@recogito/text-annotator 3.4.2 → 3.4.3
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(_,xe){typeof exports=="object"&&typeof module<"u"?xe(exports):typeof define=="function"&&define.amd?define(["exports"],xe):(_=typeof globalThis<"u"?globalThis:_||self,xe(_.RecogitoJS={}))})(this,(function(_){"use strict";const xe="not-annotatable",Ce=`.${xe}`,Xe=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(Ce):(i=t.parentElement)==null?void 0:i.closest(Ce)):!0},mn=(e,t)=>{const n=t.commonAncestorContainer;return!Xe(e,n)},bn=e=>e.addEventListener("click",t=>{!t.target.closest(Ce)&&!t.target.closest("a")&&t.preventDefault()}),ht=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}),Fe=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 Vi="2.0.6",Xi=500,wn="user-agent",Le="",yn="?",j={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},te="browser",pe="cpu",de="device",le="engine",ie="os",Ne="result",y="name",g="type",v="vendor",A="version",ee="architecture",Ye="major",b="model",Ke="console",H="mobile",Y="tablet",$="smarttv",ue="wearable",gt="xr",We="embedded",Ie="inapp",Mt="brands",Te="formFactors",Bt="fullVersionList",Me="platform",_t="platformVersion",pt="bitness",Ee="sec-ch-ua",Fi=Ee+"-full-version-list",Yi=Ee+"-arch",Ki=Ee+"-"+pt,Wi=Ee+"-form-factors",ji=Ee+"-"+H,zi=Ee+"-"+b,vn=Ee+"-"+Me,$i=vn+"-version",En=[Mt,Bt,H,b,Me,_t,ee,Te,pt],mt="Amazon",Be="Apple",An="ASUS",Sn="BlackBerry",Re="Google",On="Huawei",Dt="Lenovo",xn="Honor",bt="LG",Ut="Microsoft",Ht="Motorola",Pt="Nvidia",Cn="OnePlus",Vt="OPPO",je="Samsung",Tn="Sharp",ze="Sony",Xt="Xiaomi",Ft="Zebra",Rn="Chrome",kn="Chromium",Ae="Chromecast",wt="Edge",$e="Firefox",qe="Opera",Yt="Facebook",Ln="Sogou",_e="Mobile ",Ge=" Browser",Kt="Windows",qi=typeof window!==j.UNDEFINED,ne=qi&&window.navigator?window.navigator:void 0,Se=ne&&ne.userAgentData?ne.userAgentData:void 0,Gi=function(e,t){var n={},i=t;if(!vt(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},yt=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},Wt=function(e,t){if(typeof e===j.OBJECT&&e.length>0){for(var n in e)if(Oe(t)==Oe(e[n]))return!0;return!1}return Je(e)?Oe(t)==Oe(e):!1},vt=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?vt(e[n]):!1)},Je=function(e){return typeof e===j.STRING},jt=function(e){if(e){for(var t=[],n=De(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=Et(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=Et(n[i]);return t}},Oe=function(e){return Je(e)?e.toLowerCase():e},zt=function(e){return Je(e)?De(/[^\d\.]/g,e).split(".")[0]:void 0},me=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==j.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},De=function(e,t){return Je(t)?t.replace(e,Le):t},Qe=function(e){return De(/\\?\"/g,e)},Et=function(e,t){return e=De(/^\s\s*/,String(e)),typeof t===j.UNDEFINED?e:e.substring(0,t)},$t=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===j.OBJECT&&s.length>0?s.length===2?typeof s[1]==j.FUNCTION?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===j.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}},fe=function(e,t){for(var n in t)if(typeof t[n]===j.OBJECT&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(Wt(t[n][i],e))return n===yn?void 0:n}else if(Wt(t[n],e))return n===yn?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},Nn={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:""},In={embedded:"Automotive",mobile:"Mobile",tablet:["Tablet","EInk"],smarttv:"TV",wearable:"Watch",xr:["VR","XR"],"?":["Desktop","Unknown"],"*":void 0},Ji={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"},Mn={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[A,[y,_e+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[A,[y,wt+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[A,[y,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[y,A],[/opios[\/ ]+([\w\.]+)/i],[A,[y,qe+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[A,[y,qe+" GX"]],[/\bopr\/([\w\.]+)/i],[A,[y,qe]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[A,[y,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[A,[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,A],[/quark(?:pc)?\/([-\w\.]+)/i],[A,[y,"Quark"]],[/\bddg\/([\w\.]+)/i],[A,[y,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[A,[y,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[A,[y,"WeChat"]],[/konqueror\/([\w\.]+)/i],[A,[y,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[A,[y,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[A,[y,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[A,[y,"Smart "+Dt+Ge]],[/(avast|avg)\/([\w\.]+)/i],[[y,/(.+)/,"$1 Secure"+Ge],A],[/\bfocus\/([\w\.]+)/i],[A,[y,$e+" Focus"]],[/\bopt\/([\w\.]+)/i],[A,[y,qe+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[A,[y,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[A,[y,"Dolphin"]],[/coast\/([\w\.]+)/i],[A,[y,qe+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[A,[y,"MIUI"+Ge]],[/fxios\/([\w\.-]+)/i],[A,[y,_e+$e]],[/\bqihoobrowser\/?([\w\.]*)/i],[A,[y,"360"]],[/\b(qq)\/([\w\.]+)/i],[[y,/(.+)/,"$1Browser"],A],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[y,/(.+)/,"$1"+Ge],A],[/samsungbrowser\/([\w\.]+)/i],[A,[y,je+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[A,[y,Ln+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[y,Ln+" Mobile"],A],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[y,A],[/(lbbrowser|rekonq)/i],[y],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[A,y],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[y,Yt],A,[g,Ie]],[/(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,A,[g,Ie]],[/\bgsa\/([\w\.]+) .*safari\//i],[A,[y,"GSA"],[g,Ie]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[A,[y,"TikTok"],[g,Ie]],[/\[(linkedin)app\]/i],[y,[g,Ie]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[y,/(.+)/,"Zalo"],A,[g,Ie]],[/(chromium)[\/ ]([-\w\.]+)/i],[y,A],[/headlesschrome(?:\/([\w\.]+)| )/i],[A,[y,Rn+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[A,[y,wt+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[y,Rn+" WebView"],A],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[A,[y,"Android"+Ge]],[/chrome\/([\w\.]+) mobile/i],[A,[y,_e+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[y,A],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[A,[y,_e+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[y,_e+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[A,y],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[y,[A,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[y,A],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[y,_e+$e],A],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[y,"Netscape"],A],[/(wolvic|librewolf)\/([\w\.]+)/i],[y,A],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[A,[y,$e+" 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,[A,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[y,[A,/[^\d\.]+./,Le]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[ee,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[ee,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[ee,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[ee,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[ee,"arm"]],[/ sun4\w[;\)]/i],[[ee,"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],[[ee,/ower/,Le,Oe]],[/mc680.0/i],[[ee,"68k"]],[/winnt.+\[axp/i],[[ee,"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,je],[g,Y]],[/\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,je],[g,H]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[b,[v,Be],[g,H]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[b,[v,Be],[g,Y]],[/(macintosh);/i],[b,[v,Be]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[b,[v,Tn],[g,H]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[b,[v,xn],[g,Y]],[/honor([-\w ]+)[;\)]/i],[b,[v,xn],[g,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,[v,On],[g,Y]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[b,[v,On],[g,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," "],[v,Xt],[g,Y]],[/\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,Xt],[g,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,[v,Cn],[g,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,[v,Vt],[g,H]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[b,[v,fe,{OnePlus:["203","304","403","404","413","415"],"*":Vt}],[g,Y]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[b,[v,"BLU"],[g,H]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[b,[v,"Vivo"],[g,H]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[b,[v,"Realme"],[g,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,[v,Dt],[g,Y]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[b,[v,Dt],[g,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,[v,Ht],[g,H]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[b,[v,Ht],[g,Y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[b,[v,bt],[g,Y]],[/(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,bt],[g,H]],[/(nokia) (t[12][01])/i],[v,b,[g,Y]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[b,/_/g," "],[g,H],[v,"Nokia"]],[/(pixel (c|tablet))\b/i],[b,[v,Re],[g,Y]],[/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,Re],[g,H]],[/(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,ze],[g,H]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[b,"Xperia Tablet"],[v,ze],[g,Y]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[b,[v,mt],[g,Y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[b,/(.+)/g,"Fire Phone $1"],[v,mt],[g,H]],[/(playbook);[-\w\),; ]+(rim)/i],[b,v,[g,Y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[b,[v,Sn],[g,H]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[b,[v,An],[g,Y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[b,[v,An],[g,H]],[/(nexus 9)/i],[b,[v,"HTC"],[g,Y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[v,[b,/_/g," "],[g,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,[v,"TCL"],[g,Y]],[/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"],[g,H]],[/(itel) ((\w+))/i],[[v,Oe],b,[g,fe,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[b,[v,"Acer"],[g,Y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[b,[v,"Meizu"],[g,H]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[b,[v,"Ulefone"],[g,H]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[b,[v,"Energizer"],[g,H]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[b,[v,"Cat"],[g,H]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[b,[v,"Smartfren"],[g,H]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[b,[v,"Nothing"],[g,H]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[b,[v,"Archos"],[g,Y]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[b,[v,"Archos"],[g,H]],[/; (n159v)/i],[b,[v,"HMD"],[g,H]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[v,b,[g,Y]],[/(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,[g,H]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[v,b,[g,Y]],[/(surface duo)/i],[b,[v,Ut],[g,Y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[b,[v,"Fairphone"],[g,H]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[b,[v,Pt],[g,Y]],[/(sprint) (\w+)/i],[v,b,[g,H]],[/(kin\.[onetw]{3})/i],[[b,/\./g," "],[v,Ut],[g,H]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[b,[v,Ft],[g,Y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[b,[v,Ft],[g,H]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[v,[g,$]],[/hbbtv.+maple;(\d+)/i],[[b,/^/,"SmartTV"],[v,je],[g,$]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[v,b,[g,$]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[v,bt],[g,$]],[/(apple) ?tv/i],[v,[b,Be+" TV"],[g,$]],[/crkey.*devicetype\/chromecast/i],[[b,Ae+" Third Generation"],[v,Re],[g,$]],[/crkey.*devicetype\/([^/]*)/i],[[b,/^/,"Chromecast "],[v,Re],[g,$]],[/fuchsia.*crkey/i],[[b,Ae+" Nest Hub"],[v,Re],[g,$]],[/crkey/i],[[b,Ae],[v,Re],[g,$]],[/(portaltv)/i],[b,[v,Yt],[g,$]],[/droid.+aft(\w+)( bui|\))/i],[b,[v,mt],[g,$]],[/(shield \w+ tv)/i],[b,[v,Pt],[g,$]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[b,[v,Tn],[g,$]],[/(bravia[\w ]+)( bui|\))/i],[b,[v,ze],[g,$]],[/(mi(tv|box)-?\w+) bui/i],[b,[v,Xt],[g,$]],[/Hbbtv.*(technisat) (.*);/i],[v,b,[g,$]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[v,/.+\/(\w+)/,"$1",fe,{LG:"lge"}],[b,Et],[g,$]],[/(playstation \w+)/i],[b,[v,ze],[g,Ke]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[b,[v,Ut],[g,Ke]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[v,b,[g,Ke]],[/droid.+; (shield)( bui|\))/i],[b,[v,Pt],[g,Ke]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[b,[v,je],[g,ue]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[v,b,[g,ue]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[b,[v,Vt],[g,ue]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[b,[v,Be],[g,ue]],[/(opwwe\d{3})/i],[b,[v,Cn],[g,ue]],[/(moto 360)/i],[b,[v,Ht],[g,ue]],[/(smartwatch 3)/i],[b,[v,ze],[g,ue]],[/(g watch r)/i],[b,[v,bt],[g,ue]],[/droid.+; (wt63?0{2,3})\)/i],[b,[v,Ft],[g,ue]],[/droid.+; (glass) \d/i],[b,[v,Re],[g,gt]],[/(pico) ([\w ]+) os\d/i],[v,b,[g,gt]],[/(quest( \d| pro)?s?).+vr/i],[b,[v,Yt],[g,gt]],[/mobile vr; rv.+firefox/i],[[g,gt]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[v,[g,We]],[/(aeobc)\b/i],[b,[v,mt],[g,We]],[/(homepod).+mac os/i],[b,[v,Be],[g,We]],[/windows iot/i],[[g,We]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[b,[g,$]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[g,$]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[b,[g,fe,{mobile:"Mobile",xr:"VR","*":Y}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[g,Y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[g,H]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[b,[v,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[A,[y,wt+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[y,A],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[A,[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,A],[/ladybird\//i],[[y,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[A,y]],os:[[/(windows nt) (6\.[23]); arm/i],[[y,/N/,"R"],[A,fe,Nn]],[/(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,A],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[A,/(;|\))/g,"",fe,Nn],[y,Kt]],[/(windows ce)\/?([\d\.]*)/i],[y,A],[/[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],[[A,/_/g,"."],[y,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[y,"macOS"],[A,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[A,[y,Ae+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[A,[y,Ae+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[A,[y,Ae+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[A,[y,Ae+" Linux"]],[/crkey\/([\d\.]+)/i],[A,[y,Ae]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[A,y],[/(ubuntu) ([\w\.]+) like android/i],[[y,/(.+)/,"$1 Touch"],A],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[y,A],[/\(bb(10);/i],[A,[y,Sn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[A,[y,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[A,[y,$e+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[A,[y,"webOS"]],[/web0s;.+?(?:chr[o0]me|safari)\/(\d+)/i],[[A,fe,{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],[A,[y,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[y,"Chrome OS"],A],[/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,A],[/(sunos) ?([\d\.]*)/i],[[y,"Solaris"],A],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[y,A]]},At=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return me.call(e.init,[[te,[y,A,Ye,g]],[pe,[ee]],[de,[g,b,v]],[le,[y,A]],[ie,[y,A]]]),me.call(e.isIgnore,[[te,[A,Ye]],[le,[A]],[ie,[A]]]),me.call(e.isIgnoreRgx,[[te,/ ?browser$/i],[ie,/ ?os$/i]]),me.call(e.toString,[[te,[y,A]],[pe,[ee]],[de,[v,b]],[le,[y,A]],[ie,[y,A]]]),e})(),Qi=function(e,t){var n=At.init[t],i=At.isIgnore[t]||0,o=At.isIgnoreRgx[t]||0,r=At.toString[t]||0;function s(){me.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Se?Se.getHighEntropyValues(En).then(function(a){return e.setCH(new Bn(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Ne&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!Wt(i,c)&&Oe(o?De(o,this[c]):this[c])==Oe(o?De(o,a):a)){if(l=!0,a!=j.UNDEFINED)break}else if(a==j.UNDEFINED&&l){l=!l;break}return l},s.prototype.toString=function(){var a=Le;for(var l in r)typeof this[r[l]]!==j.UNDEFINED&&(a+=(a?" ":Le)+this[r[l]]);return a||j.UNDEFINED}),Se||(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 Bn(e,t){if(e=e||{},me.call(this,En),t)me.call(this,[[Mt,jt(e[Ee])],[Bt,jt(e[Fi])],[H,/\?1/.test(e[ji])],[b,Qe(e[zi])],[Me,Qe(e[vn])],[_t,Qe(e[$i])],[ee,Qe(e[Yi])],[Te,jt(e[Wi])],[pt,Qe(e[Ki])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==j.UNDEFINED&&(this[n]=e[n])}function _n(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(ne&&ne.userAgent==this.ua)switch(this.itemType){case te:ne.brave&&typeof ne.brave.isBrave==j.FUNCTION&&this.set(y,"Brave");break;case de:!this.get(g)&&Se&&Se[H]&&this.set(g,H),this.get(b)=="Macintosh"&&ne&&typeof ne.standalone!==j.UNDEFINED&&ne.maxTouchPoints&&ne.maxTouchPoints>2&&this.set(b,"iPad").set(g,Y);break;case ie:!this.get(y)&&Se&&Se[Me]&&this.set(y,Se[Me]);break;case Ne:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(te,r(te)).set(pe,r(pe)).set(de,r(de)).set(le,r(le)).set(ie,r(ie))}return this},this.parseUA=function(){switch(this.itemType!=Ne&&$t.call(this.data,this.ua,this.rgxMap),this.itemType){case te:this.set(Ye,zt(this.get(A)));break;case ie:if(this.get(y)=="iOS"&&this.get(A)=="18.6"){var o=/\) Version\/([\d\.]+)/.exec(this.ua);o&&parseInt(o[1].substring(0,2),10)>=26&&this.set(A,o[1])}break}return this},this.parseCH=function(){var o=this.uaCH,r=this.rgxMap;switch(this.itemType){case te:case le:var s=o[Bt]||o[Mt],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==te&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=kn||a==wt&&/WebView2/.test(c))&&(c=fe(c,Ji),a=this.get(y),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(y,c).set(A,u).set(Ye,zt(u)),a=c),this.itemType==le&&c==kn&&this.set(A,u)}break;case pe:var d=o[ee];d&&(d&&o[pt]=="64"&&(d+="64"),$t.call(this.data,d+";",r));break;case de:if(o[H]&&this.set(g,H),o[b]&&(this.set(b,o[b]),!this.get(g)||!this.get(v))){var E={};$t.call(E,"droid 9; "+o[b]+")",r),!this.get(g)&&E.type&&this.set(g,E.type),!this.get(v)&&E.vendor&&this.set(v,E.vendor)}if(o[Te]){var f;if(typeof o[Te]!="string")for(var C=0;!f&&C<o[Te].length;)f=fe(o[Te][C++],In);else f=fe(o[Te],In);this.set(g,f)}break;case ie:var p=o[Me];if(p){var S=o[_t];p==Kt&&(S=parseInt(zt(S),10)>=13?"11":"10"),this.set(y,p).set(A,S)}this.get(y)==Kt&&o[b]=="Xbox"&&this.set(y,"Xbox").set(A,void 0);break;case Ne:var m=this.data,h=function(k){return m[k].getItem().setCH(o).parseCH().get()};this.set(te,h(te)).set(pe,h(pe)).set(de,h(de)).set(le,h(le)).set(ie,h(ie))}return this},me.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",Qi(this,e)]]),this}function be(e,t,n){if(typeof e===j.OBJECT?(vt(e,!0)?(typeof t===j.OBJECT&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===j.STRING&&!vt(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===j.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 be))return new be(e,t,n).getResult();var s=typeof e===j.STRING?e:n&&n[wn]?n[wn]:ne&&ne.userAgent?ne.userAgent:Le,a=new Bn(n,!0),l=t?Gi(Mn,t):Mn,c=function(u){return u==Ne?function(){return new _n(u,s,l,a).set("ua",s).set(te,this.getBrowser()).set(pe,this.getCPU()).set(de,this.getDevice()).set(le,this.getEngine()).set(ie,this.getOS()).get()}:function(){return new _n(u,s,l[u],a).parseUA().get()}};return me.call(this,[["getBrowser",c(te)],["getCPU",c(pe)],["getDevice",c(de)],["getEngine",c(le)],["getOS",c(ie)],["getResult",c(Ne)],["getUA",function(){return s}],["setUA",function(u){return Je(u)&&(s=Et(u,Xi)),this}]]).setUA(s),this}be.VERSION=Vi,be.BROWSER=yt([y,A,Ye,g]),be.CPU=yt([ee]),be.DEVICE=yt([b,v,g,Ke,H,$,Y,ue,We]),be.ENGINE=be.OS=yt([y,A]);const Zi=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"}),qt=be().os.is(Zi.MACOS),Dn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Un=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())]}},eo=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,i=>i instanceof HTMLElement&&i.classList.contains(xe)&&!i.parentElement.closest(Ce)&&e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Hn=(e,t)=>{if(!mn(e,t))return[];const n=[];let i=null;for(const o of eo(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]},St=e=>{const t=e.cloneContents();return t.querySelectorAll(Ce).forEach(n=>n.remove()),t},Pn=(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=St(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=St(a).textContent;return{prefix:s.substring(s.length-n),suffix:l.substring(0,n)}},he=e=>e.every(t=>t.range instanceof Range&&!t.range.collapsed),Gt=/^\s*$/,Vn=e=>Gt.test(e.toString()),to=e=>Gt.test(e.textContent||""),no=(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"},io=(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)},Xn=(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=no(o,a,t,n);if(l==="inline-adjacent"){r=r.map(c=>c===a?io(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]},[]),oo=e=>({length:e.length,item:t=>e[t],[Symbol.iterator]:function*(){for(let t=0;t<this.length;t++)yield this.item(t)}}),Fn=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]},Yn=(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=St(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}},Kn=(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)},ro=(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)},Jt=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,E=>{var f;return(f=E.parentElement)!=null&&f.closest(Ce)?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 E=((u=l.textContent)==null?void 0:u.length)||0;if(s+E>n){a.setStart(l,n-s);break}s+=E}l=r.nextNode()}for(;l!==null;){const E=((d=l.textContent)==null?void 0:d.length)||0;if(s+E>=i){a.setEnd(l,i-s);break}s+=E,l=r.nextNode()}return{...e,range:a}},Ze=(e,t)=>he(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Jt(n,t))},Ot=(e,t)=>he(e.target.selector)?e:{...e,target:Ze(e.target,t)},Wn=(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},jn=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:jn(e.parentElement)},zn=(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,E=n.parentElement?n.scrollLeft:0,f=c+d-(o-l)/2,C=u+E-(r-a)/2;n.scroll({top:f,left:C,behavior:"smooth"})},$n=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:jn(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 zn(t,s.target,r),!0;const l=Ze(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(zn(t,l,r),!0):!1},ge={fill:"rgb(0, 128, 255)",fillOpacity:.18},et={fill:"rgb(0, 128, 255)",fillOpacity:.45},qn=(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?et:ge):n:(a=e.state)!=null&&a.selected?et:ge;return i&&i.paint(e,t)||r};function so(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var xt={exports:{}},Gn;function ao(){if(Gn)return xt.exports;Gn=1;function e(t,n=100,i={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:o}=typeof i=="boolean"?{immediate:i}:i;let r,s,a,l,c;function u(){const f=r,C=s;return r=void 0,s=void 0,c=t.apply(f,C),c}function d(){const f=Date.now()-l;f<n&&f>=0?a=setTimeout(d,n-f):(a=void 0,o||(c=u()))}const E=function(...f){if(r&&this!==r&&Object.getPrototypeOf(this)===Object.getPrototypeOf(r))throw new Error("Debounced method called with different contexts of the same prototype.");r=this,s=f,l=Date.now();const C=o&&!a;return a||(a=setTimeout(d,n)),C&&(c=u()),c};return Object.defineProperty(E,"isPending",{get(){return a!==void 0}}),E.clear=()=>{a&&(clearTimeout(a),a=void 0)},E.flush=()=>{a&&E.trigger()},E.trigger=()=>{c=u(),E.clear()},E}return xt.exports.debounce=e,xt.exports=e,xt.exports}var lo=ao();const tt=so(lo),co=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}},uo=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)}},Qt=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const u=uo(n),d=U=>{const{x:P,y:X}=e.getBoundingClientRect(),O=o.getAt(U.clientX-P,U.clientY-X,!1,l);O?s.current!==O.id&&(e.classList.add("hovered"),s.set(O.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",d);const E=tt((U=!1)=>requestAnimationFrame(()=>{c&&c.clear();const P=co(e),{minX:X,minY:O,maxX:T,maxY:R}=P,w=l?o.getIntersecting(X,O,T,R).filter(({annotation:V})=>l(V)):o.getIntersecting(X,O,T,R),I=r.selected.map(({id:V})=>V),D=w.map(({annotation:V,rects:z})=>{const ae=I.includes(V.id),ve=V.id===s.current;return{annotation:V,rects:z,state:{selected:ae,hovered:ve}}});i.redraw(D,P,a,c,U),setTimeout(()=>u(w.map(({annotation:V})=>V)),1)}),10),f=U=>{c=U,E()},C=U=>{a=U,E()},p=U=>{l=U,E(!1)},S=()=>E();o.observe(S);const m=r.subscribe(()=>E()),h=s.subscribe(()=>E()),k=()=>E(!0);document.addEventListener("scroll",k,{capture:!0,passive:!0});const L=tt(()=>{o.recalculatePositions(),c==null||c.reset(),E()},10);window.addEventListener("resize",L);const x=new ResizeObserver(L);x.observe(e);const N={attributes:!0,childList:!0,subtree:!0},B=new MutationObserver(tt(U=>{U.every(X=>X.target===e||e.contains(X.target))||E(!0)},150));return B.observe(document.body,N),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(S),m(),h(),document.removeEventListener("scroll",k),L.clear(),window.removeEventListener("resize",L),x.disconnect(),B.disconnect()},redraw:E,setStyle:C,setFilter:p,setPainter:f,setVisible:i.setVisible}},fo=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},ho=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},go=e=>{e.classList.add("r6o-annotatable");const t=fo(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:E}=t;n.clearRect(-.5,-.5,d+1,E+1),u&&u.clear();const{top:f,left:C}=l;[...a].sort((S,m)=>{const{annotation:{target:{created:h}}}=S,{annotation:{target:{created:k}}}=m;return h.getTime()-k.getTime()}).forEach(S=>{var L;const m=c?typeof c=="function"?c(S.annotation,S.state):c:(L=S.state)!=null&&L.selected?et:ge,h=u&&u.paint(S,l)||m,k=S.rects.map(({x,y:N,width:B,height:M})=>({x:x+C,y:N+f,width:B,height:M}));if(n.fillStyle=h.fill,n.globalAlpha=h.fillOpacity||1,k.forEach(({x,y:N,width:B,height:M})=>n.fillRect(x,N,B,M)),h.underlineColor){n.globalAlpha=1,n.strokeStyle=h.underlineColor,n.lineWidth=h.underlineThickness??1;const x=h.underlineOffset??0;k.forEach(({x:N,y:B,width:M,height:U})=>{n.beginPath(),n.moveTo(N,B+U+x),n.lineTo(N+M,B+U+x),n.stroke()})}})}),o=tt(()=>ho(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}},Jn=(e,t,n)=>Qt(e,t,n,go(e));var po={grad:.9,turn:360,rad:360/(2*Math.PI)},we=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},oe=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=1),e>n?n:e>t?e:t},Qn=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},Zn=function(e){return{r:oe(e.r,0,255),g:oe(e.g,0,255),b:oe(e.b,0,255),a:oe(e.a)}},Zt=function(e){return{r:q(e.r),g:q(e.g),b:q(e.b),a:q(e.a,3)}},mo=/^#([0-9a-f]{3,8})$/i,Ct=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},ei=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}},ti=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}},ni=function(e){return{h:Qn(e.h),s:oe(e.s,0,100),l:oe(e.l,0,100),a:oe(e.a)}},ii=function(e){return{h:q(e.h),s:q(e.s),l:q(e.l),a:q(e.a,3)}},oi=function(e){return ti((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},nt=function(e){return{h:(t=ei(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},bo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,wo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vo=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ri={string:[[function(e){var t=mo.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=yo.exec(e)||vo.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:Zn({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=bo.exec(e)||wo.exec(e);if(!t)return null;var n,i,o=ni({h:(n=t[1],i=t[2],i===void 0&&(i="deg"),Number(n)*(po[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return oi(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 we(t)&&we(n)&&we(i)?Zn({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(!we(t)||!we(n)||!we(i))return null;var s=ni({h:Number(t),s:Number(n),l:Number(i),a:Number(r)});return oi(s)},"hsl"],[function(e){var t=e.h,n=e.s,i=e.v,o=e.a,r=o===void 0?1:o;if(!we(t)||!we(n)||!we(i))return null;var s=(function(a){return{h:Qn(a.h),s:oe(a.s,0,100),v:oe(a.v,0,100),a:oe(a.a)}})({h:Number(t),s:Number(n),v:Number(i),a:Number(r)});return ti(s)},"hsv"]]},si=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]},Eo=function(e){return typeof e=="string"?si(e.trim(),ri.string):typeof e=="object"&&e!==null?si(e,ri.object):[null,void 0]},en=function(e,t){var n=nt(e);return{h:n.h,s:oe(n.s+100*t,0,100),l:n.l,a:n.a}},tn=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},ai=function(e,t){var n=nt(e);return{h:n.h,s:n.s,l:oe(n.l+100*t,0,100),a:n.a}},li=(function(){function e(t){this.parsed=Eo(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(tn(this.rgba),2)},e.prototype.isDark=function(){return tn(this.rgba)<.5},e.prototype.isLight=function(){return tn(this.rgba)>=.5},e.prototype.toHex=function(){return t=Zt(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?Ct(q(255*r)):"","#"+Ct(n)+Ct(i)+Ct(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return Zt(this.rgba)},e.prototype.toRgbString=function(){return t=Zt(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 ii(nt(this.rgba))},e.prototype.toHslString=function(){return t=ii(nt(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=ei(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 re({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),re(en(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),re(en(this.rgba,-t))},e.prototype.grayscale=function(){return re(en(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),re(ai(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),re(ai(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"?re({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=nt(this.rgba);return typeof t=="number"?re({h:t,s:n.s,l:n.l,a:n.a}):q(n.h)},e.prototype.isEqual=function(t){return this.toHex()===re(t).toHex()},e})(),re=function(e){return e instanceof li?e:new li(e)};const Ao=e=>[`background-color:${re((e==null?void 0:e.fill)||ge.fill).alpha((e==null?void 0:e.fillOpacity)===void 0?ge.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(";"),ci=()=>{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 C;const E=a?typeof a=="function"?a(d.annotation,d.state):a:(C=d.state)!=null&&C.selected?et:ge,f=l&&l.paint(d,s)||E;return`::highlight(_${d.annotation.id}) { ${Ao(f)} }`});e.innerHTML=u.join(`
|
|
2
|
-
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const E=d.target.selector.map(C=>C.range),f=new Highlight(...E);CSS.highlights.set(`_${d.id}`,f)}),t=c}}},di=(e,t,n)=>Qt(e,t,n,ci());var ui=Object.prototype.hasOwnProperty;function nn(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--&&nn(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(ui.call(e,n)&&++i&&!ui.call(t,n)||!(n in t)||!nn(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const So=e=>(e==null?void 0:e.fillOpacity)!==void 0?re((e==null?void 0:e.fill)||ge.fill).alpha(e.fillOpacity).toHex():e!=null&&e.fill?e.fill:re(ge.fill).alpha(ge.fillOpacity).toHex(),Oo=(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))},xo=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 E=!(nn(n,s)&&u);if(!c&&!E)return;E&&(t.innerHTML=""),[...s].sort((C,p)=>{const{annotation:{target:{created:S}}}=C,{annotation:{target:{created:m}}}=p;return S&&m?S.getTime()-m.getTime():0}).forEach(C=>{C.rects.map(p=>{const S=Oo(p,s),m=qn(C,a,l,c,S);if(E){const h=document.createElement("span");h.className="r6o-annotation",h.dataset.annotation=C.annotation.id,h.style.left=`${p.x}px`,h.style.top=`${p.y}px`,h.style.width=`${p.width}px`,h.style.height=`${p.height}px`,h.style.backgroundColor=So(m),m.underlineStyle&&(h.style.borderStyle=m.underlineStyle),m.underlineColor&&(h.style.borderColor=m.underlineColor),m.underlineThickness&&(h.style.borderBottomWidth=`${m.underlineThickness}px`),m.underlineOffset&&(h.style.paddingBottom=`${m.underlineOffset}px`),t.appendChild(h)}})}),n=s},setVisible:s=>{s?t.classList.remove("hidden"):t.classList.add("hidden")}}},fi=(e,t,n)=>Qt(e,t,n,xo(e)),J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function Co(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 on;const To=new Uint8Array(16);function Ro(){if(!on){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");on=crypto.getRandomValues.bind(crypto)}return on(To)}const hi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ko(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??Ro();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,Co(i)}function gi(e,t,n){return hi.randomUUID&&!e?hi.randomUUID():ko(e)}var pi=Object.prototype.hasOwnProperty;function ke(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--&&ke(e[i],t[i]););return i===-1}if(!n||typeof e=="object"){i=0;for(n in e)if(pi.call(e,n)&&++i&&!pi.call(t,n)||!(n in t)||!ke(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}function rn(){}function Lo(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const Ue=[];function sn(e,t=rn){let n;const i=new Set;function o(a){if(Lo(e,a)&&(e=a,n)){const l=!Ue.length;for(const c of i)c[1](),Ue.push(c,e);if(l){for(let c=0;c<Ue.length;c+=2)Ue[c][0](Ue[c+1]);Ue.length=0}}}function r(a){o(a(e))}function s(a,l=rn){const c=[a,l];return i.add(c),i.size===1&&(n=t(o,r)||rn),a(e),()=>{i.delete(c),i.size===0&&n&&(n(),n=null)}}return{set:o,update:r,subscribe:s}}const No=e=>{const{subscribe:t,set:n}=sn();let i;return t(o=>i=o),e.observe(({changes:o})=>{if(i){(o.deleted||[]).some(s=>s.id===i)&&n(void 0);const r=(o.updated||[]).find(({oldValue:s})=>s.id===i);r&&n(r.newValue.id)}}),{get current(){return i},subscribe:t,set:n}};var mi=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(mi||{});const Tt={selected:[]},Io=(e,t,n)=>{const{subscribe:i,set:o}=sn(Tt);let r=t,s=Tt;i(p=>s=p);const a=()=>{ke(s,Tt)||o(Tt)},l=()=>{var p;return((p=s.selected)==null?void 0:p.length)===0},c=p=>{if(l())return!1;const S=typeof p=="string"?p:p.id;return s.selected.some(m=>m.id===S)},u=(p,S)=>{let m;if(Array.isArray(p)){if(m=p.map(k=>e.getAnnotation(k)).filter(Boolean),m.length<p.length){console.warn("Invalid selection: "+p.filter(k=>!m.some(L=>L.id===k)));return}}else{const k=e.getAnnotation(p);if(!k){console.warn("Invalid selection: "+p);return}m=[k]}const h=m.reduce((k,L)=>{const x=C(L);return x==="EDIT"?[...k,{id:L.id,editable:!0}]:x==="SELECT"?[...k,{id:L.id}]:k},[]);o({selected:h,event:S})},d=(p,S)=>{const m=Array.isArray(p)?p:[p],h=m.map(k=>e.getAnnotation(k)).filter(k=>!!k);o({selected:h.map(k=>{const L=S===void 0?C(k)==="EDIT":S;return{id:k.id,editable:L}})}),h.length!==m.length&&console.warn("Invalid selection",p)},E=p=>{if(l())return!1;const{selected:S}=s;S.some(({id:m})=>p.includes(m))&&o({selected:S.filter(({id:m})=>!p.includes(m))})},f=p=>{r=p,d(s.selected.map(({id:S})=>S))},C=p=>Mo(p,r,n);return e.observe(({changes:p})=>E((p.deleted||[]).map(S=>S.id))),{get event(){return s?s.event:null},get selected(){return s?[...s.selected]:null},get userSelectAction(){return r},clear:a,evalSelectAction:C,isEmpty:l,isSelected:c,setSelected:d,setUserSelectAction:f,subscribe:i,userSelect:u}},Mo=(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 Bo(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 an;const _o=new Uint8Array(16);function Do(){if(!an){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");an=crypto.getRandomValues.bind(crypto)}return an(_o)}const Uo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),bi={randomUUID:Uo};function Ho(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??Do();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,Bo(o)}function wi(e,t,n){return bi.randomUUID&&!e?bi.randomUUID():Ho(e)}const ln=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)}},Po=(e,t,n,i)=>({id:wi(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),Vo=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},Xo=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},Fo=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!ke(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),Yo=(e,t)=>!ke(e.target,t.target),yi=(e,t)=>{const n=Vo(e,t),i=Xo(e,t),o=Fo(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:Yo(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var F=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(F||{});const Ko=(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},Wo=(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:E})=>E.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:E,newValue:f}=d;if(s.has(f.id)){const C=t.updated.find(p=>p.oldValue.id===f.id).newValue;return yi(E,C)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Rt=e=>{const t=e.id===void 0?wi():e.id;return{...e,id:t,bodies:e.bodies===void 0?[]:e.bodies.map(n=>({...n,annotation:t})),target:{...e.target,annotation:t}}},jo=e=>e.id!==void 0,zo=()=>{const e=new Map,t=new Map,n=[],i=(O,T={})=>{n.push({onChange:O,options:T})},o=O=>{const T=n.findIndex(R=>R.onChange==O);T>-1&&n.splice(T,1)},r=(O,T)=>{const R={origin:O,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...e.values()]};n.forEach(w=>{Ko(w,R)&&w.onChange(R)})},s=(O,T=F.LOCAL)=>{if(O.id&&e.get(O.id))throw Error(`Cannot add annotation ${O.id} - exists already`);{const R=Rt(O);e.set(R.id,R),R.bodies.forEach(w=>t.set(w.id,R.id)),r(T,{created:[R]})}},a=(O,T)=>{const R=Rt(typeof O=="string"?T:O),w=typeof O=="string"?O:O.id,I=w&&e.get(w);if(I){const D=yi(I,R);return w===R.id?e.set(w,R):(e.delete(w),e.set(R.id,R)),I.bodies.forEach(V=>t.delete(V.id)),R.bodies.forEach(V=>t.set(V.id,R.id)),D}else console.warn(`Cannot update annotation ${w} - does not exist`)},l=(O,T=F.LOCAL,R=F.LOCAL)=>{const w=jo(T)?R:T,I=a(O,T);I&&r(w,{updated:[I]})},c=(O,T=F.LOCAL)=>{e.get(O.id)?l(O,T):s(O,T)},u=(O,T=F.LOCAL)=>{const R=O.reduce((w,I)=>{const D=a(I);return D?[...w,D]:w},[]);R.length>0&&r(T,{updated:R})},d=(O,T=F.LOCAL)=>{const R=O.map(Rt),{toAdd:w,toUpdate:I}=R.reduce((V,z)=>e.get(z.id)?{...V,toUpdate:[...V.toUpdate,z]}:{...V,toAdd:[...V.toAdd,z]},{toAdd:[],toUpdate:[]}),D=I.map(V=>a(V,T)).filter(Boolean);w.forEach(V=>{e.set(V.id,V),V.bodies.forEach(z=>t.set(z.id,V.id))}),r(T,{created:w,updated:D})},E=(O,T=F.LOCAL)=>{const R=e.get(O.annotation);if(R){const w={...R,bodies:[...R.bodies,O]};e.set(R.id,w),t.set(O.id,w.id),r(T,{updated:[{oldValue:R,newValue:w,bodiesCreated:[O]}]})}else console.warn(`Attempt to add body to missing annotation: ${O.annotation}`)},f=()=>[...e.values()],C=(O=F.LOCAL)=>{const T=[...e.values()];e.clear(),t.clear(),r(O,{deleted:T})},p=(O,T=!0,R=F.LOCAL)=>{const w=O.map(Rt);if(T){const I=[...e.values()];e.clear(),t.clear(),w.forEach(D=>{e.set(D.id,D),D.bodies.forEach(V=>t.set(V.id,D.id))}),r(R,{created:w,deleted:I})}else{const I=O.reduce((D,V)=>{const z=V.id&&e.get(V.id);return z?[...D,z]:D},[]);if(I.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${I.map(D=>D.id).join(", ")}`);w.forEach(D=>{e.set(D.id,D),D.bodies.forEach(V=>t.set(V.id,D.id))}),r(R,{created:w})}},S=O=>{const T=typeof O=="string"?O:O.id,R=e.get(T);if(R)return e.delete(T),R.bodies.forEach(w=>t.delete(w.id)),R;console.warn(`Attempt to delete missing annotation: ${T}`)},m=(O,T=F.LOCAL)=>{const R=S(O);R&&r(T,{deleted:[R]})},h=(O,T=F.LOCAL)=>{const R=O.reduce((w,I)=>{const D=S(I);return D?[...w,D]:w},[]);R.length>0&&r(T,{deleted:R})},k=O=>{const T=e.get(O.annotation);if(T){const R=T.bodies.find(w=>w.id===O.id);if(R){t.delete(R.id);const w={...T,bodies:T.bodies.filter(I=>I.id!==O.id)};return e.set(T.id,w),{oldValue:T,newValue:w,bodiesDeleted:[R]}}else console.warn(`Attempt to delete missing body ${O.id} from annotation ${O.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${O.annotation}`)},L=(O,T=F.LOCAL)=>{const R=k(O);R&&r(T,{updated:[R]})},x=(O,T=F.LOCAL)=>{const R=O.map(w=>k(w)).filter(Boolean);R.length>0&&r(T,{updated:R})},N=O=>{const T=e.get(O);return T?{...T}:void 0},B=O=>{const T=t.get(O);if(T){const R=N(T).bodies.find(w=>w.id===O);if(R)return R;console.error(`Store integrity error: body ${O} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${O}`)},M=(O,T)=>{if(O.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const R=e.get(O.annotation);if(R){const w=R.bodies.find(D=>D.id===O.id),I={...R,bodies:R.bodies.map(D=>D.id===w.id?T:D)};return e.set(R.id,I),w.id!==T.id&&(t.delete(w.id),t.set(T.id,I.id)),{oldValue:R,newValue:I,bodiesUpdated:[{oldBody:w,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${O.annotation}`)},U=(O,T,R=F.LOCAL)=>{const w=M(O,T);w&&r(R,{updated:[w]})},P=(O,T=F.LOCAL)=>{const R=O.map(w=>M({id:w.id,annotation:w.annotation},w)).filter(Boolean);r(T,{updated:R})},X=O=>{const T=e.get(O.annotation);if(T){const R={...T,target:{...T.target,...O}};return e.set(T.id,R),{oldValue:T,newValue:R,targetUpdated:{oldTarget:T.target,newTarget:O}}}else console.warn(`Attempt to update target on missing annotation: ${O.annotation}`)};return{addAnnotation:s,addBody:E,all:f,bulkAddAnnotations:p,bulkDeleteAnnotations:h,bulkDeleteBodies:x,bulkUpdateAnnotations:u,bulkUpdateBodies:P,bulkUpdateTargets:(O,T=F.LOCAL)=>{const R=O.map(w=>X(w)).filter(Boolean);R.length>0&&r(T,{updated:R})},bulkUpsertAnnotations:d,clear:C,deleteAnnotation:m,deleteBody:L,getAnnotation:N,getBody:B,observe:i,unobserve:o,updateAnnotation:l,updateBody:U,updateTarget:(O,T=F.LOCAL)=>{const R=X(O);R&&r(T,{updated:[R]})},upsertAnnotation:c}};let $o=()=>({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 qo=250,Go=(e,t)=>{const n=$o(),i=[];let o=-1,r=!1,s=0;const a=C=>{if(!r){const{changes:p}=C,S=performance.now();if(S-s>qo)i.splice(o+1),i.push(p),o=i.length-1;else{const m=i.length-1;i[m]=Wo(i[m],p)}s=S}r=!1};e.observe(a,{origin:F.LOCAL});const l=C=>C&&C.length>0&&e.bulkDeleteAnnotations(C),c=C=>C&&C.length>0&&e.bulkAddAnnotations(C,!1),u=C=>C&&C.length>0&&e.bulkUpdateAnnotations(C.map(({oldValue:p})=>p)),d=C=>C&&C.length>0&&e.bulkUpdateAnnotations(C.map(({newValue:p})=>p)),E=C=>C&&C.length>0&&e.bulkAddAnnotations(C,!1),f=C=>C&&C.length>0&&e.bulkDeleteAnnotations(C);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(C,p)=>n.on(C,p),redo:()=>{if(i.length-1>o){r=!0;const{created:C,updated:p,deleted:S}=i[o+1];c(C),d(p),f(S),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:C,updated:p,deleted:S}=i[o];l(C),u(p),E(S),n.emit("undo",i[o]),o-=1}}}},Jo=()=>{const{subscribe:e,set:t}=sn([]);return{subscribe:e,set:t}},Qo=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(p,S)=>{l.has(p)?l.get(p).push(S):l.set(p,[S])},E=(p,S)=>{const m=l.get(p);if(m){const h=m.indexOf(S);h!==-1&&m.splice(h,1)}},f=(p,S,m)=>{l.has(p)&&setTimeout(()=>{l.get(p).forEach(h=>{if(n){const k=Array.isArray(S)?S.map(x=>n.serialize(x)):n.serialize(S),L=m?m instanceof PointerEvent?m:n.serialize(m):void 0;h(k,L)}else h(S,m)})},1)};r.subscribe(({selected:p})=>{if(!(c.length===0&&p.length===0)){if(c.length===0&&p.length>0)c=p.map(({id:S})=>s.getAnnotation(S));else if(c.length>0&&p.length===0)c.forEach(S=>{const m=s.getAnnotation(S.id);m&&!ke(m,S)&&f("updateAnnotation",m,S)}),c=[];else{const S=new Set(c.map(h=>h.id)),m=new Set(p.map(({id:h})=>h));c.filter(h=>!m.has(h.id)).forEach(h=>{const k=s.getAnnotation(h.id);k&&!ke(k,h)&&f("updateAnnotation",k,h)}),c=[...c.filter(h=>m.has(h.id)),...p.filter(({id:h})=>!S.has(h)).map(({id:h})=>s.getAnnotation(h))]}f("selectionChanged",c)}}),o.subscribe(p=>{!u&&p?f("mouseEnterAnnotation",s.getAnnotation(p)):u&&!p?f("mouseLeaveAnnotation",s.getAnnotation(u)):u&&p&&(f("mouseLeaveAnnotation",s.getAnnotation(u)),f("mouseEnterAnnotation",s.getAnnotation(p))),u=p}),a==null||a.subscribe(p=>f("viewportIntersect",p.map(S=>s.getAnnotation(S)))),s.observe(p=>{const{created:S,deleted:m}=p.changes;(S||[]).forEach(h=>f("createAnnotation",h)),(m||[]).forEach(h=>f("deleteAnnotation",h)),(p.changes.updated||[]).filter(h=>[...h.bodiesCreated||[],...h.bodiesDeleted||[],...h.bodiesUpdated||[]].length>0).forEach(({oldValue:h,newValue:k})=>{const L=c.find(x=>x.id===h.id)||h;c=c.map(x=>x.id===h.id?k:x),f("updateAnnotation",k,L)})},{origin:F.LOCAL}),s.observe(p=>{if(c){const S=new Set(c.map(h=>h.id)),m=(p.changes.updated||[]).filter(({newValue:h})=>S.has(h.id)).map(({newValue:h})=>h);m.length>0&&(c=c.map(h=>m.find(L=>L.id===h.id)||h))}},{origin:F.REMOTE});const C=p=>S=>{const{updated:m}=S;p?(m||[]).forEach(h=>f("updateAnnotation",h.oldValue,h.newValue)):(m||[]).forEach(h=>f("updateAnnotation",h.newValue,h.oldValue))};return t.on("undo",C(!0)),t.on("redo",C(!1)),{on:d,off:E,emit:f}},Zo=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:[]}),er=(e,t,n)=>{const{store:i,selection:o}=e,r=m=>{if(n){const{parsed:h,error:k}=n.parse(m);h?i.addAnnotation(h,F.REMOTE):console.error(k)}else i.addAnnotation(ln(m),F.REMOTE)},s=()=>o.clear(),a=()=>i.clear(),l=m=>{const h=i.getAnnotation(m);return n&&h?n.serialize(h):h},c=()=>n?i.all().map(n.serialize):i.all(),u=()=>{var m;const h=(((m=o.selected)==null?void 0:m.map(k=>k.id))||[]).map(k=>i.getAnnotation(k)).filter(Boolean);return n?h.map(n.serialize):h},d=(m,h=!0)=>fetch(m).then(k=>k.json()).then(k=>(f(k,h),k)),E=m=>{if(typeof m=="string"){const h=i.getAnnotation(m);if(i.deleteAnnotation(m),h)return n?n.serialize(h):h}else{const h=n?n.parse(m).parsed:m;if(h)return i.deleteAnnotation(h),m}},f=(m,h=!0)=>{if(n){const k=n.parseAll||Zo(n),{parsed:L,failed:x}=k(m);x.length>0&&console.warn(`Discarded ${x.length} invalid annotations`,x),i.bulkAddAnnotations(L,h,F.REMOTE)}else i.bulkAddAnnotations(m.map(ln),h,F.REMOTE)},C=(m,h)=>{m?o.setSelected(m,h):o.clear()},p=m=>{o.setUserSelectAction(m)},S=m=>{if(n){const h=n.parse(m).parsed,k=n.serialize(i.getAnnotation(h.id));return i.updateAnnotation(h),k}else{const h=i.getAnnotation(m.id);return i.updateAnnotation(ln(m)),h}};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:E,setAnnotations:f,setSelected:C,setUserSelectAction:p,undo:t.undo,updateAnnotation:S}},tr="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let nr=e=>crypto.getRandomValues(new Uint8Array(e)),ir=(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}}},or=(e,t=21)=>ir(e,t|0,nr),rr=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=tr[n[e]&63];return t};const sr=()=>({isGuest:!0,id:or("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),ar=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}`},vi=e=>e?typeof e=="object"?{...e}:e:void 0,lr=(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-${ar(n)}`,annotation:t,type:o,purpose:r,value:s,creator:vi(c),created:a?new Date(a):void 0,updated:l?new Date(l):void 0,...u}}),cr=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});rr();const dr=(e,t)=>({parse:n=>Ei(n),serialize:n=>Ai(n,e,t)}),ur=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,fr=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:vi(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,E)=>{switch(E.type){case"TextQuoteSelector":d.quote=E.exact;break;case"TextPositionSelector":d.start=E.start,d.end=E.end;break}return d},{});if(ur(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}},Ei=e=>{const t=e.id||gi(),{creator:n,created:i,modified:o,body:r,...s}=e,a=lr(r,t),l=fr(e);return"error"in l?{error:l.error}:{parsed:{...s,id:t,bodies:a,target:l.parsed}}},Ai=(e,t,n)=>{const{bodies:i,target:o,...r}=e,{selector:s,creator:a,created:l,updated:c,...u}=o,d=s.map(E=>{const{id:f,quote:C,start:p,end:S,range:m}=E,h={type:"TextQuoteSelector",exact:C};if(n){const{prefix:L,suffix:x}=Pn(m,n);h.prefix=L,h.suffix=x}const k={type:"TextPositionSelector",start:p,end:S};return{...u,id:f,scope:"scope"in E?E.scope:void 0,source:t,selector:[h,k]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:cr(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}};function Si(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),E=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),f=Math.max(n,Math.floor(t-c*d/l+E)),C=Math.min(i,Math.floor(t+(l-c)*d/l+E));Si(e,t,f,C,o)}const r=e[t];let s=n,a=i;for(it(e,n,t),o(e[i],r)>0&&it(e,n,i);s<a;){for(it(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?it(e,n,a):(a++,it(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function it(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(!Lt(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;Lt(t,l)&&(n.leaf?i.push(a):dn(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Lt(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(Lt(t,s)){if(n.leaf||dn(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=Pe([]),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&&dn(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=Pe(t.slice(n,i+1)),He(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Pe([]),a.leaf=!1,a.height=o;const l=Math.ceil(r/s),c=l*Math.ceil(Math.sqrt(s));Oi(t,n,i,c,this.compareMinX);for(let u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);Oi(t,u,d,l,this.compareMinY);for(let E=u;E<=d;E+=l){const f=Math.min(E+l-1,d);a.children.push(this._build(t,E,f,o-1))}}return He(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=cn(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),rt(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=Pe(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,He(i,this.toBBox),He(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Pe([t,n]),this.data.height=t.height+1,this.data.leaf=!1,He(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=ot(t,0,a,this.toBBox),c=ot(t,a,i,this.toBBox),u=yr(l,c),d=cn(l)+cn(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=ot(t,0,n,r),a=ot(t,i-n,i,r);let l=kt(s)+kt(a);for(let c=n;c<i-n;c++){const u=t.children[c];rt(s,t.leaf?r(u):u),l+=kt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];rt(a,t.leaf?r(u):u),l+=kt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)rt(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():He(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 He(e,t){ot(e,0,e.children.length,t,e)}function ot(e,t,n,i,o){o||(o=Pe(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];rt(o,e.leaf?i(s):s)}return o}function rt(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 cn(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function kt(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 dn(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Lt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Pe(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Oi(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;Si(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 Er=(e,t,n,i)=>{const o=new gr,r=new Map,s=vr(),a=(x,N)=>{const B=x.selector.flatMap(U=>{const P=he([U])?U.range:Jt(U,t).range;return Un(P)}),M=Xn(B,n,i).map(U=>Kn(U,N));return M.map(U=>{const{x:P,y:X,width:O,height:T}=U;return{minX:P,minY:X,maxX:P+O,maxY:X+T,annotation:{id:x.annotation,rects:M}}})},l=()=>[...r.values()],c=()=>{o.clear(),r.clear()},u=x=>{const N=a(x,t.getBoundingClientRect());N.length!==0&&(N.forEach(B=>o.insert(B)),r.set(x.annotation,N))},d=x=>{const N=r.get(x.annotation);N&&(N.forEach(B=>o.remove(B)),r.delete(x.annotation))},E=x=>{d(x),u(x)},f=(x,N=!0)=>{N&&c();const B=t.getBoundingClientRect(),M=x.map(P=>({target:P,rects:a(P,B)}));M.forEach(({target:P,rects:X})=>{X.length>0&&r.set(P.annotation,X)});const U=M.flatMap(({rects:P})=>P);o.load(U)},C=(x,N,B=!1)=>{const M=o.search({minX:x,minY:N,maxX:x,maxY:N}),U=P=>P.annotation.rects.reduce((X,O)=>X+O.width*O.height,0);return M.length>0?(M.sort((P,X)=>U(P)-U(X)),B?M.map(P=>P.annotation.id):[M[0].annotation.id]):[]},p=x=>{const N=S(x);if(N.length===0)return;let B=N[0].left,M=N[0].top,U=N[0].right,P=N[0].bottom;for(let X=1;X<N.length;X++){const O=N[X];B=Math.min(B,O.left),M=Math.min(M,O.top),U=Math.max(U,O.right),P=Math.max(P,O.bottom)}return new DOMRect(B,M,U-B,P-M)},S=x=>{const N=r.get(x);return N?N[0].annotation.rects:[]};return{all:l,clear:c,getAt:C,getAnnotationBounds:p,getAnnotationRects:S,getIntersecting:(x,N,B,M)=>{const U=o.search({minX:x,minY:N,maxX:B,maxY:M}),P=new Set(U.map(X=>X.annotation.id));return Array.from(P).map(X=>({annotation:e.getAnnotation(X),rects:S(X)})).filter(X=>!!X.annotation)},insert:u,recalculate:()=>{f(e.all().map(x=>x.target),!0),s.emit("recalculate")},remove:d,set:f,size:()=>o.all().length,update:E,on:(x,N)=>s.on(x,N)}},xi=(e,t)=>{var h,k;const n=zo(),i=Er(n,e,(h=t.mergeHighlights)==null?void 0:h.horizontalTolerance,(k=t.mergeHighlights)==null?void 0:k.verticalTolerance),o=Io(n,t.userSelectAction,t.adapter),r=No(n),s=Jo(),a=(L,x=F.LOCAL)=>{const N=Ot(L,e),B=he(N.target.selector);return B&&n.addAnnotation(N,x),B},l=(L,x=!0,N=F.LOCAL)=>{const B=L.map(U=>Ot(U,e)),M=B.filter(U=>!he(U.target.selector));return n.bulkAddAnnotations(B,x,N),M},c=(L,x=F.LOCAL)=>{const N=L.map(M=>Ot(M,e)),B=N.filter(M=>!he(M.target.selector));return N.forEach(M=>{n.getAnnotation(M.id)?n.updateAnnotation(M,x):n.addAnnotation(M,x)}),B},u=(L,x=F.LOCAL)=>{const N=Ze(L,e);n.updateTarget(N,x)},d=(L,x=F.LOCAL)=>{const N=L.map(B=>Ze(B,e));n.bulkUpdateTargets(N,x)};function E(L,x,N,B){const M=N||!!B,U=i.getAt(L,x,M).map(X=>n.getAnnotation(X)),P=B?U.filter(B):U;if(P.length!==0)return N?P:P[0]}const f=L=>i.getAnnotationRects(L).length>0?i.getAnnotationBounds(L):void 0,C=(L,x,N,B)=>i.getIntersecting(L,x,N,B),p=L=>i.getAnnotationRects(L),S=()=>i.recalculate(),m=L=>i.on("recalculate",L);return n.observe(({changes:L})=>{const x=(L.deleted||[]).filter(M=>he(M.target.selector)),N=(L.created||[]).filter(M=>he(M.target.selector)),B=(L.updated||[]).filter(M=>he(M.newValue.target.selector));(x==null?void 0:x.length)>0&&x.forEach(M=>i.remove(M.target)),N.length>0&&i.set(N.map(M=>M.target),!1),(B==null?void 0:B.length)>0&&B.forEach(({newValue:M})=>i.update(M.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:f,getAnnotationRects:p,getIntersecting:C,getAt:E,recalculatePositions:S,onRecalculatePositions:m,updateTarget:u},selection:o,hover:r,viewport:s}},Ar=()=>{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=Ar(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,E])=>E.presenceKey===u.presenceKey).map(([d,E])=>d);return e.on("selectionChange",(u,d)=>{r(u).forEach(f=>o.delete(f)),d&&d.forEach(f=>o.set(f,u))}),{clear:()=>{const{width:u,height:d}=n;i.clearRect(-.5,-.5,u+1,d+1)},destroy:()=>{n.remove()},paint:(u,d,E)=>{t.font&&(i.font=t.font);const f=o.get(u.annotation.id);if(f){const{height:C}=u.rects[0],p=u.rects[0].x+d.left,S=u.rects[0].y+d.top;i.fillStyle=f.appearance.color,i.fillRect(p-2,S-2.5,2,C+5);const m=i.measureText(f.appearance.label),h=m.width+6,k=m.actualBoundingBoxAscent+m.actualBoundingBoxDescent+8,L=m.fontBoundingBoxAscent?8:6.5;return i.fillRect(p-2,S-2.5-k,h,k),i.fillStyle="#fff",i.fillText(f.appearance.label,p+1,S-L),{fill:f.appearance.color,fillOpacity:E?.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)}}},un=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function fn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function st(e,t,n,i){e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on".concat(t),n)}function Ti(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 Ri(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 Sr(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 at={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,"-":un?173:189,"=":un?61:187,";":un?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},ce={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,meta:91,command:91},lt={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},W={};for(let e=1;e<20;e++)at["f".concat(e)]=111+e;let K=[],ct=null,ki="all";const ye=new Map,Ve=e=>at[e.toLowerCase()]||ce[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),Or=e=>Object.keys(at).find(t=>at[t]===e),xr=e=>Object.keys(ce).find(t=>ce[t]===e);function Li(e){ki=e||"all"}function dt(){return ki||"all"}function Cr(){return K.slice(0)}function Tr(){return K.map(e=>Or(e)||xr(e)||String.fromCharCode(e))}function Rr(){const e=[];return Object.keys(W).forEach(t=>{W[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=>Ve(a))})})}),e}function kr(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 Lr(e){return typeof e=="string"&&(e=Ve(e)),K.indexOf(e)!==-1}function Nr(e,t){let n,i;e||(e=dt());for(const o in W)if(Object.prototype.hasOwnProperty.call(W,o))for(n=W[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return hn(a)}):i++;dt()===e&&Li(t||"all")}function Ir(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Ve(e.key));const n=K.indexOf(t);if(n>=0&&K.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&K.splice(0,K.length),(t===93||t===224)&&(t=91),t in Z){Z[t]=!1;for(const i in ce)ce[i]===t&&(se[i]=!1)}}function Ni(e){if(typeof e>"u")Object.keys(W).forEach(o=>{Array.isArray(W[o])&&W[o].forEach(r=>Nt(r)),delete W[o]}),hn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&Nt(o)});else if(typeof e=="object")e.key&&Nt(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=""),Nt({key:e,scope:o,method:r,splitKey:"+"})}}const Nt=e=>{let{key:t,scope:n,method:i,splitKey:o="+"}=e;Ri(t).forEach(s=>{const a=s.split(o),l=a.length,c=a[l-1],u=c==="*"?"*":Ve(c);if(!W[u])return;n||(n=dt());const d=l>1?Ti(ce,a):[],E=[];W[u]=W[u].filter(f=>{const p=(i?f.method===i:!0)&&f.scope===n&&Sr(f.mods,d);return p&&E.push(f.element),!p}),E.forEach(f=>hn(f))})};function Ii(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(K),t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0)))}}function Mi(e,t){const n=W["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!se.filter.call(this,e))return;if((i===93||i===224)&&(i=91),K.indexOf(i)===-1&&i!==229&&K.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=lt[a];e[a]&&K.indexOf(l)===-1?K.push(l):!e[a]&&K.indexOf(l)>-1?K.splice(K.indexOf(l),1):a==="metaKey"&&e[a]&&(K=K.filter(c=>c in lt||c===i))}),i in Z){Z[i]=!0;for(const a in ce)if(Object.prototype.hasOwnProperty.call(ce,a)){const l=lt[ce[a]];se[a]=e[l]}if(!n)return}for(const a in Z)Object.prototype.hasOwnProperty.call(Z,a)&&(Z[a]=e[lt[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(K.indexOf(17)===-1&&K.push(17),K.indexOf(18)===-1&&K.push(18),Z[17]=!0,Z[18]=!0);const o=dt();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)&&Ii(e,n[a],o,t);if(!(i in W))return;const r=W[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 E=0;E<u.length;E++)d.push(Ve(u[E]));d.sort().join("")===K.sort().join("")&&Ii(e,l,o,t)}}function se(e,t,n){K=[];const i=Ri(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,E=!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&&(E=!0)),typeof t=="string"&&(r=t),E&&Ni(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=Ti(ce,e)),e=e[e.length-1],e=e==="*"?"*":Ve(e),e in W||(W[e]=[]),W[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(!ye.has(s)){const f=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Mi(p,s)},C=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Mi(p,s),Ir(p)};ye.set(s,{keydownListener:f,keyupListenr:C,capture:d}),fn(s,"keydown",f,d),fn(s,"keyup",C,d)}if(!ct){const f=()=>{K=[]};ct={listener:f,capture:d},fn(window,"focus",f,d)}}}function Mr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(W).forEach(n=>{W[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function hn(e){const t=Object.values(W).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=ye.get(e)||{};i&&o&&(st(e,"keyup",o,r),st(e,"keydown",i,r),ye.delete(e))}if((t.length<=0||ye.size<=0)&&(Object.keys(ye).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=ye.get(o)||{};r&&s&&(st(o,"keyup",s,a),st(o,"keydown",r,a),ye.delete(o))}),ye.clear(),Object.keys(W).forEach(o=>delete W[o]),ct)){const{listener:o,capture:r}=ct;st(window,"focus",o,r),ct=null}}const gn={getPressedKeyString:Tr,setScope:Li,getScope:dt,deleteScope:Nr,getPressedKeyCodes:Cr,getAllKeyCodes:Rr,isPressed:Lr,filter:kr,trigger:Mr,unbind:Ni,keyMap:at,modifier:ce,modifierMap:lt};for(const e in gn)Object.prototype.hasOwnProperty.call(gn,e)&&(se[e]=gn[e]);if(typeof window<"u"){const e=window.hotkeys;se.noConflict=t=>(t&&window.hotkeys===se&&(window.hotkeys=e),se),window.hotkeys=se}async function Br(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 Bi=300,_i=["up","down","left","right"],Di=qt?"⌘+a":"ctrl+a",_r=[..._i.map(e=>`shift+${e}`),Di],Ui=(e,t,n)=>{const{store:i,selection:o}=t;let r;const{annotatingEnabled:s,offsetReferenceSelector:a,selectionMode:l,dismissOnNotAnnotatable:c="NEVER"}=n,u=w=>r=w;let d;const E=w=>d=w;let f,C,p,S,m=s;const h=w=>{m=w,x.clear(),w||(C=void 0,f=void 0,p=void 0,S=void 0)},k=w=>{const I=w;return qt?I.metaKey:I.ctrlKey},L=()=>{if(!m||p===!1)return;const{selected:w}=o;if(n.allowModifierSelect&&k(S)&&w.length===1&&w[0].editable){const D=i.getAnnotation(w[0].id);if(D!=null&&D.target){C=D.target,f={annotation:D.id,selector:[],created:C.created,creator:C.creator,updated:new Date,updatedBy:r};return}}C=void 0,f={annotation:gi(),selector:[],created:new Date,creator:r}},x=tt(w=>{if(!m)return;const I=document.getSelection();if(!(I!=null&&I.anchorNode))return;const D=Array.from(Array(I.rangeCount).keys()).map(G=>I.getRangeAt(G));if(!D.some(G=>G.intersectsNode(e))){f=void 0;return}const V=w.timeStamp-((S==null?void 0:S.timeStamp)||w.timeStamp);if((S==null?void 0:S.type)==="pointerdown"&&(V<1e3&&!f||I.isCollapsed&&V<Bi)&&L(),f||L(),I.isCollapsed){i.getAnnotation(f.annotation)&&!k(S)&&(o.clear(),i.deleteAnnotation(f.annotation));return}const z=D.map(G=>Wn(G,e));if(z.every(G=>Vn(G)))return;const ae=z.flatMap(G=>Hn(e,G.cloneRange()));if(!(ae.length>0&&!f||ae.length!==f.selector.length||ae.some((G,ut)=>{var pn;return G.toString()!==((pn=f.selector[ut])==null?void 0:pn.quote)})))return;const It=C?Fn([...C.selector.map(G=>G.range),...ae]):ae;f={...f,selector:It.map(G=>Yn(G,e,a)),updated:new Date},i.getAnnotation(f.annotation)?i.updateTarget(f,F.LOCAL):k(w)||o.clear()},10),N=w=>{S=ht(w),p=S.button===0},B=async w=>{if(!p)return;const I=ht(w),D=()=>{const{x:z,y:ae}=e.getBoundingClientRect();if(Xe(e,I.target)){(typeof c=="function"?c(I,e):c==="ALWAYS")&&o.clear();return}const ve=I.target instanceof Node&&e.contains(I.target)&&i.getAt(I.clientX-z,I.clientY-ae,l==="all",d);if(ve){const{selected:It}=o,G=new Set(It.map(ft=>ft.id)),ut=Array.isArray(ve)?ve.map(ft=>ft.id):[ve.id];(G.size!==ut.length||!ut.every(ft=>G.has(ft)))&&o.userSelect(ut,I)}else o.clear()};if(I.timeStamp-S.timeStamp<Bi){await M();const z=document.getSelection(),ae=Xe(e,S.target),ve=Xe(e,I.target);if(z!=null&&z.isCollapsed||ae&&ve){f=void 0,D();return}}f&&f.selector.length>0&&(T(),o.userSelect(f.annotation,I))},M=async()=>{const w=document.getSelection();let I=!1,D=w==null?void 0:w.isCollapsed;const V=()=>D||I,z=1;return setTimeout(()=>I=!0,50),Br(()=>D=w==null?void 0:w.isCollapsed,z,V)},U=w=>{const I=document.getSelection();I!=null&&I.isCollapsed||((!f||f.selector.length===0)&&x(w),f&&(T(),o.userSelect(f.annotation,ht(w))))},P=w=>{m&&w.key==="Shift"&&f&&(document.getSelection().isCollapsed||(T(),o.userSelect(f.annotation,Fe(w))))},X=w=>{const I=()=>setTimeout(()=>{(f==null?void 0:f.selector.length)>0&&(o.clear(),i.addAnnotation({id:f.annotation,bodies:[],target:f}),o.userSelect(f.annotation,Fe(w))),document.removeEventListener("selectionchange",I)},100);document.addEventListener("selectionchange",I),L()};se(_r.join(","),{element:e,keydown:!0,keyup:!1},w=>{w.repeat||(S=Fe(w))}),se(Di,{keydown:!0,keyup:!1},w=>{S=Fe(w),X(w)});const O=w=>{w.repeat||w.target!==e&&w.target!==document.body||(f=void 0,o.clear())};se(_i.join(","),{keydown:!0,keyup:!1},O);const T=()=>{const w=i.getAnnotation(f.annotation);if(!w){i.addAnnotation({id:f.annotation,bodies:[],target:f});return}const{target:{updated:I}}=w,{updated:D}=f;(!I||!D||I<D)&&i.updateTarget(f)};return document.addEventListener("pointerdown",N),document.addEventListener("pointerup",B),document.addEventListener("contextmenu",U),e.addEventListener("keyup",P),e.addEventListener("selectstart",L),document.addEventListener("selectionchange",x),{destroy:()=>{f=void 0,C=void 0,p=void 0,S=void 0,x.clear(),document.removeEventListener("pointerdown",N),document.removeEventListener("pointerup",B),document.removeEventListener("contextmenu",U),e.removeEventListener("keyup",P),e.removeEventListener("selectstart",L),document.removeEventListener("selectionchange",x),se.unbind()},setFilter:E,setUser:u,setAnnotatingEnabled:h}},Hi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Pi="SPANS",Dr=(e,t={})=>{bn(e),Dn(e);const n=Hi(t,{annotatingEnabled:!0,user:sr()}),i=xi(e,n),{selection:o,viewport:r}=i,s=i.store,a=Go(s),l=Qo(i,a,n.adapter);let c=n.user;const u=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Pi:n.renderer||Pi,d=u==="SPANS"?fi(e,i,r):u==="CSS_HIGHLIGHTS"?di(e,i,r):u==="CANVAS"?Jn(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${u}`;console.debug(`Using ${u} renderer`),n.style&&d.setStyle(n.style);const E=Ui(e,i,n);E.setUser(c);const f=er(i,a,n.adapter),C=()=>c,p=x=>{E.setAnnotatingEnabled(x===void 0?!0:x)},S=x=>{d.setFilter(x),E.setFilter(x)},m=x=>{c=x,E.setUser(x)},h=x=>{x&&(d.setPainter(Ci(x,n.presence)),x.on("selectionChange",()=>d.redraw()))},k=x=>{x?o.setSelected(x):o.clear()};return{...f,destroy:()=>{d.destroy(),E.destroy(),a.destroy()},element:e,getUser:C,setAnnotatingEnabled:p,setFilter:S,setStyle:d.setStyle.bind(d),redraw:d.redraw.bind(d),setUser:m,setSelected:k,setPresenceProvider:h,setVisible:d.setVisible.bind(d),on:l.on,off:l.off,scrollIntoView:$n(e,s),state:i}};_.DEFAULT_SELECTED_STYLE=et,_.DEFAULT_STYLE=ge,_.NOT_ANNOTATABLE_CLASS=xe,_.NOT_ANNOTATABLE_SELECTOR=Ce,_.Origin=F,_.UserSelectAction=mi,_.W3CTextFormat=dr,_.cancelSingleClickEvents=bn,_.cloneKeyboardEvent=Fe,_.clonePointerEvent=ht,_.createBody=Po,_.createCanvasRenderer=Jn,_.createHighlightsRenderer=di,_.createPresencePainter=Ci,_.createRenderer=ci,_.createSelectionHandler=Ui,_.createSpansRenderer=fi,_.createTextAnnotator=Dr,_.createTextAnnotatorState=xi,_.fillDefaults=Hi,_.getHighlightClientRects=Un,_.getQuoteContext=Pn,_.getRangeAnnotatableContents=St,_.isMac=qt,_.isNodeWhitespaceOrEmpty=to,_.isNotAnnotatable=Xe,_.isRangeAnnotatable=mn,_.isRangeWhitespaceOrEmpty=Vn,_.isRevived=he,_.mergeClientRects=Xn,_.mergeRanges=Fn,_.paint=qn,_.parseW3CTextAnnotation=Ei,_.programmaticallyFocusable=Dn,_.rangeToSelector=Yn,_.reviveAnnotation=Ot,_.reviveSelector=Jt,_.reviveTarget=Ze,_.scrollIntoView=$n,_.serializeW3CTextAnnotation=Ai,_.splitAnnotatableRanges=Hn,_.toDomRectList=oo,_.toParentBounds=Kn,_.toViewportBounds=ro,_.trimRangeToContainer=Wn,_.whitespaceOrEmptyRegex=Gt,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(D,Ce){typeof exports=="object"&&typeof module<"u"?Ce(exports):typeof define=="function"&&define.amd?define(["exports"],Ce):(D=typeof globalThis<"u"?globalThis:D||self,Ce(D.RecogitoJS={}))})(this,(function(D){"use strict";const Ce="not-annotatable",Te=`.${Ce}`,Fe=(e,t)=>{var i;return e.contains(t)?!!(t instanceof HTMLElement?t.closest(Te):(i=t.parentElement)==null?void 0:i.closest(Te)):!0},wn=(e,t)=>{const n=t.commonAncestorContainer;return!Fe(e,n)},yn=e=>e.addEventListener("click",t=>{!t.target.closest(Te)&&!t.target.closest("a")&&t.preventDefault()}),gt=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}),Ye=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,vn="user-agent",Ne="",En="?",j={FUNCTION:"function",OBJECT:"object",STRING:"string",UNDEFINED:"undefined"},te="browser",me="cpu",ue="device",ce="engine",ie="os",Ie="result",w="name",m="type",y="vendor",E="version",ee="architecture",Ke="major",b="model",We="console",P="mobile",Y="tablet",z="smarttv",fe="wearable",pt="xr",je="embedded",Me="inapp",Bt="brands",Re="formFactors",_t="fullVersionList",Be="platform",Dt="platformVersion",mt="bitness",Ee="sec-ch-ua",Yi=Ee+"-full-version-list",Ki=Ee+"-arch",Wi=Ee+"-"+mt,ji=Ee+"-form-factors",zi=Ee+"-"+P,$i=Ee+"-"+b,An=Ee+"-"+Be,qi=An+"-version",Sn=[Bt,_t,P,b,Be,Dt,ee,Re,mt],bt="Amazon",_e="Apple",On="ASUS",xn="BlackBerry",ke="Google",Cn="Huawei",Ut="Lenovo",Tn="Honor",wt="LG",Ht="Microsoft",Pt="Motorola",Vt="Nvidia",Rn="OnePlus",Xt="OPPO",ze="Samsung",kn="Sharp",$e="Sony",Ft="Xiaomi",Yt="Zebra",Ln="Chrome",Nn="Chromium",Ae="Chromecast",yt="Edge",qe="Firefox",Ge="Opera",Kt="Facebook",In="Sogou",De="Mobile ",Je=" Browser",Wt="Windows",Gi=typeof window!==j.UNDEFINED,ne=Gi&&window.navigator?window.navigator:void 0,Se=ne&&ne.userAgentData?ne.userAgentData:void 0,Ji=function(e,t){var n={},i=t;if(!Et(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},vt=function(e){for(var t={},n=0;n<e.length;n++)t[e[n].toUpperCase()]=e[n];return t},jt=function(e,t){if(typeof e===j.OBJECT&&e.length>0){for(var n in e)if(Oe(t)==Oe(e[n]))return!0;return!1}return Qe(e)?Oe(t)==Oe(e):!1},Et=function(e,t){for(var n in e)return/^(browser|cpu|device|engine|os)$/.test(n)||(t?Et(e[n]):!1)},Qe=function(e){return typeof e===j.STRING},zt=function(e){if(e){for(var t=[],n=Ue(/\\?\"/g,e).split(","),i=0;i<n.length;i++)if(n[i].indexOf(";")>-1){var o=At(n[i]).split(";v=");t[i]={brand:o[0],version:o[1]}}else t[i]=At(n[i]);return t}},Oe=function(e){return Qe(e)?e.toLowerCase():e},$t=function(e){return Qe(e)?Ue(/[^\d\.]/g,e).split(".")[0]:void 0},be=function(e){for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];typeof n==j.OBJECT&&n.length==2?this[n[0]]=n[1]:this[n]=void 0}return this},Ue=function(e,t){return Qe(t)?t.replace(e,Ne):t},Ze=function(e){return Ue(/\\?\"/g,e)},At=function(e,t){return e=Ue(/^\s\s*/,String(e)),typeof t===j.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===j.OBJECT&&s.length>0?s.length===2?typeof s[1]==j.FUNCTION?this[s[0]]=s[1].call(this,l):this[s[0]]=s[1]:s.length>=3&&(typeof s[1]===j.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]===j.OBJECT&&t[n].length>0){for(var i=0;i<t[n].length;i++)if(jt(t[n][i],e))return n===En?void 0:n}else if(jt(t[n],e))return n===En?void 0:n;return t.hasOwnProperty("*")?t["*"]:e},Mn={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:""},Bn={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"},_n={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[E,[w,De+"Chrome"]],[/webview.+edge\/([\w\.]+)/i],[E,[w,yt+" WebView"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[E,[w,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[w,E],[/opios[\/ ]+([\w\.]+)/i],[E,[w,Ge+" Mini"]],[/\bop(?:rg)?x\/([\w\.]+)/i],[E,[w,Ge+" GX"]],[/\bopr\/([\w\.]+)/i],[E,[w,Ge]],[/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i],[E,[w,"Baidu"]],[/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i],[E,[w,"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],[w,E],[/quark(?:pc)?\/([-\w\.]+)/i],[E,[w,"Quark"]],[/\bddg\/([\w\.]+)/i],[E,[w,"DuckDuckGo"]],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[E,[w,"UCBrowser"]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i,/micromessenger\/([\w\.]+)/i],[E,[w,"WeChat"]],[/konqueror\/([\w\.]+)/i],[E,[w,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[E,[w,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[E,[w,"Yandex"]],[/slbrowser\/([\w\.]+)/i],[E,[w,"Smart "+Ut+Je]],[/(avast|avg)\/([\w\.]+)/i],[[w,/(.+)/,"$1 Secure"+Je],E],[/\bfocus\/([\w\.]+)/i],[E,[w,qe+" Focus"]],[/\bopt\/([\w\.]+)/i],[E,[w,Ge+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[E,[w,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[E,[w,"Dolphin"]],[/coast\/([\w\.]+)/i],[E,[w,Ge+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[E,[w,"MIUI"+Je]],[/fxios\/([\w\.-]+)/i],[E,[w,De+qe]],[/\bqihoobrowser\/?([\w\.]*)/i],[E,[w,"360"]],[/\b(qq)\/([\w\.]+)/i],[[w,/(.+)/,"$1Browser"],E],[/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i],[[w,/(.+)/,"$1"+Je],E],[/samsungbrowser\/([\w\.]+)/i],[E,[w,ze+" Internet"]],[/metasr[\/ ]?([\d\.]+)/i],[E,[w,In+" Explorer"]],[/(sogou)mo\w+\/([\d\.]+)/i],[[w,In+" Mobile"],E],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i],[w,E],[/(lbbrowser|rekonq)/i],[w],[/ome\/([\w\.]+) \w* ?(iron) saf/i,/ome\/([\w\.]+).+qihu (360)[es]e/i],[E,w],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[w,Kt],E,[m,Me]],[/(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],[w,E,[m,Me]],[/\bgsa\/([\w\.]+) .*safari\//i],[E,[w,"GSA"],[m,Me]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[E,[w,"TikTok"],[m,Me]],[/\[(linkedin)app\]/i],[w,[m,Me]],[/(zalo(?:app)?)[\/\sa-z]*([\w\.-]+)/i],[[w,/(.+)/,"Zalo"],E,[m,Me]],[/(chromium)[\/ ]([-\w\.]+)/i],[w,E],[/headlesschrome(?:\/([\w\.]+)| )/i],[E,[w,Ln+" Headless"]],[/wv\).+chrome\/([\w\.]+).+edgw\//i],[E,[w,yt+" WebView2"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[w,Ln+" WebView"],E],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[E,[w,"Android"+Je]],[/chrome\/([\w\.]+) mobile/i],[E,[w,De+"Chrome"]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[w,E],[/version\/([\w\.\,]+) .*mobile(?:\/\w+ | ?)safari/i],[E,[w,De+"Safari"]],[/iphone .*mobile(?:\/\w+ | ?)safari/i],[[w,De+"Safari"]],[/version\/([\w\.\,]+) .*(safari)/i],[E,w],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[w,[E,"1"]],[/(webkit|khtml)\/([\w\.]+)/i],[w,E],[/(?:mobile|tablet);.*(firefox)\/([\w\.-]+)/i],[[w,De+qe],E],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[w,"Netscape"],E],[/(wolvic|librewolf)\/([\w\.]+)/i],[w,E],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[E,[w,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],[w,[E,/_/g,"."]],[/(cobalt)\/([\w\.]+)/i],[w,[E,/[^\d\.]+./,Ne]]],cpu:[[/\b((amd|x|x86[-_]?|wow|win)64)\b/i],[[ee,"amd64"]],[/(ia32(?=;))/i,/\b((i[346]|x)86)(pc)?\b/i],[[ee,"ia32"]],[/\b(aarch64|arm(v?[89]e?l?|_?64))\b/i],[[ee,"arm64"]],[/\b(arm(v[67])?ht?n?[fl]p?)\b/i],[[ee,"armhf"]],[/( (ce|mobile); ppc;|\/[\w\.]+arm\b)/i],[[ee,"arm"]],[/ sun4\w[;\)]/i],[[ee,"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],[[ee,/ower/,Ne,Oe]],[/mc680.0/i],[[ee,"68k"]],[/winnt.+\[axp/i],[[ee,"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,[y,ze],[m,Y]],[/\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,[y,ze],[m,P]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)[\/\);]/i],[b,[y,_e],[m,P]],[/\b(?:ios|apple\w+)\/.+[\(\/](ipad)/i,/\b(ipad)[\d,]*[;\] ].+(mac |i(pad)?)os/i],[b,[y,_e],[m,Y]],[/(macintosh);/i],[b,[y,_e]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[b,[y,kn],[m,P]],[/\b((?:brt|eln|hey2?|gdi|jdn)-a?[lnw]09|(?:ag[rm]3?|jdn2|kob2)-a?[lw]0[09]hn)(?: bui|\)|;)/i],[b,[y,Tn],[m,Y]],[/honor([-\w ]+)[;\)]/i],[b,[y,Tn],[m,P]],[/\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,[y,Cn],[m,Y]],[/(?:huawei) ?([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][\dc][adnt]?)\b(?!.+d\/s)/i],[b,[y,Cn],[m,P]],[/oid[^\)]+; (2[\dbc]{4}(182|283|rp\w{2})[cgl]|m2105k81a?c)(?: bui|\))/i,/\b(?:xiao)?((?:red)?mi[-_ ]?pad[\w- ]*)(?: bui|\))/i],[[b,/_/g," "],[y,Ft],[m,Y]],[/\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," "],[y,Ft],[m,P]],[/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,[y,Rn],[m,P]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[b,[y,Xt],[m,P]],[/\b(opd2(\d{3}a?))(?: bui|\))/i],[b,[y,he,{OnePlus:["203","304","403","404","413","415"],"*":Xt}],[m,Y]],[/(vivo (5r?|6|8l?|go|one|s|x[il]?[2-4]?)[\w\+ ]*)(?: bui|\))/i],[b,[y,"BLU"],[m,P]],[/; vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[b,[y,"Vivo"],[m,P]],[/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],[b,[y,"Realme"],[m,P]],[/(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,[y,Ut],[m,Y]],[/lenovo[-_ ]?([-\w ]+?)(?: bui|\)|\/)/i],[b,[y,Ut],[m,P]],[/\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,[y,Pt],[m,P]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[b,[y,Pt],[m,Y]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[b,[y,wt],[m,Y]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+(?!.*(?:browser|netcast|android tv|watch|webos))(\w+)/i,/\blg-?([\d\w]+) bui/i],[b,[y,wt],[m,P]],[/(nokia) (t[12][01])/i],[y,b,[m,Y]],[/(?:maemo|nokia).*(n900|lumia \d+|rm-\d+)/i,/nokia[-_ ]?(([-\w\. ]*?))( bui|\)|;|\/)/i],[[b,/_/g," "],[m,P],[y,"Nokia"]],[/(pixel (c|tablet))\b/i],[b,[y,ke],[m,Y]],[/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,[y,ke],[m,P]],[/(google) (pixelbook( go)?)/i],[y,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,[y,$e],[m,P]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[b,"Xperia Tablet"],[y,$e],[m,Y]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo(?!bc)\w\w)( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[b,[y,bt],[m,Y]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[b,/(.+)/g,"Fire Phone $1"],[y,bt],[m,P]],[/(playbook);[-\w\),; ]+(rim)/i],[b,y,[m,Y]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/(?:blackberry|\(bb10;) (\w+)/i],[b,[y,xn],[m,P]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[b,[y,On],[m,Y]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[b,[y,On],[m,P]],[/(nexus 9)/i],[b,[y,"HTC"],[m,Y]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[y,[b,/_/g," "],[m,P]],[/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,[y,"TCL"],[m,Y]],[/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,[y,"TCL"],[m,P]],[/(itel) ((\w+))/i],[[y,Oe],b,[m,he,{tablet:["p10001l","w7001"],"*":"mobile"}]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[b,[y,"Acer"],[m,Y]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[b,[y,"Meizu"],[m,P]],[/; ((?:power )?armor(?:[\w ]{0,8}))(?: bui|\))/i],[b,[y,"Ulefone"],[m,P]],[/; (energy ?\w+)(?: bui|\))/i,/; energizer ([\w ]+)(?: bui|\))/i],[b,[y,"Energizer"],[m,P]],[/; cat (b35);/i,/; (b15q?|s22 flip|s48c|s62 pro)(?: bui|\))/i],[b,[y,"Cat"],[m,P]],[/((?:new )?andromax[\w- ]+)(?: bui|\))/i],[b,[y,"Smartfren"],[m,P]],[/droid.+; (a(in)?(0(15|59|6[35])|142)p?)/i],[b,[y,"Nothing"],[m,P]],[/; (x67 5g|tikeasy \w+|ac[1789]\d\w+)( b|\))/i,/archos ?(5|gamepad2?|([\w ]*[t1789]|hello) ?\d+[\w ]*)( b|\))/i],[b,[y,"Archos"],[m,Y]],[/archos ([\w ]+)( b|\))/i,/; (ac[3-6]\d\w{2,8})( b|\))/i],[b,[y,"Archos"],[m,P]],[/; (n159v)/i],[b,[y,"HMD"],[m,P]],[/(imo) (tab \w+)/i,/(infinix|tecno) (x1101b?|p904|dp(7c|8d|10a)( pro)?|p70[1-3]a?|p904|t1101)/i],[y,b,[m,Y]],[/(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],[y,b,[m,P]],[/(kobo)\s(ereader|touch)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i],[y,b,[m,Y]],[/(surface duo)/i],[b,[y,Ht],[m,Y]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[b,[y,"Fairphone"],[m,P]],[/((?:tegranote|shield t(?!.+d tv))[\w- ]*?)(?: b|\))/i],[b,[y,Vt],[m,Y]],[/(sprint) (\w+)/i],[y,b,[m,P]],[/(kin\.[onetw]{3})/i],[[b,/\./g," "],[y,Ht],[m,P]],[/droid.+; ([c6]+|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[b,[y,Yt],[m,Y]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[b,[y,Yt],[m,P]],[/(philips)[\w ]+tv/i,/smart-tv.+(samsung)/i],[y,[m,z]],[/hbbtv.+maple;(\d+)/i],[[b,/^/,"SmartTV"],[y,ze],[m,z]],[/(vizio)(?: |.+model\/)(\w+-\w+)/i,/tcast.+(lg)e?. ([-\w]+)/i],[y,b,[m,z]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[y,wt],[m,z]],[/(apple) ?tv/i],[y,[b,_e+" TV"],[m,z]],[/crkey.*devicetype\/chromecast/i],[[b,Ae+" Third Generation"],[y,ke],[m,z]],[/crkey.*devicetype\/([^/]*)/i],[[b,/^/,"Chromecast "],[y,ke],[m,z]],[/fuchsia.*crkey/i],[[b,Ae+" Nest Hub"],[y,ke],[m,z]],[/crkey/i],[[b,Ae],[y,ke],[m,z]],[/(portaltv)/i],[b,[y,Kt],[m,z]],[/droid.+aft(\w+)( bui|\))/i],[b,[y,bt],[m,z]],[/(shield \w+ tv)/i],[b,[y,Vt],[m,z]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[b,[y,kn],[m,z]],[/(bravia[\w ]+)( bui|\))/i],[b,[y,$e],[m,z]],[/(mi(tv|box)-?\w+) bui/i],[b,[y,Ft],[m,z]],[/Hbbtv.*(technisat) (.*);/i],[y,b,[m,z]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[y,/.+\/(\w+)/,"$1",he,{LG:"lge"}],[b,At],[m,z]],[/(playstation \w+)/i],[b,[y,$e],[m,We]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[b,[y,Ht],[m,We]],[/(ouya)/i,/(nintendo) (\w+)/i,/(retroid) (pocket ([^\)]+))/i],[y,b,[m,We]],[/droid.+; (shield)( bui|\))/i],[b,[y,Vt],[m,We]],[/\b(sm-[lr]\d\d[0156][fnuw]?s?|gear live)\b/i],[b,[y,ze],[m,fe]],[/((pebble))app/i,/(asus|google|lg|oppo) ((pixel |zen)?watch[\w ]*)( bui|\))/i],[y,b,[m,fe]],[/(ow(?:19|20)?we?[1-3]{1,3})/i],[b,[y,Xt],[m,fe]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[b,[y,_e],[m,fe]],[/(opwwe\d{3})/i],[b,[y,Rn],[m,fe]],[/(moto 360)/i],[b,[y,Pt],[m,fe]],[/(smartwatch 3)/i],[b,[y,$e],[m,fe]],[/(g watch r)/i],[b,[y,wt],[m,fe]],[/droid.+; (wt63?0{2,3})\)/i],[b,[y,Yt],[m,fe]],[/droid.+; (glass) \d/i],[b,[y,ke],[m,pt]],[/(pico) ([\w ]+) os\d/i],[y,b,[m,pt]],[/(quest( \d| pro)?s?).+vr/i],[b,[y,Kt],[m,pt]],[/mobile vr; rv.+firefox/i],[[m,pt]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[y,[m,je]],[/(aeobc)\b/i],[b,[y,bt],[m,je]],[/(homepod).+mac os/i],[b,[y,_e],[m,je]],[/windows iot/i],[[m,je]],[/droid.+; ([\w- ]+) (4k|android|smart|google)[- ]?tv/i],[b,[m,z]],[/\b((4k|android|smart|opera)[- ]?tv|tv; rv:|large screen[\w ]+safari)\b/i],[[m,z]],[/droid .+?; ([^;]+?)(?: bui|; wv\)|\) applew|; hmsc).+?(mobile|vr|\d) safari/i],[b,[m,he,{mobile:"Mobile",xr:"VR","*":Y}]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[m,Y]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[m,P]],[/droid .+?; ([\w\. -]+)( bui|\))/i],[b,[y,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[E,[w,yt+"HTML"]],[/(arkweb)\/([\w\.]+)/i],[w,E],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[E,[w,"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],[w,E],[/ladybird\//i],[[w,"LibWeb"]],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[E,w]],os:[[/(windows nt) (6\.[23]); arm/i],[[w,/N/,"R"],[E,he,Mn]],[/(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],[w,E],[/windows nt ?([\d\.\)]*)(?!.+xbox)/i,/\bwin(?=3| ?9|n)(?:nt| 9x )?([\d\.;]*)/i],[[E,/(;|\))/g,"",he,Mn],[w,Wt]],[/(windows ce)\/?([\d\.]*)/i],[w,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,"."],[w,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+(haiku|morphos))/i],[[w,"macOS"],[E,/_/g,"."]],[/android ([\d\.]+).*crkey/i],[E,[w,Ae+" Android"]],[/fuchsia.*crkey\/([\d\.]+)/i],[E,[w,Ae+" Fuchsia"]],[/crkey\/([\d\.]+).*devicetype\/smartspeaker/i],[E,[w,Ae+" SmartSpeaker"]],[/linux.*crkey\/([\d\.]+)/i],[E,[w,Ae+" Linux"]],[/crkey\/([\d\.]+)/i],[E,[w,Ae]],[/droid ([\w\.]+)\b.+(android[- ]x86)/i],[E,w],[/(ubuntu) ([\w\.]+) like android/i],[[w,/(.+)/,"$1 Touch"],E],[/(harmonyos)[\/ ]?([\d\.]*)/i,/(android|bada|blackberry|kaios|maemo|meego|openharmony|qnx|rim tablet os|sailfish|series40|symbian|tizen)\w*[-\/\.; ]?([\d\.]*)/i],[w,E],[/\(bb(10);/i],[E,[w,xn]],[/(?:symbian ?os|symbos|s60(?=;)|series ?60)[-\/ ]?([\w\.]*)/i],[E,[w,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[E,[w,qe+" OS"]],[/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i,/webos(?:[ \/]?|\.tv-20(?=2[2-9]))(\d[\d\.]*)/i],[E,[w,"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"}],[w,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[E,[w,"watchOS"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[w,"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],[w,E],[/(sunos) ?([\d\.]*)/i],[[w,"Solaris"],E],[/\b(beos|os\/2|amigaos|openvms|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[w,E]]},St=(function(){var e={init:{},isIgnore:{},isIgnoreRgx:{},toString:{}};return be.call(e.init,[[te,[w,E,Ke,m]],[me,[ee]],[ue,[m,b,y]],[ce,[w,E]],[ie,[w,E]]]),be.call(e.isIgnore,[[te,[E,Ke]],[ce,[E]],[ie,[E]]]),be.call(e.isIgnoreRgx,[[te,/ ?browser$/i],[ie,/ ?os$/i]]),be.call(e.toString,[[te,[w,E]],[me,[ee]],[ue,[y,b]],[ce,[w,E]],[ie,[w,E]]]),e})(),Zi=function(e,t){var n=St.init[t],i=St.isIgnore[t]||0,o=St.isIgnoreRgx[t]||0,r=St.toString[t]||0;function s(){be.call(this,n)}return s.prototype.getItem=function(){return e},s.prototype.withClientHints=function(){return Se?Se.getHighEntropyValues(Sn).then(function(a){return e.setCH(new Dn(a,!1)).parseCH().get()}):e.parseCH().get()},s.prototype.withFeatureCheck=function(){return e.detectFeature().get()},t!=Ie&&(s.prototype.is=function(a){var l=!1;for(var c in this)if(this.hasOwnProperty(c)&&!jt(i,c)&&Oe(o?Ue(o,this[c]):this[c])==Oe(o?Ue(o,a):a)){if(l=!0,a!=j.UNDEFINED)break}else if(a==j.UNDEFINED&&l){l=!l;break}return l},s.prototype.toString=function(){var a=Ne;for(var l in r)typeof this[r[l]]!==j.UNDEFINED&&(a+=(a?" ":Ne)+this[r[l]]);return a||j.UNDEFINED}),Se||(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 Dn(e,t){if(e=e||{},be.call(this,Sn),t)be.call(this,[[Bt,zt(e[Ee])],[_t,zt(e[Yi])],[P,/\?1/.test(e[zi])],[b,Ze(e[$i])],[Be,Ze(e[An])],[Dt,Ze(e[qi])],[ee,Ze(e[Ki])],[Re,zt(e[ji])],[mt,Ze(e[Wi])]]);else for(var n in e)this.hasOwnProperty(n)&&typeof e[n]!==j.UNDEFINED&&(this[n]=e[n])}function Un(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(ne&&ne.userAgent==this.ua)switch(this.itemType){case te:ne.brave&&typeof ne.brave.isBrave==j.FUNCTION&&this.set(w,"Brave");break;case ue:!this.get(m)&&Se&&Se[P]&&this.set(m,P),this.get(b)=="Macintosh"&&ne&&typeof ne.standalone!==j.UNDEFINED&&ne.maxTouchPoints&&ne.maxTouchPoints>2&&this.set(b,"iPad").set(m,Y);break;case ie:!this.get(w)&&Se&&Se[Be]&&this.set(w,Se[Be]);break;case Ie:var o=this.data,r=function(s){return o[s].getItem().detectFeature().get()};this.set(te,r(te)).set(me,r(me)).set(ue,r(ue)).set(ce,r(ce)).set(ie,r(ie))}return this},this.parseUA=function(){switch(this.itemType!=Ie&&qt.call(this.data,this.ua,this.rgxMap),this.itemType){case te:this.set(Ke,$t(this.get(E)));break;case ie:if(this.get(w)=="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 te:case ce:var s=o[_t]||o[Bt],a;if(s)for(var l=0;l<s.length;l++){var c=s[l].brand||s[l],u=s[l].version;this.itemType==te&&!/not.a.brand/i.test(c)&&(!a||/Chrom/.test(a)&&c!=Nn||a==yt&&/WebView2/.test(c))&&(c=he(c,Qi),a=this.get(w),a&&!/Chrom/.test(a)&&/Chrom/.test(c)||this.set(w,c).set(E,u).set(Ke,$t(u)),a=c),this.itemType==ce&&c==Nn&&this.set(E,u)}break;case me:var d=o[ee];d&&(d&&o[mt]=="64"&&(d+="64"),qt.call(this.data,d+";",r));break;case ue:if(o[P]&&this.set(m,P),o[b]&&(this.set(b,o[b]),!this.get(m)||!this.get(y))){var v={};qt.call(v,"droid 9; "+o[b]+")",r),!this.get(m)&&v.type&&this.set(m,v.type),!this.get(y)&&v.vendor&&this.set(y,v.vendor)}if(o[Re]){var O;if(typeof o[Re]!="string")for(var p=0;!O&&p<o[Re].length;)O=he(o[Re][p++],Bn);else O=he(o[Re],Bn);this.set(m,O)}break;case ie:var h=o[Be];if(h){var x=o[Dt];h==Wt&&(x=parseInt($t(x),10)>=13?"11":"10"),this.set(w,h).set(E,x)}this.get(w)==Wt&&o[b]=="Xbox"&&this.set(w,"Xbox").set(E,void 0);break;case Ie:var g=this.data,f=function(k){return g[k].getItem().setCH(o).parseCH().get()};this.set(te,f(te)).set(me,f(me)).set(ue,f(ue)).set(ce,f(ce)).set(ie,f(ie))}return this},be.call(this,[["itemType",e],["ua",t],["uaCH",i],["rgxMap",n],["data",Zi(this,e)]]),this}function we(e,t,n){if(typeof e===j.OBJECT?(Et(e,!0)?(typeof t===j.OBJECT&&(n=t),t=e):(n=e,t=void 0),e=void 0):typeof e===j.STRING&&!Et(t,!0)&&(n=t,t=void 0),n)if(typeof n.append===j.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 we))return new we(e,t,n).getResult();var s=typeof e===j.STRING?e:n&&n[vn]?n[vn]:ne&&ne.userAgent?ne.userAgent:Ne,a=new Dn(n,!0),l=t?Ji(_n,t):_n,c=function(u){return u==Ie?function(){return new Un(u,s,l,a).set("ua",s).set(te,this.getBrowser()).set(me,this.getCPU()).set(ue,this.getDevice()).set(ce,this.getEngine()).set(ie,this.getOS()).get()}:function(){return new Un(u,s,l[u],a).parseUA().get()}};return be.call(this,[["getBrowser",c(te)],["getCPU",c(me)],["getDevice",c(ue)],["getEngine",c(ce)],["getOS",c(ie)],["getResult",c(Ie)],["getUA",function(){return s}],["setUA",function(u){return Qe(u)&&(s=At(u,Fi)),this}]]).setUA(s),this}we.VERSION=Xi,we.BROWSER=vt([w,E,Ke,m]),we.CPU=vt([ee]),we.DEVICE=vt([b,y,m,We,P,z,Y,fe,je]),we.ENGINE=we.OS=vt([w,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"}),Gt=we().os.is(eo.MACOS),Hn=e=>{!e.hasAttribute("tabindex")&&e.tabIndex<0&&e.setAttribute("tabindex","-1"),e.classList.add("no-focus-outline")},Pn=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())]}},to=function*(e){const t=document.createNodeIterator(e.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,i=>i instanceof HTMLElement&&i.classList.contains(Ce)&&!i.parentElement.closest(Te)&&e.intersectsNode(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP);let n;for(;n=t.nextNode();)n instanceof HTMLElement&&(yield n)},Vn=(e,t)=>{if(!wn(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]},Ot=e=>{const t=e.cloneContents();return t.querySelectorAll(Te).forEach(n=>n.remove()),t},Xn=(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=Ot(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=Ot(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),Jt=/^\s*$/,Fn=e=>Jt.test(e.toString()),no=e=>Jt.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)},Yn=(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)}}),Kn=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]},Wn=(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=Ot(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}},jn=(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)},Qt=(e,t)=>{var u,d;const{start:n,end:i}=e,o=e.offsetReference||t,r=document.createNodeIterator(t,NodeFilter.SHOW_TEXT,v=>{var O;return(O=v.parentElement)!=null&&O.closest(Te)?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 v=((u=l.textContent)==null?void 0:u.length)||0;if(s+v>n){a.setStart(l,n-s);break}s+=v}l=r.nextNode()}for(;l!==null;){const v=((d=l.textContent)==null?void 0:d.length)||0;if(s+v>=i){a.setEnd(l,i-s);break}s+=v,l=r.nextNode()}return{...e,range:a}},et=(e,t)=>ge(e.selector)?e:{...e,selector:e.selector.map(n=>n.range instanceof Range&&!n.range.collapsed?n:Qt(n,t))},xt=(e,t)=>ge(e.target.selector)?e:{...e,target:et(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},$n=e=>{if(!e)return document.scrollingElement;const{overflowY:t}=window.getComputedStyle(e);return t!=="visible"&&t!=="hidden"&&e.scrollHeight>e.clientHeight?e:$n(e.parentElement)},qn=(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,v=n.parentElement?n.scrollLeft:0,O=c+d-(o-l)/2,p=u+v-(r-a)/2;n.scroll({top:O,left:p,behavior:"smooth"})},Gn=(e,t)=>(n,i)=>{const o=typeof n=="string"?n:n.id,r=i?typeof i=="string"?document.getElementById(i):i:$n(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 qn(t,s.target,r),!0;const l=et(s.target,e),{range:c}=l.selector[0];return c&&!c.collapsed?(qn(t,l,r),!0):!1},pe={fill:"rgb(0, 128, 255)",fillOpacity:.18},tt={fill:"rgb(0, 128, 255)",fillOpacity:.45},Jn=(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?tt:pe):n:(a=e.state)!=null&&a.selected?tt:pe;return i&&i.paint(e,t)||r};function ao(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ct={exports:{}},Qn;function lo(){if(Qn)return Ct.exports;Qn=1;function e(t,n=100,i={}){if(typeof t!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);if(n<0)throw new RangeError("`wait` must not be negative.");const{immediate:o}=typeof i=="boolean"?{immediate:i}:i;let r,s,a,l,c;function u(){const O=r,p=s;return r=void 0,s=void 0,c=t.apply(O,p),c}function d(){const O=Date.now()-l;O<n&&O>=0?a=setTimeout(d,n-O):(a=void 0,o||(c=u()))}const v=function(...O){if(r&&this!==r&&Object.getPrototypeOf(this)===Object.getPrototypeOf(r))throw new Error("Debounced method called with different contexts of the same prototype.");r=this,s=O,l=Date.now();const p=o&&!a;return a||(a=setTimeout(d,n)),p&&(c=u()),c};return Object.defineProperty(v,"isPending",{get(){return a!==void 0}}),v.clear=()=>{a&&(clearTimeout(a),a=void 0)},v.flush=()=>{a&&v.trigger()},v.trigger=()=>{c=u(),v.clear()},v}return Ct.exports.debounce=e,Ct.exports=e,Ct.exports}var co=lo();const nt=ao(co);var Zn=Object.prototype.hasOwnProperty;function Le(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--&&Le(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)||!Le(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}function Zt(){}function uo(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}const He=[];function en(e,t=Zt){let n;const i=new Set;function o(a){if(uo(e,a)&&(e=a,n)){const l=!He.length;for(const c of i)c[1](),He.push(c,e);if(l){for(let c=0;c<He.length;c+=2)He[c][0](He[c+1]);He.length=0}}}function r(a){o(a(e))}function s(a,l=Zt){const c=[a,l];return i.add(c),i.size===1&&(n=t(o,r)||Zt),a(e),()=>{i.delete(c),i.size===0&&n&&(n(),n=null)}}return{set:o,update:r,subscribe:s}}const fo=e=>{const{subscribe:t,set:n}=en();let i;return t(o=>i=o),e.observe(({changes:o})=>{if(i){(o.deleted||[]).some(s=>s.id===i)&&n(void 0);const r=(o.updated||[]).find(({oldValue:s})=>s.id===i);r&&n(r.newValue.id)}}),{get current(){return i},subscribe:t,set:n}};var tn=(e=>(e.EDIT="EDIT",e.SELECT="SELECT",e.NONE="NONE",e))(tn||{});const Tt={selected:[]},ho=(e,t,n)=>{const{subscribe:i,set:o}=en(Tt);let r=t,s=Tt;i(h=>s=h);const a=()=>{Le(s,Tt)||o(Tt)},l=()=>{var h;return((h=s.selected)==null?void 0:h.length)===0},c=h=>{if(l())return!1;const x=typeof h=="string"?h:h.id;return s.selected.some(g=>g.id===x)},u=(h,x)=>{let g;if(Array.isArray(h)){if(g=h.map(k=>e.getAnnotation(k)).filter(Boolean),g.length<h.length){console.warn("Invalid selection: "+h.filter(k=>!g.some(I=>I.id===k)));return}}else{const k=e.getAnnotation(h);if(!k){console.warn("Invalid selection: "+h);return}g=[k]}const f=g.reduce((k,I)=>{const S=p(I);return S==="EDIT"?[...k,{id:I.id,editable:!0}]:S==="SELECT"?[...k,{id:I.id}]:k},[]);o({selected:f,event:x})},d=(h,x)=>{const g=Array.isArray(h)?h:[h],f=g.map(k=>e.getAnnotation(k)).filter(k=>!!k);o({selected:f.map(k=>{const I=x===void 0?p(k)==="EDIT":x;return{id:k.id,editable:I}})}),f.length!==g.length&&console.warn("Invalid selection",h)},v=h=>{if(l())return!1;const{selected:x}=s;x.some(({id:g})=>h.includes(g))&&o({selected:x.filter(({id:g})=>!h.includes(g))})},O=h=>{r=h,d(s.selected.map(({id:x})=>x))},p=h=>go(h,r,n);return e.observe(({changes:h})=>v((h.deleted||[]).map(x=>x.id))),{get event(){return s?s.event:null},get selected(){return s?[...s.selected]:null},get userSelectAction(){return r},clear:a,evalSelectAction:p,isEmpty:l,isSelected:c,setSelected:d,setUserSelectAction:O,subscribe:i,userSelect:u}},go=(e,t,n)=>{const i=n?n.serialize(e):e;return typeof t=="function"?t(i):t||"EDIT"},G=[];for(let e=0;e<256;++e)G.push((e+256).toString(16).slice(1));function po(e,t=0){return(G[e[t+0]]+G[e[t+1]]+G[e[t+2]]+G[e[t+3]]+"-"+G[e[t+4]]+G[e[t+5]]+"-"+G[e[t+6]]+G[e[t+7]]+"-"+G[e[t+8]]+G[e[t+9]]+"-"+G[e[t+10]]+G[e[t+11]]+G[e[t+12]]+G[e[t+13]]+G[e[t+14]]+G[e[t+15]]).toLowerCase()}let nn;const mo=new Uint8Array(16);function bo(){if(!nn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");nn=crypto.getRandomValues.bind(crypto)}return nn(mo)}const wo=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),ei={randomUUID:wo};function yo(e,t,n){var i;e=e||{};const o=e.random??((i=e.rng)==null?void 0:i.call(e))??bo();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,po(o)}function ti(e,t,n){return ei.randomUUID&&!e?ei.randomUUID():yo(e)}const on=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)}},vo=(e,t,n,i)=>({id:ti(),annotation:typeof e=="string"?e:e.id,created:n||new Date,creator:i,...t}),Eo=(e,t)=>{const n=new Set(e.bodies.map(i=>i.id));return t.bodies.filter(i=>!n.has(i.id))},Ao=(e,t)=>{const n=new Set(t.bodies.map(i=>i.id));return e.bodies.filter(i=>!n.has(i.id))},So=(e,t)=>t.bodies.map(n=>{const i=e.bodies.find(o=>o.id===n.id);return{newBody:n,oldBody:i&&!Le(i,n)?i:void 0}}).filter(({oldBody:n})=>n).map(({oldBody:n,newBody:i})=>({oldBody:n,newBody:i})),Oo=(e,t)=>!Le(e.target,t.target),ni=(e,t)=>{const n=Eo(e,t),i=Ao(e,t),o=So(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:Oo(e,t)?{oldTarget:e.target,newTarget:t.target}:void 0}};var F=(e=>(e.LOCAL="LOCAL",e.REMOTE="REMOTE",e.SILENT="SILENT",e))(F||{});const xo=(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:v})=>v.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:v,newValue:O}=d;if(s.has(O.id)){const p=t.updated.find(h=>h.oldValue.id===O.id).newValue;return ni(v,p)}else return d}),...(t.updated||[]).filter(({oldValue:d})=>!a.has(d.id))];return{created:l,deleted:c,updated:u}},Rt=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}}},To=e=>e.id!==void 0,Ro=()=>{const e=new Map,t=new Map,n=[],i=(A,T={})=>{n.push({onChange:A,options:T})},o=A=>{const T=n.findIndex(C=>C.onChange==A);T>-1&&n.splice(T,1)},r=(A,T)=>{const C={origin:A,changes:{created:T.created||[],updated:T.updated||[],deleted:T.deleted||[]},state:[...e.values()]};n.forEach(M=>{xo(M,C)&&M.onChange(C)})},s=(A,T=F.LOCAL)=>{if(A.id&&e.get(A.id))throw Error(`Cannot add annotation ${A.id} - exists already`);{const C=Rt(A);e.set(C.id,C),C.bodies.forEach(M=>t.set(M.id,C.id)),r(T,{created:[C]})}},a=(A,T)=>{const C=Rt(typeof A=="string"?T:A),M=typeof A=="string"?A:A.id,R=M&&e.get(M);if(R){const L=ni(R,C);return M===C.id?e.set(M,C):(e.delete(M),e.set(C.id,C)),R.bodies.forEach(U=>t.delete(U.id)),C.bodies.forEach(U=>t.set(U.id,C.id)),L}else console.warn(`Cannot update annotation ${M} - does not exist`)},l=(A,T=F.LOCAL,C=F.LOCAL)=>{const M=To(T)?C:T,R=a(A,T);R&&r(M,{updated:[R]})},c=(A,T=F.LOCAL)=>{e.get(A.id)?l(A,T):s(A,T)},u=(A,T=F.LOCAL)=>{const C=A.reduce((M,R)=>{const L=a(R);return L?[...M,L]:M},[]);C.length>0&&r(T,{updated:C})},d=(A,T=F.LOCAL)=>{const C=A.map(Rt),{toAdd:M,toUpdate:R}=C.reduce((U,Z)=>e.get(Z.id)?{...U,toUpdate:[...U.toUpdate,Z]}:{...U,toAdd:[...U.toAdd,Z]},{toAdd:[],toUpdate:[]}),L=R.map(U=>a(U,T)).filter(Boolean);M.forEach(U=>{e.set(U.id,U),U.bodies.forEach(Z=>t.set(Z.id,U.id))}),r(T,{created:M,updated:L})},v=(A,T=F.LOCAL)=>{const C=e.get(A.annotation);if(C){const M={...C,bodies:[...C.bodies,A]};e.set(C.id,M),t.set(A.id,M.id),r(T,{updated:[{oldValue:C,newValue:M,bodiesCreated:[A]}]})}else console.warn(`Attempt to add body to missing annotation: ${A.annotation}`)},O=()=>[...e.values()],p=(A=F.LOCAL)=>{const T=[...e.values()];e.clear(),t.clear(),r(A,{deleted:T})},h=(A,T=!0,C=F.LOCAL)=>{const M=A.map(Rt);if(T){const R=[...e.values()];e.clear(),t.clear(),M.forEach(L=>{e.set(L.id,L),L.bodies.forEach(U=>t.set(U.id,L.id))}),r(C,{created:M,deleted:R})}else{const R=A.reduce((L,U)=>{const Z=U.id&&e.get(U.id);return Z?[...L,Z]:L},[]);if(R.length>0)throw Error(`Bulk insert would overwrite the following annotations: ${R.map(L=>L.id).join(", ")}`);M.forEach(L=>{e.set(L.id,L),L.bodies.forEach(U=>t.set(U.id,L.id))}),r(C,{created:M})}},x=A=>{const T=typeof A=="string"?A:A.id,C=e.get(T);if(C)return e.delete(T),C.bodies.forEach(M=>t.delete(M.id)),C;console.warn(`Attempt to delete missing annotation: ${T}`)},g=(A,T=F.LOCAL)=>{const C=x(A);C&&r(T,{deleted:[C]})},f=(A,T=F.LOCAL)=>{const C=A.reduce((M,R)=>{const L=x(R);return L?[...M,L]:M},[]);C.length>0&&r(T,{deleted:C})},k=A=>{const T=e.get(A.annotation);if(T){const C=T.bodies.find(M=>M.id===A.id);if(C){t.delete(C.id);const M={...T,bodies:T.bodies.filter(R=>R.id!==A.id)};return e.set(T.id,M),{oldValue:T,newValue:M,bodiesDeleted:[C]}}else console.warn(`Attempt to delete missing body ${A.id} from annotation ${A.annotation}`)}else console.warn(`Attempt to delete body from missing annotation ${A.annotation}`)},I=(A,T=F.LOCAL)=>{const C=k(A);C&&r(T,{updated:[C]})},S=(A,T=F.LOCAL)=>{const C=A.map(M=>k(M)).filter(Boolean);C.length>0&&r(T,{updated:C})},N=A=>{const T=e.get(A);return T?{...T}:void 0},_=A=>{const T=t.get(A);if(T){const C=N(T).bodies.find(M=>M.id===A);if(C)return C;console.error(`Store integrity error: body ${A} in index, but not in annotation`)}else console.warn(`Attempt to retrieve missing body: ${A}`)},B=(A,T)=>{if(A.annotation!==T.annotation)throw"Annotation integrity violation: annotation ID must be the same when updating bodies";const C=e.get(A.annotation);if(C){const M=C.bodies.find(L=>L.id===A.id),R={...C,bodies:C.bodies.map(L=>L.id===M.id?T:L)};return e.set(C.id,R),M.id!==T.id&&(t.delete(M.id),t.set(T.id,R.id)),{oldValue:C,newValue:R,bodiesUpdated:[{oldBody:M,newBody:T}]}}else console.warn(`Attempt to add body to missing annotation ${A.annotation}`)},H=(A,T,C=F.LOCAL)=>{const M=B(A,T);M&&r(C,{updated:[M]})},V=(A,T=F.LOCAL)=>{const C=A.map(M=>B({id:M.id,annotation:M.annotation},M)).filter(Boolean);r(T,{updated:C})},X=A=>{const T=e.get(A.annotation);if(T){const C={...T,target:{...T.target,...A}};return e.set(T.id,C),{oldValue:T,newValue:C,targetUpdated:{oldTarget:T.target,newTarget:A}}}else console.warn(`Attempt to update target on missing annotation: ${A.annotation}`)};return{addAnnotation:s,addBody:v,all:O,bulkAddAnnotations:h,bulkDeleteAnnotations:f,bulkDeleteBodies:S,bulkUpdateAnnotations:u,bulkUpdateBodies:V,bulkUpdateTargets:(A,T=F.LOCAL)=>{const C=A.map(M=>X(M)).filter(Boolean);C.length>0&&r(T,{updated:C})},bulkUpsertAnnotations:d,clear:p,deleteAnnotation:g,deleteBody:I,getAnnotation:N,getBody:_,observe:i,unobserve:o,updateAnnotation:l,updateBody:H,updateTarget:(A,T=F.LOCAL)=>{const C=X(A);C&&r(T,{updated:[C]})},upsertAnnotation:c}};let ko=()=>({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 Lo=250,No=(e,t)=>{const n=ko(),i=[];let o=-1,r=!1,s=0;const a=p=>{if(!r){const{changes:h}=p,x=performance.now();if(x-s>Lo)i.splice(o+1),i.push(h),o=i.length-1;else{const g=i.length-1;i[g]=Co(i[g],h)}s=x}r=!1};e.observe(a,{origin:F.LOCAL});const l=p=>p&&p.length>0&&e.bulkDeleteAnnotations(p),c=p=>p&&p.length>0&&e.bulkAddAnnotations(p,!1),u=p=>p&&p.length>0&&e.bulkUpdateAnnotations(p.map(({oldValue:h})=>h)),d=p=>p&&p.length>0&&e.bulkUpdateAnnotations(p.map(({newValue:h})=>h)),v=p=>p&&p.length>0&&e.bulkAddAnnotations(p,!1),O=p=>p&&p.length>0&&e.bulkDeleteAnnotations(p);return{canRedo:()=>i.length-1>o,canUndo:()=>o>-1,destroy:()=>e.unobserve(a),getHistory:()=>({changes:[...i],pointer:o}),on:(p,h)=>n.on(p,h),redo:()=>{if(i.length-1>o){r=!0;const{created:p,updated:h,deleted:x}=i[o+1];c(p),d(h),O(x),n.emit("redo",i[o+1]),o+=1}},undo:()=>{if(o>-1){r=!0;const{created:p,updated:h,deleted:x}=i[o];l(p),u(h),v(x),n.emit("undo",i[o]),o-=1}}}},Io=()=>{const{subscribe:e,set:t}=en([]);return{subscribe:e,set:t}},Mo=(e,t,n,i)=>{const{hover:o,selection:r,store:s,viewport:a}=e,l=new Map;let c=[],u;const d=(h,x)=>{l.has(h)?l.get(h).push(x):l.set(h,[x])},v=(h,x)=>{const g=l.get(h);if(g){const f=g.indexOf(x);f!==-1&&g.splice(f,1)}},O=(h,x,g)=>{l.has(h)&&setTimeout(()=>{l.get(h).forEach(f=>{if(n){const k=Array.isArray(x)?x.map(S=>n.serialize(S)):n.serialize(x),I=g?g instanceof PointerEvent?g:n.serialize(g):void 0;f(k,I)}else f(x,g)})},1)};r.subscribe(({selected:h})=>{if(!(c.length===0&&h.length===0)){if(c.length===0&&h.length>0)c=h.map(({id:x})=>s.getAnnotation(x));else if(c.length>0&&h.length===0)c.forEach(x=>{const g=s.getAnnotation(x.id);g&&!Le(g,x)&&O("updateAnnotation",g,x)}),c=[];else{const x=new Set(c.map(f=>f.id)),g=new Set(h.map(({id:f})=>f));c.filter(f=>!g.has(f.id)).forEach(f=>{const k=s.getAnnotation(f.id);k&&!Le(k,f)&&O("updateAnnotation",k,f)}),c=[...c.filter(f=>g.has(f.id)),...h.filter(({id:f})=>!x.has(f)).map(({id:f})=>s.getAnnotation(f))]}O("selectionChanged",c)}}),o.subscribe(h=>{!u&&h?O("mouseEnterAnnotation",s.getAnnotation(h)):u&&!h?O("mouseLeaveAnnotation",s.getAnnotation(u)):u&&h&&(O("mouseLeaveAnnotation",s.getAnnotation(u)),O("mouseEnterAnnotation",s.getAnnotation(h))),u=h}),a==null||a.subscribe(h=>O("viewportIntersect",h.map(x=>s.getAnnotation(x)))),s.observe(h=>{const{created:x,deleted:g}=h.changes;(x||[]).forEach(f=>O("createAnnotation",f)),(g||[]).forEach(f=>O("deleteAnnotation",f)),(h.changes.updated||[]).filter(f=>[...f.bodiesCreated||[],...f.bodiesDeleted||[],...f.bodiesUpdated||[]].length>0).forEach(({oldValue:f,newValue:k})=>{const I=c.find(S=>S.id===f.id)||f;c=c.map(S=>S.id===f.id?k:S),O("updateAnnotation",k,I)})},{origin:F.LOCAL}),s.observe(h=>{if(c){const x=new Set(c.map(f=>f.id)),g=(h.changes.updated||[]).filter(({newValue:f})=>x.has(f.id)).map(({newValue:f})=>f);g.length>0&&(c=c.map(f=>g.find(I=>I.id===f.id)||f))}},{origin:F.REMOTE});const p=h=>x=>{const{updated:g}=x;h?(g||[]).forEach(f=>O("updateAnnotation",f.oldValue,f.newValue)):(g||[]).forEach(f=>O("updateAnnotation",f.newValue,f.oldValue))};return t.on("undo",p(!0)),t.on("redo",p(!1)),{on:d,off:v,emit:O}},Bo=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:[]}),_o=(e,t,n)=>{const{store:i,selection:o}=e,r=g=>{if(n){const{parsed:f,error:k}=n.parse(g);f?i.addAnnotation(f,F.REMOTE):console.error(k)}else i.addAnnotation(on(g),F.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(k=>k.id))||[]).map(k=>i.getAnnotation(k)).filter(Boolean);return n?f.map(n.serialize):f},d=(g,f=!0)=>fetch(g).then(k=>k.json()).then(k=>(O(k,f),k)),v=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}},O=(g,f=!0)=>{if(n){const k=n.parseAll||Bo(n),{parsed:I,failed:S}=k(g);S.length>0&&console.warn(`Discarded ${S.length} invalid annotations`,S),i.bulkAddAnnotations(I,f,F.REMOTE)}else i.bulkAddAnnotations(g.map(on),f,F.REMOTE)},p=(g,f)=>{g?o.setSelected(g,f):o.clear()},h=g=>{o.setUserSelectAction(g)},x=g=>{if(n){const f=n.parse(g).parsed,k=n.serialize(i.getAnnotation(f.id));return i.updateAnnotation(f),k}else{const f=i.getAnnotation(g.id);return i.updateAnnotation(on(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:v,setAnnotations:O,setSelected:p,setUserSelectAction:h,undo:t.undo,updateAnnotation:x}},Do="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Uo=e=>crypto.getRandomValues(new Uint8Array(e)),Ho=(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}}},Po=(e,t=21)=>Ho(e,t|0,Uo),Vo=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=Do[n[e]&63];return t};const Xo=()=>({isGuest:!0,id:Po("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",20)()}),Fo=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,Yo=(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-${Fo(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}}),Ko=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});Vo();const Wo=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}},jo=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)}},rn=(e,t,n,i)=>{const{store:o,selection:r,hover:s}=t;let a,l,c;const u=jo(n),d=H=>{const{x:V,y:X}=e.getBoundingClientRect(),A=o.getAt(H.clientX-V,H.clientY-X,!1,l);A&&t.selection.evalSelectAction(A)!==tn.NONE?s.current!==A.id&&(e.classList.add("hovered"),s.set(A.id)):s.current&&(e.classList.remove("hovered"),s.set(null))};e.addEventListener("pointermove",d);const v=nt((H=!1)=>requestAnimationFrame(()=>{c&&c.clear();const V=Wo(e),{minX:X,minY:A,maxX:T,maxY:C}=V,M=l?o.getIntersecting(X,A,T,C).filter(({annotation:U})=>l(U)):o.getIntersecting(X,A,T,C),R=r.selected.map(({id:U})=>U),L=M.map(({annotation:U,rects:Z})=>{const ae=R.includes(U.id),le=U.id===s.current;return{annotation:U,rects:Z,state:{selected:ae,hovered:le}}});i.redraw(L,V,a,c,H),setTimeout(()=>u(M.map(({annotation:U})=>U)),1)}),10),O=H=>{c=H,v()},p=H=>{a=H,v()},h=H=>{l=H,v(!1)},x=()=>v();o.observe(x);const g=r.subscribe(()=>v()),f=s.subscribe(()=>v()),k=()=>v(!0);document.addEventListener("scroll",k,{capture:!0,passive:!0});const I=nt(()=>{o.recalculatePositions(),c==null||c.reset(),v()},10);window.addEventListener("resize",I);const S=new ResizeObserver(I);S.observe(e);const N={attributes:!0,childList:!0,subtree:!0},_=new MutationObserver(nt(H=>{H.every(X=>X.target===e||e.contains(X.target))||v(!0)},150));return _.observe(document.body,N),{destroy:()=>{e.removeEventListener("pointermove",d),i.destroy(),o.unobserve(x),g(),f(),document.removeEventListener("scroll",k),I.clear(),window.removeEventListener("resize",I),S.disconnect(),_.disconnect()},redraw:v,setStyle:p,setFilter:h,setPainter:O,setVisible:i.setVisible}},zo=()=>{const e=document.createElement("canvas");return e.width=window.innerWidth,e.height=window.innerHeight,e.className="r6o-canvas-highlight-layer bg",e},$o=(e,t)=>{e.width=window.innerWidth,e.height=window.innerHeight},qo=e=>{e.classList.add("r6o-annotatable");const t=zo(),n=t.getContext("2d");document.body.appendChild(t);const i=(a,l,c,u)=>requestAnimationFrame(()=>{const{width:d,height:v}=t;n.clearRect(-.5,-.5,d+1,v+1),u&&u.clear();const{top:O,left:p}=l;[...a].sort((x,g)=>{const{annotation:{target:{created:f}}}=x,{annotation:{target:{created:k}}}=g;return f.getTime()-k.getTime()}).forEach(x=>{var I;const g=c?typeof c=="function"?c(x.annotation,x.state):c:(I=x.state)!=null&&I.selected?tt:pe,f=u&&u.paint(x,l)||g,k=x.rects.map(({x:S,y:N,width:_,height:B})=>({x:S+p,y:N+O,width:_,height:B}));if(n.fillStyle=f.fill,n.globalAlpha=f.fillOpacity||1,k.forEach(({x:S,y:N,width:_,height:B})=>n.fillRect(S,N,_,B)),f.underlineColor){n.globalAlpha=1,n.strokeStyle=f.underlineColor,n.lineWidth=f.underlineThickness??1;const S=f.underlineOffset??0;k.forEach(({x:N,y:_,width:B,height:H})=>{n.beginPath(),n.moveTo(N,_+H+S),n.lineTo(N+B,_+H+S),n.stroke()})}})}),o=nt(()=>$o(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)=>rn(e,t,n,qo(e));var Go={grad:.9,turn:360,rad:360/(2*Math.PI)},ye=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},$=function(e,t,n){return t===void 0&&(t=0),n===void 0&&(n=Math.pow(10,t)),Math.round(n*e)/n+0},oe=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:oe(e.r,0,255),g:oe(e.g,0,255),b:oe(e.b,0,255),a:oe(e.a)}},sn=function(e){return{r:$(e.r),g:$(e.g),b:$(e.b),a:$(e.a,3)}},Jo=/^#([0-9a-f]{3,8})$/i,kt=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:oe(e.s,0,100),l:oe(e.l,0,100),a:oe(e.a)}},di=function(e){return{h:$(e.h),s:$(e.s),l:$(e.l),a:$(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},it=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},Qo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zo=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,er=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tr=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,fi={string:[[function(e){var t=Jo.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?$(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?$(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=er.exec(e)||tr.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=Qo.exec(e)||Zo.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)*(Go[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 ye(t)&&ye(n)&&ye(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(!ye(t)||!ye(n)||!ye(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(!ye(t)||!ye(n)||!ye(i))return null;var s=(function(a){return{h:ri(a.h),s:oe(a.s,0,100),v:oe(a.v,0,100),a:oe(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]},nr=function(e){return typeof e=="string"?hi(e.trim(),fi.string):typeof e=="object"&&e!==null?hi(e,fi.object):[null,void 0]},an=function(e,t){var n=it(e);return{h:n.h,s:oe(n.s+100*t,0,100),l:n.l,a:n.a}},ln=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},gi=function(e,t){var n=it(e);return{h:n.h,s:n.s,l:oe(n.l+100*t,0,100),a:n.a}},pi=(function(){function e(t){this.parsed=nr(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 $(ln(this.rgba),2)},e.prototype.isDark=function(){return ln(this.rgba)<.5},e.prototype.isLight=function(){return ln(this.rgba)>=.5},e.prototype.toHex=function(){return t=sn(this.rgba),n=t.r,i=t.g,o=t.b,s=(r=t.a)<1?kt($(255*r)):"","#"+kt(n)+kt(i)+kt(o)+s;var t,n,i,o,r,s},e.prototype.toRgb=function(){return sn(this.rgba)},e.prototype.toRgbString=function(){return t=sn(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(it(this.rgba))},e.prototype.toHslString=function(){return t=di(it(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:$(t.h),s:$(t.s),v:$(t.v),a:$(t.a,3)};var t},e.prototype.invert=function(){return re({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),re(an(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),re(an(this.rgba,-t))},e.prototype.grayscale=function(){return re(an(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),re(gi(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),re(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"?re({r:(n=this.rgba).r,g:n.g,b:n.b,a:t}):$(this.rgba.a,3);var n},e.prototype.hue=function(t){var n=it(this.rgba);return typeof t=="number"?re({h:t,s:n.s,l:n.l,a:n.a}):$(n.h)},e.prototype.isEqual=function(t){return this.toHex()===re(t).toHex()},e})(),re=function(e){return e instanceof pi?e:new pi(e)};const ir=e=>[`background-color:${re((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 p;const v=a?typeof a=="function"?a(d.annotation,d.state):a:(p=d.state)!=null&&p.selected?tt:pe,O=l&&l.paint(d,s)||v;return`::highlight(_${d.annotation.id}) { ${ir(O)} }`});e.innerHTML=u.join(`
|
|
2
|
+
`),CSS.highlights.clear(),r.forEach(({annotation:d})=>{const v=d.target.selector.map(p=>p.range),O=new Highlight(...v);CSS.highlights.set(`_${d.id}`,O)}),t=c}}},bi=(e,t,n)=>rn(e,t,n,mi());var wi=Object.prototype.hasOwnProperty;function cn(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--&&cn(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)||!cn(e[n],t[n]))return!1;return Object.keys(t).length===i}}return e!==e&&t!==t}const or=e=>(e==null?void 0:e.fillOpacity)!==void 0?re((e==null?void 0:e.fill)||pe.fill).alpha(e.fillOpacity).toHex():e!=null&&e.fill?e.fill:re(pe.fill).alpha(pe.fillOpacity).toHex(),rr=(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))},sr=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 v=!(cn(n,s)&&u);if(!c&&!v)return;v&&(t.innerHTML=""),[...s].sort((p,h)=>{const{annotation:{target:{created:x}}}=p,{annotation:{target:{created:g}}}=h;return x&&g?x.getTime()-g.getTime():0}).forEach(p=>{p.rects.map(h=>{const x=rr(h,s),g=Jn(p,a,l,c,x);if(v){const f=document.createElement("span");f.className="r6o-annotation",f.dataset.annotation=p.annotation.id,f.style.left=`${h.x}px`,f.style.top=`${h.y}px`,f.style.width=`${h.width}px`,f.style.height=`${h.height}px`,f.style.backgroundColor=or(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")}}},yi=(e,t,n)=>rn(e,t,n,sr(e)),J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function ar(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 dn;const lr=new Uint8Array(16);function cr(){if(!dn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");dn=crypto.getRandomValues.bind(crypto)}return dn(lr)}const vi={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function dr(e,t,n){var o;e=e||{};const i=e.random??((o=e.rng)==null?void 0:o.call(e))??cr();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,ar(i)}function Ei(e,t,n){return vi.randomUUID&&!e?vi.randomUUID():dr(e)}const ur=(e,t)=>({parse:n=>Ai(n),serialize:n=>Si(n,e,t)}),fr=e=>e.quote!==void 0&&e.start!==void 0&&e.end!==void 0,hr=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,v)=>{switch(v.type){case"TextQuoteSelector":d.quote=v.exact;break;case"TextPositionSelector":d.start=v.start,d.end=v.end;break}return d},{});if(fr(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}},Ai=e=>{const t=e.id||Ei(),{creator:n,created:i,modified:o,body:r,...s}=e,a=Yo(r,t),l=hr(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,...u}=o,d=s.map(v=>{const{id:O,quote:p,start:h,end:x,range:g}=v,f={type:"TextQuoteSelector",exact:p};if(n){const{prefix:I,suffix:S}=Xn(g,n);f.prefix=I,f.suffix=S}const k={type:"TextPositionSelector",start:h,end:x};return{...u,id:O,scope:"scope"in v?v.scope:void 0,source:t,selector:[f,k]}});return{...r,"@context":"http://www.w3.org/ns/anno.jsonld",id:e.id,type:"Annotation",body:Ko(e.bodies),creator:a,created:l==null?void 0:l.toISOString(),modified:c==null?void 0:c.toISOString(),target:d}};function Oi(e,t,n=0,i=e.length-1,o=gr){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),v=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),O=Math.max(n,Math.floor(t-c*d/l+v)),p=Math.min(i,Math.floor(t+(l-c)*d/l+v));Oi(e,t,O,p,o)}const r=e[t];let s=n,a=i;for(ot(e,n,t),o(e[i],r)>0&&ot(e,n,i);s<a;){for(ot(e,s,a),s++,a--;o(e[s],r)<0;)s++;for(;o(e[a],r)>0;)a--}o(e[n],r)===0?ot(e,n,a):(a++,ot(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}}function ot(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function gr(e,t){return e<t?-1:e>t?1:0}class pr{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(!Nt(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;Nt(t,l)&&(n.leaf?i.push(a):fn(t,l)?this._all(a,i):r.push(a))}n=r.pop()}return i}collides(t){let n=this.data;if(!Nt(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(Nt(t,s)){if(n.leaf||fn(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=Ve([]),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=mr(t,i.children,n);if(u!==-1)return i.children.splice(u,1),r.push(i),this._condense(r),this}!c&&!i.leaf&&fn(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=Ve(t.slice(n,i+1)),Pe(a,this.toBBox),a;o||(o=Math.ceil(Math.log(r)/Math.log(s)),s=Math.ceil(r/Math.pow(s,o-1))),a=Ve([]),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 u=n;u<=i;u+=c){const d=Math.min(u+c-1,i);xi(t,u,d,l,this.compareMinY);for(let v=u;v<=d;v+=l){const O=Math.min(v+l-1,d);a.children.push(this._build(t,v,O,o-1))}}return Pe(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=un(c),d=yr(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),st(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=Ve(i.children.splice(s,i.children.length-s));a.height=i.height,a.leaf=i.leaf,Pe(i,this.toBBox),Pe(a,this.toBBox),n?t[n-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,n){this.data=Ve([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Pe(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=rt(t,0,a,this.toBBox),c=rt(t,a,i,this.toBBox),u=vr(l,c),d=un(l)+un(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:br,r=t.leaf?this.compareMinY:wr,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=rt(t,0,n,r),a=rt(t,i-n,i,r);let l=Lt(s)+Lt(a);for(let c=n;c<i-n;c++){const u=t.children[c];st(s,t.leaf?r(u):u),l+=Lt(s)}for(let c=i-n-1;c>=n;c--){const u=t.children[c];st(a,t.leaf?r(u):u),l+=Lt(a)}return l}_adjustParentBBoxes(t,n,i){for(let o=i;o>=0;o--)st(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():Pe(t[n],this.toBBox)}}function mr(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 Pe(e,t){rt(e,0,e.children.length,t,e)}function rt(e,t,n,i,o){o||(o=Ve(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];st(o,e.leaf?i(s):s)}return o}function st(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 br(e,t){return e.minX-t.minX}function wr(e,t){return e.minY-t.minY}function un(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function Lt(e){return e.maxX-e.minX+(e.maxY-e.minY)}function yr(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 vr(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 fn(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function Nt(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Ve(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 Er=()=>({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 pr,r=new Map,s=Er(),a=(S,N)=>{const _=S.selector.flatMap(H=>{const V=ge([H])?H.range:Qt(H,t).range;return Pn(V)}),B=Yn(_,n,i).map(H=>jn(H,N));return B.map(H=>{const{x:V,y:X,width:A,height:T}=H;return{minX:V,minY:X,maxX:V+A,maxY:X+T,annotation:{id:S.annotation,rects:B}}})},l=()=>[...r.values()],c=()=>{o.clear(),r.clear()},u=S=>{const N=a(S,t.getBoundingClientRect());N.length!==0&&(N.forEach(_=>o.insert(_)),r.set(S.annotation,N))},d=S=>{const N=r.get(S.annotation);N&&(N.forEach(_=>o.remove(_)),r.delete(S.annotation))},v=S=>{d(S),u(S)},O=(S,N=!0)=>{N&&c();const _=t.getBoundingClientRect(),B=S.map(V=>({target:V,rects:a(V,_)}));B.forEach(({target:V,rects:X})=>{X.length>0&&r.set(V.annotation,X)});const H=B.flatMap(({rects:V})=>V);o.load(H)},p=(S,N,_=!1)=>{const B=o.search({minX:S,minY:N,maxX:S,maxY:N}),H=V=>V.annotation.rects.reduce((X,A)=>X+A.width*A.height,0);return B.length>0?(B.sort((V,X)=>H(V)-H(X)),_?B.map(V=>V.annotation.id):[B[0].annotation.id]):[]},h=S=>{const N=x(S);if(N.length===0)return;let _=N[0].left,B=N[0].top,H=N[0].right,V=N[0].bottom;for(let X=1;X<N.length;X++){const A=N[X];_=Math.min(_,A.left),B=Math.min(B,A.top),H=Math.max(H,A.right),V=Math.max(V,A.bottom)}return new DOMRect(_,B,H-_,V-B)},x=S=>{const N=r.get(S);return N?N[0].annotation.rects:[]};return{all:l,clear:c,getAt:p,getAnnotationBounds:h,getAnnotationRects:x,getIntersecting:(S,N,_,B)=>{const H=o.search({minX:S,minY:N,maxX:_,maxY:B}),V=new Set(H.map(X=>X.annotation.id));return Array.from(V).map(X=>({annotation:e.getAnnotation(X),rects:x(X)})).filter(X=>!!X.annotation)},insert:u,recalculate:()=>{O(e.all().map(S=>S.target),!0),s.emit("recalculate")},remove:d,set:O,size:()=>o.all().length,update:v,on:(S,N)=>s.on(S,N)}},Ci=(e,t)=>{var f,k;const n=Ro(),i=Ar(n,e,(f=t.mergeHighlights)==null?void 0:f.horizontalTolerance,(k=t.mergeHighlights)==null?void 0:k.verticalTolerance),o=ho(n,t.userSelectAction,t.adapter),r=fo(n),s=Io(),a=(I,S=F.LOCAL)=>{const N=xt(I,e),_=ge(N.target.selector);return _&&n.addAnnotation(N,S),_},l=(I,S=!0,N=F.LOCAL)=>{const _=I.map(H=>xt(H,e)),B=_.filter(H=>!ge(H.target.selector));return n.bulkAddAnnotations(_,S,N),B},c=(I,S=F.LOCAL)=>{const N=I.map(B=>xt(B,e)),_=N.filter(B=>!ge(B.target.selector));return N.forEach(B=>{n.getAnnotation(B.id)?n.updateAnnotation(B,S):n.addAnnotation(B,S)}),_},u=(I,S=F.LOCAL)=>{const N=et(I,e);n.updateTarget(N,S)},d=(I,S=F.LOCAL)=>{const N=I.map(_=>et(_,e));n.bulkUpdateTargets(N,S)};function v(I,S,N,_){const B=N||!!_,H=i.getAt(I,S,B).map(X=>n.getAnnotation(X)),V=_?H.filter(_):H;if(V.length!==0)return N?V:V[0]}const O=I=>i.getAnnotationRects(I).length>0?i.getAnnotationBounds(I):void 0,p=(I,S,N,_)=>i.getIntersecting(I,S,N,_),h=I=>i.getAnnotationRects(I),x=()=>i.recalculate(),g=I=>i.on("recalculate",I);return n.observe(({changes:I})=>{const S=(I.deleted||[]).filter(B=>ge(B.target.selector)),N=(I.created||[]).filter(B=>ge(B.target.selector)),_=(I.updated||[]).filter(B=>ge(B.newValue.target.selector));(S==null?void 0:S.length)>0&&S.forEach(B=>i.remove(B.target)),N.length>0&&i.set(N.map(B=>B.target),!1),(_==null?void 0:_.length)>0&&_.forEach(({newValue:B})=>i.update(B.target))}),{store:{...n,addAnnotation:a,bulkAddAnnotations:l,bulkUpdateTargets:d,bulkUpsertAnnotations:c,getAnnotationBounds:O,getAnnotationRects:h,getIntersecting:p,getAt:v,recalculatePositions:x,onRecalculatePositions:g,updateTarget:u},selection:o,hover:r,viewport:s}},Sr=()=>{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},Ti=(e,t={})=>{const n=Sr(),i=n.getContext("2d");document.body.appendChild(n);const o=new Map,r=u=>Array.from(o.entries()).filter(([d,v])=>v.presenceKey===u.presenceKey).map(([d,v])=>d);return e.on("selectionChange",(u,d)=>{r(u).forEach(O=>o.delete(O)),d&&d.forEach(O=>o.set(O,u))}),{clear:()=>{const{width:u,height:d}=n;i.clearRect(-.5,-.5,u+1,d+1)},destroy:()=>{n.remove()},paint:(u,d,v)=>{t.font&&(i.font=t.font);const O=o.get(u.annotation.id);if(O){const{height:p}=u.rects[0],h=u.rects[0].x+d.left,x=u.rects[0].y+d.top;i.fillStyle=O.appearance.color,i.fillRect(h-2,x-2.5,2,p+5);const g=i.measureText(O.appearance.label),f=g.width+6,k=g.actualBoundingBoxAscent+g.actualBoundingBoxDescent+8,I=g.fontBoundingBoxAscent?8:6.5;return i.fillRect(h-2,x-2.5-k,f,k),i.fillStyle="#fff",i.fillText(O.appearance.label,h+1,x-I),{fill:O.appearance.color,fillOpacity:v?.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)}}},hn=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function gn(e,t,n,i){e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on".concat(t),n)}function at(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 Or(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 lt={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,"-":hn?173:189,"=":hn?61:187,";":hn?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},ct={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Q={16:!1,18:!1,17:!1,91:!1},W={};for(let e=1;e<20;e++)lt["f".concat(e)]=111+e;let K=[],dt=null,Li="all";const ve=new Map,Xe=e=>lt[e.toLowerCase()]||de[e.toLowerCase()]||e.toUpperCase().charCodeAt(0),xr=e=>Object.keys(lt).find(t=>lt[t]===e),Cr=e=>Object.keys(de).find(t=>de[t]===e);function Ni(e){Li=e||"all"}function ut(){return Li||"all"}function Tr(){return K.slice(0)}function Rr(){return K.map(e=>xr(e)||Cr(e)||String.fromCharCode(e))}function kr(){const e=[];return Object.keys(W).forEach(t=>{W[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=>Xe(a))})})}),e}function Lr(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 Nr(e){return typeof e=="string"&&(e=Xe(e)),K.indexOf(e)!==-1}function Ir(e,t){let n,i;e||(e=ut());for(const o in W)if(Object.prototype.hasOwnProperty.call(W,o))for(n=W[o],i=0;i<n.length;)n[i].scope===e?n.splice(i,1).forEach(s=>{let{element:a}=s;return pn(a)}):i++;ut()===e&&Ni(t||"all")}function Mr(e){let t=e.keyCode||e.which||e.charCode;e.key&&e.key.toLowerCase()==="capslock"&&(t=Xe(e.key));const n=K.indexOf(t);if(n>=0&&K.splice(n,1),e.key&&e.key.toLowerCase()==="meta"&&K.splice(0,K.length),(t===93||t===224)&&(t=91),t in Q){Q[t]=!1;for(const i in de)de[i]===t&&(se[i]=!1)}}function Ii(e){if(typeof e>"u")Object.keys(W).forEach(o=>{Array.isArray(W[o])&&W[o].forEach(r=>It(r)),delete W[o]}),pn(null);else if(Array.isArray(e))e.forEach(o=>{o.key&&It(o)});else if(typeof e=="object")e.key&&It(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=""),It({key:e,scope:o,method:r,splitKey:"+"})}}const It=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],u=c==="*"?"*":Xe(c);if(!W[u])return;n||(n=ut());const d=l>1?Ri(de,a):[],v=[];W[u]=W[u].filter(O=>{const h=(i?O.method===i:!0)&&O.scope===n&&Or(O.mods,d);return h&&v.push(O.element),!h}),v.forEach(O=>pn(O))})};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 Q)Object.prototype.hasOwnProperty.call(Q,r)&&(!Q[r]&&t.mods.indexOf(+r)>-1||Q[r]&&t.mods.indexOf(+r)===-1)&&(o=!1);(t.mods.length===0&&!Q[16]&&!Q[18]&&!Q[17]&&!Q[91]||o||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(K),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=W["*"];let i=e.keyCode||e.which||e.charCode;if(e.key&&e.key.toLowerCase()==="capslock"||!se.filter.call(this,e))return;if((i===93||i===224)&&(i=91),K.indexOf(i)===-1&&i!==229&&K.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{const l=ct[a];e[a]&&K.indexOf(l)===-1?K.push(l):!e[a]&&K.indexOf(l)>-1?K.splice(K.indexOf(l),1):a==="metaKey"&&e[a]&&(K=K.filter(c=>c in ct||c===i))}),i in Q){Q[i]=!0;for(const a in de)if(Object.prototype.hasOwnProperty.call(de,a)){const l=ct[de[a]];se[a]=e[l]}if(!n)return}for(const a in Q)Object.prototype.hasOwnProperty.call(Q,a)&&(Q[a]=e[ct[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(K.indexOf(17)===-1&&K.push(17),K.indexOf(18)===-1&&K.push(18),Q[17]=!0,Q[18]=!0);const o=ut();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 W))return;const r=W[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 v=0;v<u.length;v++)d.push(Xe(u[v]));d.sort().join("")===K.sort().join("")&&Mi(e,l,o,t)}}function se(e,t,n){K=[];const i=ki(e);let o=[],r="all",s=document,a=0,l=!1,c=!0,u="+",d=!1,v=!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&&(v=!0)),typeof t=="string"&&(r=t),v&&Ii(e,r);a<i.length;a++)e=i[a].split(u),o=[],e.length>1&&(o=Ri(de,e)),e=e[e.length-1],e=e==="*"?"*":Xe(e),e in W||(W[e]=[]),W[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(!ve.has(s)){const O=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;return Bi(h,s)},p=function(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.event;Bi(h,s),Mr(h)};ve.set(s,{keydownListener:O,keyupListenr:p,capture:d}),gn(s,"keydown",O,d),gn(s,"keyup",p,d)}if(!dt){const O=()=>{K=[]};dt={listener:O,capture:d},gn(window,"focus",O,d)}}}function Br(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(W).forEach(n=>{W[n].filter(o=>o.scope===t&&o.shortcut===e).forEach(o=>{o&&o.method&&o.method()})})}function pn(e){const t=Object.values(W).flat();if(t.findIndex(i=>{let{element:o}=i;return o===e})<0){const{keydownListener:i,keyupListenr:o,capture:r}=ve.get(e)||{};i&&o&&(at(e,"keyup",o,r),at(e,"keydown",i,r),ve.delete(e))}if((t.length<=0||ve.size<=0)&&(Object.keys(ve).forEach(o=>{const{keydownListener:r,keyupListenr:s,capture:a}=ve.get(o)||{};r&&s&&(at(o,"keyup",s,a),at(o,"keydown",r,a),ve.delete(o))}),ve.clear(),Object.keys(W).forEach(o=>delete W[o]),dt)){const{listener:o,capture:r}=dt;at(window,"focus",o,r),dt=null}}const mn={getPressedKeyString:Rr,setScope:Ni,getScope:ut,deleteScope:Ir,getPressedKeyCodes:Tr,getAllKeyCodes:kr,isPressed:Nr,filter:Lr,trigger:Br,unbind:Ii,keyMap:lt,modifier:de,modifierMap:ct};for(const e in mn)Object.prototype.hasOwnProperty.call(mn,e)&&(se[e]=mn[e]);if(typeof window<"u"){const e=window.hotkeys;se.noConflict=t=>(t&&window.hotkeys===se&&(window.hotkeys=e),se),window.hotkeys=se}async function _r(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,Di=["up","down","left","right"],Ui=Gt?"⌘+a":"ctrl+a",Dr=[...Di.map(e=>`shift+${e}`),Ui],Hi=(e,t,n,i)=>{const{store:o,selection:r}=t;let s;const{annotatingEnabled:a,offsetReferenceSelector:l,selectionMode:c,dismissOnNotAnnotatable:u="NEVER"}=i,d=R=>s=R;let v;const O=R=>v=R;let p,h,x,g,f=a;const k=R=>{f=R,N.clear(),R||(h=void 0,p=void 0,x=void 0,g=void 0)},I=R=>{const L=R;return Gt?L.metaKey:L.ctrlKey},S=()=>{if(!f||x===!1)return;const{selected:R}=r;if(i.allowModifierSelect&&I(g)&&R.length===1&&R[0].editable){const U=o.getAnnotation(R[0].id);if(U!=null&&U.target){h=U.target,p={annotation:U.id,selector:[],created:h.created,creator:h.creator,updated:new Date,updatedBy:s};return}}h=void 0,p={annotation:Ei(),selector:[],created:new Date,creator:s}},N=nt(R=>{if(!f)return;const L=document.getSelection();if(!(L!=null&&L.anchorNode))return;const U=Array.from(Array(L.rangeCount).keys()).map(q=>L.getRangeAt(q));if(!U.some(q=>q.intersectsNode(e))){p=void 0;return}const Z=R.timeStamp-((g==null?void 0:g.timeStamp)||R.timeStamp);if((g==null?void 0:g.type)==="pointerdown"&&(Z<1e3&&!p||L.isCollapsed&&Z<_i)&&S(),p||S(),L.isCollapsed){o.getAnnotation(p.annotation)&&!I(g)&&(r.clear(),o.deleteAnnotation(p.annotation));return}const ae=U.map(q=>zn(q,e));if(ae.every(q=>Fn(q)))return;const le=ae.flatMap(q=>Vn(e,q.cloneRange()));if(!(le.length>0&&!p||le.length!==p.selector.length||le.some((q,ft)=>{var bn;return q.toString()!==((bn=p.selector[ft])==null?void 0:bn.quote)})))return;const Mt=h?Kn([...h.selector.map(q=>q.range),...le]):le;p={...p,selector:Mt.map(q=>Wn(q,e,l)),updated:new Date},o.getAnnotation(p.annotation)?o.updateTarget(p,F.LOCAL):I(R)||r.clear()},10),_=R=>{g=gt(R),x=g.button===0},B=async R=>{if(!x)return;const L=gt(R),U=()=>{const{x:ae,y:le}=e.getBoundingClientRect();if(Fe(e,L.target)){(typeof u=="function"?u(L,e):u==="ALWAYS")&&r.clear();return}const xe=L.target instanceof Node&&e.contains(L.target)&&o.getAt(L.clientX-ae,L.clientY-le,c==="all",v);if(xe){const{selected:Mt}=r,q=new Set(Mt.map(ht=>ht.id)),ft=Array.isArray(xe)?xe.map(ht=>ht.id):[xe.id];(q.size!==ft.length||!ft.every(ht=>q.has(ht)))&&(n.emit("clickAnnotation",xe),r.userSelect(ft,L))}else r.clear()};if(L.timeStamp-g.timeStamp<_i){await H();const ae=document.getSelection(),le=Fe(e,g.target),xe=Fe(e,L.target);if(ae!=null&&ae.isCollapsed||le&&xe){p=void 0,U();return}}p&&p.selector.length>0&&(C(),r.userSelect(p.annotation,L))},H=async()=>{const R=document.getSelection();let L=!1,U=R==null?void 0:R.isCollapsed;const Z=()=>U||L,ae=1;return setTimeout(()=>L=!0,50),_r(()=>U=R==null?void 0:R.isCollapsed,ae,Z)},V=R=>{const L=document.getSelection();L!=null&&L.isCollapsed||((!p||p.selector.length===0)&&N(R),p&&(C(),r.userSelect(p.annotation,gt(R))))},X=R=>{f&&R.key==="Shift"&&p&&(document.getSelection().isCollapsed||(C(),r.userSelect(p.annotation,Ye(R))))},A=R=>{const L=()=>setTimeout(()=>{(p==null?void 0:p.selector.length)>0&&(r.clear(),o.addAnnotation({id:p.annotation,bodies:[],target:p}),r.userSelect(p.annotation,Ye(R))),document.removeEventListener("selectionchange",L)},100);document.addEventListener("selectionchange",L),S()};se(Dr.join(","),{element:e,keydown:!0,keyup:!1},R=>{R.repeat||(g=Ye(R))}),se(Ui,{keydown:!0,keyup:!1},R=>{g=Ye(R),A(R)});const T=R=>{R.repeat||R.target!==e&&R.target!==document.body||(p=void 0,r.clear())};se(Di.join(","),{keydown:!0,keyup:!1},T);const C=()=>{const R=o.getAnnotation(p.annotation);if(!R){o.addAnnotation({id:p.annotation,bodies:[],target:p});return}const{target:{updated:L}}=R,{updated:U}=p;(!L||!U||L<U)&&o.updateTarget(p)};return document.addEventListener("pointerdown",_),document.addEventListener("pointerup",B),document.addEventListener("contextmenu",V),e.addEventListener("keyup",X),e.addEventListener("selectstart",S),document.addEventListener("selectionchange",N),{destroy:()=>{p=void 0,h=void 0,x=void 0,g=void 0,N.clear(),document.removeEventListener("pointerdown",_),document.removeEventListener("pointerup",B),document.removeEventListener("contextmenu",V),e.removeEventListener("keyup",X),e.removeEventListener("selectstart",S),document.removeEventListener("selectionchange",N),se.unbind()},setFilter:O,setUser:d,setAnnotatingEnabled:k}},Pi=(e,t)=>({...e,annotatingEnabled:e.annotatingEnabled??t.annotatingEnabled,user:e.user||t.user}),Vi="SPANS",Ur=(e,t={})=>{yn(e),Hn(e);const n=Pi(t,{annotatingEnabled:!0,user:Xo()}),i=Ci(e,n),{selection:o,viewport:r}=i,s=i.store,a=No(s),l=Mo(i,a,n.adapter);let c=n.user;const u=n.renderer==="CSS_HIGHLIGHTS"?CSS.highlights?"CSS_HIGHLIGHTS":Vi:n.renderer||Vi,d=u==="SPANS"?yi(e,i,r):u==="CSS_HIGHLIGHTS"?bi(e,i,r):u==="CANVAS"?oi(e,i,r):void 0;if(!d)throw`Unknown renderer implementation: ${u}`;console.debug(`Using ${u} renderer`),n.style&&d.setStyle(n.style);const v=Hi(e,i,l,n);v.setUser(c);const O=_o(i,a,n.adapter),p=()=>c,h=S=>{v.setAnnotatingEnabled(S===void 0?!0:S)},x=S=>{d.setFilter(S),v.setFilter(S)},g=S=>{c=S,v.setUser(S)},f=S=>{S&&(d.setPainter(Ti(S,n.presence)),S.on("selectionChange",()=>d.redraw()))},k=S=>{S?o.setSelected(S):o.clear()};return{...O,destroy:()=>{d.destroy(),v.destroy(),a.destroy()},element:e,getUser:p,setAnnotatingEnabled:h,setFilter:x,setStyle:d.setStyle.bind(d),redraw:d.redraw.bind(d),setUser:g,setSelected:k,setPresenceProvider:f,setVisible:d.setVisible.bind(d),on:l.on,off:l.off,scrollIntoView:Gn(e,s),state:i}};D.DEFAULT_SELECTED_STYLE=tt,D.DEFAULT_STYLE=pe,D.NOT_ANNOTATABLE_CLASS=Ce,D.NOT_ANNOTATABLE_SELECTOR=Te,D.Origin=F,D.UserSelectAction=tn,D.W3CTextFormat=ur,D.cancelSingleClickEvents=yn,D.cloneKeyboardEvent=Ye,D.clonePointerEvent=gt,D.createBody=vo,D.createCanvasRenderer=oi,D.createHighlightsRenderer=bi,D.createPresencePainter=Ti,D.createRenderer=mi,D.createSelectionHandler=Hi,D.createSpansRenderer=yi,D.createTextAnnotator=Ur,D.createTextAnnotatorState=Ci,D.fillDefaults=Pi,D.getHighlightClientRects=Pn,D.getQuoteContext=Xn,D.getRangeAnnotatableContents=Ot,D.isMac=Gt,D.isNodeWhitespaceOrEmpty=no,D.isNotAnnotatable=Fe,D.isRangeAnnotatable=wn,D.isRangeWhitespaceOrEmpty=Fn,D.isRevived=ge,D.mergeClientRects=Yn,D.mergeRanges=Kn,D.paint=Jn,D.parseW3CTextAnnotation=Ai,D.programmaticallyFocusable=Hn,D.rangeToSelector=Wn,D.reviveAnnotation=xt,D.reviveSelector=Qt,D.reviveTarget=et,D.scrollIntoView=Gn,D.serializeW3CTextAnnotation=Si,D.splitAnnotatableRanges=Vn,D.toDomRectList=ro,D.toParentBounds=jn,D.toViewportBounds=so,D.trimRangeToContainer=zn,D.whitespaceOrEmptyRegex=Jt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|
|
3
3
|
//# sourceMappingURL=text-annotator.umd.js.map
|