@sfgrp/distinguish
Version:
An interactive key engine that feeds off of [TaxonWorks](https://taxonworks.org)' [API](https://api.taxonworks.org). Distinguish is a product of the [Species File Group](https://speciesfilegroup.org) and its collaborators.
6 lines • 67.4 kB
JavaScript
(function(O,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],n):(O=typeof globalThis<"u"?globalThis:O||self,n(O.Distinguish={},O.Vue,O.Pinia))})(this,function(O,n,Y){"use strict";function Re(e,t){return function(){return e.apply(t,arguments)}}const{toString:kt}=Object.prototype,{getPrototypeOf:ue}=Object,Z=(e=>t=>{const r=kt.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),T=e=>(e=e.toLowerCase(),t=>Z(t)===e),v=e=>t=>typeof t===e,{isArray:j}=Array,z=v("undefined");function wt(e){return e!==null&&!z(e)&&e.constructor!==null&&!z(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const xe=T("ArrayBuffer");function Et(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&xe(e.buffer),t}const St=v("string"),x=v("function"),Te=v("number"),ee=e=>e!==null&&typeof e=="object",Bt=e=>e===!0||e===!1,te=e=>{if(Z(e)!=="object")return!1;const t=ue(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ct=T("Date"),Nt=T("File"),Rt=T("Blob"),xt=T("FileList"),Tt=e=>ee(e)&&x(e.pipe),Ot=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=Z(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},Dt=T("URLSearchParams"),[Vt,At,It,$t]=["ReadableStream","Request","Response","Headers"].map(T),Ut=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function K(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let o,s;if(typeof e!="object"&&(e=[e]),j(e))for(o=0,s=e.length;o<s;o++)t.call(null,e[o],o,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let l;for(o=0;o<a;o++)l=i[o],t.call(null,e[l],l,e)}}function Oe(e,t){t=t.toLowerCase();const r=Object.keys(e);let o=r.length,s;for(;o-- >0;)if(s=r[o],t===s.toLowerCase())return s;return null}const $=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,De=e=>!z(e)&&e!==$;function fe(){const{caseless:e}=De(this)&&this||{},t={},r=(o,s)=>{const i=e&&Oe(t,s)||s;te(t[i])&&te(o)?t[i]=fe(t[i],o):te(o)?t[i]=fe({},o):j(o)?t[i]=o.slice():t[i]=o};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&K(arguments[o],r);return t}const Lt=(e,t,r,{allOwnKeys:o}={})=>(K(t,(s,i)=>{r&&x(s)?e[i]=Re(s,r):e[i]=s},{allOwnKeys:o}),e),Ft=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Pt=(e,t,r,o)=>{e.prototype=Object.create(t.prototype,o),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Mt=(e,t,r,o)=>{let s,i,a;const l={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],(!o||o(a,e,t))&&!l[a]&&(t[a]=e[a],l[a]=!0);e=r!==!1&&ue(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},jt=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const o=e.indexOf(t,r);return o!==-1&&o===r},qt=e=>{if(!e)return null;if(j(e))return e;let t=e.length;if(!Te(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Ht=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ue(Uint8Array)),zt=(e,t)=>{const o=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=o.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Kt=(e,t)=>{let r;const o=[];for(;(r=e.exec(t))!==null;)o.push(r);return o},Jt=T("HTMLFormElement"),Wt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,s){return o.toUpperCase()+s}),Ve=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),Xt=T("RegExp"),Ae=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),o={};K(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(o[i]=a||s)}),Object.defineProperties(e,o)},Qt=e=>{Ae(e,(t,r)=>{if(x(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=e[r];if(x(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},Gt=(e,t)=>{const r={},o=s=>{s.forEach(i=>{r[i]=!0})};return j(e)?o(e):o(String(e).split(t)),r},Yt=()=>{},Zt=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function vt(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const en=e=>{const t=new Array(10),r=(o,s)=>{if(ee(o)){if(t.indexOf(o)>=0)return;if(!("toJSON"in o)){t[s]=o;const i=j(o)?[]:{};return K(o,(a,l)=>{const u=r(a,s+1);!z(u)&&(i[l]=u)}),t[s]=void 0,i}}return o};return r(e,0)},tn=T("AsyncFunction"),nn=e=>e&&(ee(e)||x(e))&&x(e.then)&&x(e.catch),Ie=((e,t)=>e?setImmediate:t?((r,o)=>($.addEventListener("message",({source:s,data:i})=>{s===$&&i===r&&o.length&&o.shift()()},!1),s=>{o.push(s),$.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",x($.postMessage)),rn=typeof queueMicrotask<"u"?queueMicrotask.bind($):typeof process<"u"&&process.nextTick||Ie,c={isArray:j,isArrayBuffer:xe,isBuffer:wt,isFormData:Ot,isArrayBufferView:Et,isString:St,isNumber:Te,isBoolean:Bt,isObject:ee,isPlainObject:te,isReadableStream:Vt,isRequest:At,isResponse:It,isHeaders:$t,isUndefined:z,isDate:Ct,isFile:Nt,isBlob:Rt,isRegExp:Xt,isFunction:x,isStream:Tt,isURLSearchParams:Dt,isTypedArray:Ht,isFileList:xt,forEach:K,merge:fe,extend:Lt,trim:Ut,stripBOM:Ft,inherits:Pt,toFlatObject:Mt,kindOf:Z,kindOfTest:T,endsWith:jt,toArray:qt,forEachEntry:zt,matchAll:Kt,isHTMLForm:Jt,hasOwnProperty:Ve,hasOwnProp:Ve,reduceDescriptors:Ae,freezeMethods:Qt,toObjectSet:Gt,toCamelCase:Wt,noop:Yt,toFiniteNumber:Zt,findKey:Oe,global:$,isContextDefined:De,isSpecCompliantForm:vt,toJSONObject:en,isAsyncFn:tn,isThenable:nn,setImmediate:Ie,asap:rn};function g(e,t,r,o,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),o&&(this.request=o),s&&(this.response=s,this.status=s.status?s.status:null)}c.inherits(g,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:c.toJSONObject(this.config),code:this.code,status:this.status}}});const $e=g.prototype,Ue={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ue[e]={value:e}}),Object.defineProperties(g,Ue),Object.defineProperty($e,"isAxiosError",{value:!0}),g.from=(e,t,r,o,s,i)=>{const a=Object.create($e);return c.toFlatObject(e,a,function(u){return u!==Error.prototype},l=>l!=="isAxiosError"),g.call(a,e.message,t,r,o,s),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};const on=null;function me(e){return c.isPlainObject(e)||c.isArray(e)}function Le(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function Fe(e,t,r){return e?e.concat(t).map(function(s,i){return s=Le(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function sn(e){return c.isArray(e)&&!e.some(me)}const an=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function ne(e,t,r){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=c.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(y,h){return!c.isUndefined(h[y])});const o=r.metaTokens,s=r.visitor||p,i=r.dots,a=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&c.isSpecCompliantForm(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function d(m){if(m===null)return"";if(c.isDate(m))return m.toISOString();if(!u&&c.isBlob(m))throw new g("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(m)||c.isTypedArray(m)?u&&typeof Blob=="function"?new Blob([m]):Buffer.from(m):m}function p(m,y,h){let k=m;if(m&&!h&&typeof m=="object"){if(c.endsWith(y,"{}"))y=o?y:y.slice(0,-2),m=JSON.stringify(m);else if(c.isArray(m)&&sn(m)||(c.isFileList(m)||c.endsWith(y,"[]"))&&(k=c.toArray(m)))return y=Le(y),k.forEach(function(S,A){!(c.isUndefined(S)||S===null)&&t.append(a===!0?Fe([y],A,i):a===null?y:y+"[]",d(S))}),!1}return me(m)?!0:(t.append(Fe(h,y,i),d(m)),!1)}const f=[],b=Object.assign(an,{defaultVisitor:p,convertValue:d,isVisitable:me});function w(m,y){if(!c.isUndefined(m)){if(f.indexOf(m)!==-1)throw Error("Circular reference detected in "+y.join("."));f.push(m),c.forEach(m,function(k,E){(!(c.isUndefined(k)||k===null)&&s.call(t,k,c.isString(E)?E.trim():E,y,b))===!0&&w(k,y?y.concat(E):[E])}),f.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return w(e),t}function Pe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(o){return t[o]})}function he(e,t){this._pairs=[],e&&ne(e,this,t)}const Me=he.prototype;Me.append=function(t,r){this._pairs.push([t,r])},Me.toString=function(t){const r=t?function(o){return t.call(this,o,Pe)}:Pe;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function ln(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function je(e,t,r){if(!t)return e;const o=r&&r.encode||ln;c.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let i;if(s?i=s(t,r):i=c.isURLSearchParams(t)?t.toString():new he(t,r).toString(o),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class qe{constructor(){this.handlers=[]}use(t,r,o){return this.handlers.push({fulfilled:t,rejected:r,synchronous:o?o.synchronous:!1,runWhen:o?o.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(o){o!==null&&t(o)})}}const He={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:he,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},ge=typeof window<"u"&&typeof document<"u",ye=typeof navigator=="object"&&navigator||void 0,dn=ge&&(!ye||["ReactNative","NativeScript","NS"].indexOf(ye.product)<0),pn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",un=ge&&window.location.href||"http://localhost",C={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ge,hasStandardBrowserEnv:dn,hasStandardBrowserWebWorkerEnv:pn,navigator:ye,origin:un},Symbol.toStringTag,{value:"Module"})),...cn};function fn(e,t){return ne(e,new C.classes.URLSearchParams,Object.assign({visitor:function(r,o,s,i){return C.isNode&&c.isBuffer(r)?(this.append(o,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function mn(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function hn(e){const t={},r=Object.keys(e);let o;const s=r.length;let i;for(o=0;o<s;o++)i=r[o],t[i]=e[i];return t}function ze(e){function t(r,o,s,i){let a=r[i++];if(a==="__proto__")return!0;const l=Number.isFinite(+a),u=i>=r.length;return a=!a&&c.isArray(s)?s.length:a,u?(c.hasOwnProp(s,a)?s[a]=[s[a],o]:s[a]=o,!l):((!s[a]||!c.isObject(s[a]))&&(s[a]=[]),t(r,o,s[a],i)&&c.isArray(s[a])&&(s[a]=hn(s[a])),!l)}if(c.isFormData(e)&&c.isFunction(e.entries)){const r={};return c.forEachEntry(e,(o,s)=>{t(mn(o),s,r,0)}),r}return null}function gn(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(o){if(o.name!=="SyntaxError")throw o}return(r||JSON.stringify)(e)}const J={transitional:He,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const o=r.getContentType()||"",s=o.indexOf("application/json")>-1,i=c.isObject(t);if(i&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s?JSON.stringify(ze(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t)||c.isReadableStream(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let l;if(i){if(o.indexOf("application/x-www-form-urlencoded")>-1)return fn(t,this.formSerializer).toString();if((l=c.isFileList(t))||o.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return ne(l?{"files[]":t}:t,u&&new u,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),gn(t)):t}],transformResponse:[function(t){const r=this.transitional||J.transitional,o=r&&r.forcedJSONParsing,s=this.responseType==="json";if(c.isResponse(t)||c.isReadableStream(t))return t;if(t&&c.isString(t)&&(o&&!this.responseType||s)){const a=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(l){if(a)throw l.name==="SyntaxError"?g.from(l,g.ERR_BAD_RESPONSE,this,null,this.response):l}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:C.classes.FormData,Blob:C.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};c.forEach(["delete","get","head","post","put","patch"],e=>{J.headers[e]={}});const yn=c.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),bn=e=>{const t={};let r,o,s;return e&&e.split(`
`).forEach(function(a){s=a.indexOf(":"),r=a.substring(0,s).trim().toLowerCase(),o=a.substring(s+1).trim(),!(!r||t[r]&&yn[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},Ke=Symbol("internals");function W(e){return e&&String(e).trim().toLowerCase()}function re(e){return e===!1||e==null?e:c.isArray(e)?e.map(re):String(e)}function _n(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(e);)t[o[1]]=o[2];return t}const kn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function be(e,t,r,o,s){if(c.isFunction(o))return o.call(this,t,r);if(s&&(t=r),!!c.isString(t)){if(c.isString(o))return t.indexOf(o)!==-1;if(c.isRegExp(o))return o.test(t)}}function wn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function En(e,t){const r=c.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(e,o+r,{value:function(s,i,a){return this[o].call(this,t,s,i,a)},configurable:!0})})}let N=class{constructor(t){t&&this.set(t)}set(t,r,o){const s=this;function i(l,u,d){const p=W(u);if(!p)throw new Error("header name must be a non-empty string");const f=c.findKey(s,p);(!f||s[f]===void 0||d===!0||d===void 0&&s[f]!==!1)&&(s[f||u]=re(l))}const a=(l,u)=>c.forEach(l,(d,p)=>i(d,p,u));if(c.isPlainObject(t)||t instanceof this.constructor)a(t,r);else if(c.isString(t)&&(t=t.trim())&&!kn(t))a(bn(t),r);else if(c.isHeaders(t))for(const[l,u]of t.entries())i(u,l,o);else t!=null&&i(r,t,o);return this}get(t,r){if(t=W(t),t){const o=c.findKey(this,t);if(o){const s=this[o];if(!r)return s;if(r===!0)return _n(s);if(c.isFunction(r))return r.call(this,s,o);if(c.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=W(t),t){const o=c.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||be(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let s=!1;function i(a){if(a=W(a),a){const l=c.findKey(o,a);l&&(!r||be(o,o[l],l,r))&&(delete o[l],s=!0)}}return c.isArray(t)?t.forEach(i):i(t),s}clear(t){const r=Object.keys(this);let o=r.length,s=!1;for(;o--;){const i=r[o];(!t||be(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const r=this,o={};return c.forEach(this,(s,i)=>{const a=c.findKey(o,i);if(a){r[a]=re(s),delete r[i];return}const l=t?wn(i):String(i).trim();l!==i&&delete r[i],r[l]=re(s),o[l]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return c.forEach(this,(o,s)=>{o!=null&&o!==!1&&(r[s]=t&&c.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(s=>o.set(s)),o}static accessor(t){const o=(this[Ke]=this[Ke]={accessors:{}}).accessors,s=this.prototype;function i(a){const l=W(a);o[l]||(En(s,a),o[l]=!0)}return c.isArray(t)?t.forEach(i):i(t),this}};N.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(N.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(o){this[r]=o}}}),c.freezeMethods(N);function _e(e,t){const r=this||J,o=t||r,s=N.from(o.headers);let i=o.data;return c.forEach(e,function(l){i=l.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Je(e){return!!(e&&e.__CANCEL__)}function q(e,t,r){g.call(this,e??"canceled",g.ERR_CANCELED,t,r),this.name="CanceledError"}c.inherits(q,g,{__CANCEL__:!0});function We(e,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?e(r):t(new g("Request failed with status code "+r.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Sn(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Bn(e,t){e=e||10;const r=new Array(e),o=new Array(e);let s=0,i=0,a;return t=t!==void 0?t:1e3,function(u){const d=Date.now(),p=o[i];a||(a=d),r[s]=u,o[s]=d;let f=i,b=0;for(;f!==s;)b+=r[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),d-a<t)return;const w=p&&d-p;return w?Math.round(b*1e3/w):void 0}}function Cn(e,t){let r=0,o=1e3/t,s,i;const a=(d,p=Date.now())=>{r=p,s=null,i&&(clearTimeout(i),i=null),e.apply(null,d)};return[(...d)=>{const p=Date.now(),f=p-r;f>=o?a(d,p):(s=d,i||(i=setTimeout(()=>{i=null,a(s)},o-f)))},()=>s&&a(s)]}const oe=(e,t,r=3)=>{let o=0;const s=Bn(50,250);return Cn(i=>{const a=i.loaded,l=i.lengthComputable?i.total:void 0,u=a-o,d=s(u),p=a<=l;o=a;const f={loaded:a,total:l,progress:l?a/l:void 0,bytes:u,rate:d||void 0,estimated:d&&l&&p?(l-a)/d:void 0,event:i,lengthComputable:l!=null,[t?"download":"upload"]:!0};e(f)},r)},Xe=(e,t)=>{const r=e!=null;return[o=>t[0]({lengthComputable:r,total:e,loaded:o}),t[1]]},Qe=e=>(...t)=>c.asap(()=>e(...t)),Nn=C.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,C.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(C.origin),C.navigator&&/(msie|trident)/i.test(C.navigator.userAgent)):()=>!0,Rn=C.hasStandardBrowserEnv?{write(e,t,r,o,s,i){const a=[e+"="+encodeURIComponent(t)];c.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),c.isString(o)&&a.push("path="+o),c.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function xn(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Tn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Ge(e,t,r){let o=!xn(t);return e&&(o||r==!1)?Tn(e,t):t}const Ye=e=>e instanceof N?{...e}:e;function U(e,t){t=t||{};const r={};function o(d,p,f,b){return c.isPlainObject(d)&&c.isPlainObject(p)?c.merge.call({caseless:b},d,p):c.isPlainObject(p)?c.merge({},p):c.isArray(p)?p.slice():p}function s(d,p,f,b){if(c.isUndefined(p)){if(!c.isUndefined(d))return o(void 0,d,f,b)}else return o(d,p,f,b)}function i(d,p){if(!c.isUndefined(p))return o(void 0,p)}function a(d,p){if(c.isUndefined(p)){if(!c.isUndefined(d))return o(void 0,d)}else return o(void 0,p)}function l(d,p,f){if(f in t)return o(d,p);if(f in e)return o(void 0,d)}const u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:l,headers:(d,p,f)=>s(Ye(d),Ye(p),f,!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(p){const f=u[p]||s,b=f(e[p],t[p],p);c.isUndefined(b)&&f!==l||(r[p]=b)}),r}const Ze=e=>{const t=U({},e);let{data:r,withXSRFToken:o,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:l}=t;t.headers=a=N.from(a),t.url=je(Ge(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),l&&a.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):"")));let u;if(c.isFormData(r)){if(C.hasStandardBrowserEnv||C.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((u=a.getContentType())!==!1){const[d,...p]=u?u.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([d||"multipart/form-data",...p].join("; "))}}if(C.hasStandardBrowserEnv&&(o&&c.isFunction(o)&&(o=o(t)),o||o!==!1&&Nn(t.url))){const d=s&&i&&Rn.read(i);d&&a.set(s,d)}return t},On=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,o){const s=Ze(e);let i=s.data;const a=N.from(s.headers).normalize();let{responseType:l,onUploadProgress:u,onDownloadProgress:d}=s,p,f,b,w,m;function y(){w&&w(),m&&m(),s.cancelToken&&s.cancelToken.unsubscribe(p),s.signal&&s.signal.removeEventListener("abort",p)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function k(){if(!h)return;const S=N.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),R={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:S,config:e,request:h};We(function(M){r(M),y()},function(M){o(M),y()},R),h=null}"onloadend"in h?h.onloadend=k:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(k)},h.onabort=function(){h&&(o(new g("Request aborted",g.ECONNABORTED,e,h)),h=null)},h.onerror=function(){o(new g("Network Error",g.ERR_NETWORK,e,h)),h=null},h.ontimeout=function(){let A=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const R=s.transitional||He;s.timeoutErrorMessage&&(A=s.timeoutErrorMessage),o(new g(A,R.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),"setRequestHeader"in h&&c.forEach(a.toJSON(),function(A,R){h.setRequestHeader(R,A)}),c.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),l&&l!=="json"&&(h.responseType=s.responseType),d&&([b,m]=oe(d,!0),h.addEventListener("progress",b)),u&&h.upload&&([f,w]=oe(u),h.upload.addEventListener("progress",f),h.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(p=S=>{h&&(o(!S||S.type?new q(null,e,h):S),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(p),s.signal&&(s.signal.aborted?p():s.signal.addEventListener("abort",p)));const E=Sn(s.url);if(E&&C.protocols.indexOf(E)===-1){o(new g("Unsupported protocol "+E+":",g.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Dn=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let o=new AbortController,s;const i=function(d){if(!s){s=!0,l();const p=d instanceof Error?d:this.reason;o.abort(p instanceof g?p:new q(p instanceof Error?p.message:p))}};let a=t&&setTimeout(()=>{a=null,i(new g(`timeout ${t} of ms exceeded`,g.ETIMEDOUT))},t);const l=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(d=>{d.unsubscribe?d.unsubscribe(i):d.removeEventListener("abort",i)}),e=null)};e.forEach(d=>d.addEventListener("abort",i));const{signal:u}=o;return u.unsubscribe=()=>c.asap(l),u}},Vn=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let o=0,s;for(;o<r;)s=o+t,yield e.slice(o,s),o=s},An=async function*(e,t){for await(const r of In(e))yield*Vn(r,t)},In=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:o}=await t.read();if(r)break;yield o}}finally{await t.cancel()}},ve=(e,t,r,o)=>{const s=An(e,t);let i=0,a,l=u=>{a||(a=!0,o&&o(u))};return new ReadableStream({async pull(u){try{const{done:d,value:p}=await s.next();if(d){l(),u.close();return}let f=p.byteLength;if(r){let b=i+=f;r(b)}u.enqueue(new Uint8Array(p))}catch(d){throw l(d),d}},cancel(u){return l(u),s.return()}},{highWaterMark:2})},se=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",et=se&&typeof ReadableStream=="function",$n=se&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Un=et&&tt(()=>{let e=!1;const t=new Request(C.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),nt=64*1024,ke=et&&tt(()=>c.isReadableStream(new Response("").body)),ie={stream:ke&&(e=>e.body)};se&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!ie[t]&&(ie[t]=c.isFunction(e[t])?r=>r[t]():(r,o)=>{throw new g(`Response type '${t}' is not supported`,g.ERR_NOT_SUPPORT,o)})})})(new Response);const Ln=async e=>{if(e==null)return 0;if(c.isBlob(e))return e.size;if(c.isSpecCompliantForm(e))return(await new Request(C.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(c.isArrayBufferView(e)||c.isArrayBuffer(e))return e.byteLength;if(c.isURLSearchParams(e)&&(e=e+""),c.isString(e))return(await $n(e)).byteLength},Fn=async(e,t)=>{const r=c.toFiniteNumber(e.getContentLength());return r??Ln(t)},we={http:on,xhr:On,fetch:se&&(async e=>{let{url:t,method:r,data:o,signal:s,cancelToken:i,timeout:a,onDownloadProgress:l,onUploadProgress:u,responseType:d,headers:p,withCredentials:f="same-origin",fetchOptions:b}=Ze(e);d=d?(d+"").toLowerCase():"text";let w=Dn([s,i&&i.toAbortSignal()],a),m;const y=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let h;try{if(u&&Un&&r!=="get"&&r!=="head"&&(h=await Fn(p,o))!==0){let R=new Request(t,{method:"POST",body:o,duplex:"half"}),I;if(c.isFormData(o)&&(I=R.headers.get("content-type"))&&p.setContentType(I),R.body){const[M,pe]=Xe(h,oe(Qe(u)));o=ve(R.body,nt,M,pe)}}c.isString(f)||(f=f?"include":"omit");const k="credentials"in Request.prototype;m=new Request(t,{...b,signal:w,method:r.toUpperCase(),headers:p.normalize().toJSON(),body:o,duplex:"half",credentials:k?f:void 0});let E=await fetch(m);const S=ke&&(d==="stream"||d==="response");if(ke&&(l||S&&y)){const R={};["status","statusText","headers"].forEach(bt=>{R[bt]=E[bt]});const I=c.toFiniteNumber(E.headers.get("content-length")),[M,pe]=l&&Xe(I,oe(Qe(l),!0))||[];E=new Response(ve(E.body,nt,M,()=>{pe&&pe(),y&&y()}),R)}d=d||"text";let A=await ie[c.findKey(ie,d)||"text"](E,e);return!S&&y&&y(),await new Promise((R,I)=>{We(R,I,{data:A,headers:N.from(E.headers),status:E.status,statusText:E.statusText,config:e,request:m})})}catch(k){throw y&&y(),k&&k.name==="TypeError"&&/fetch/i.test(k.message)?Object.assign(new g("Network Error",g.ERR_NETWORK,e,m),{cause:k.cause||k}):g.from(k,k&&k.code,e,m)}})};c.forEach(we,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const rt=e=>`- ${e}`,Pn=e=>c.isFunction(e)||e===null||e===!1,ot={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let r,o;const s={};for(let i=0;i<t;i++){r=e[i];let a;if(o=r,!Pn(r)&&(o=we[(a=String(r)).toLowerCase()],o===void 0))throw new g(`Unknown adapter '${a}'`);if(o)break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,u])=>`adapter ${l} `+(u===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
`+i.map(rt).join(`
`):" "+rt(i[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:we};function Ee(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new q(null,e)}function st(e){return Ee(e),e.headers=N.from(e.headers),e.data=_e.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),ot.getAdapter(e.adapter||J.adapter)(e).then(function(o){return Ee(e),o.data=_e.call(e,e.transformResponse,o),o.headers=N.from(o.headers),o},function(o){return Je(o)||(Ee(e),o&&o.response&&(o.response.data=_e.call(e,e.transformResponse,o.response),o.response.headers=N.from(o.response.headers))),Promise.reject(o)})}const it="1.8.4",ae={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ae[e]=function(o){return typeof o===e||"a"+(t<1?"n ":" ")+e}});const at={};ae.transitional=function(t,r,o){function s(i,a){return"[Axios v"+it+"] Transitional option '"+i+"'"+a+(o?". "+o:"")}return(i,a,l)=>{if(t===!1)throw new g(s(a," has been removed"+(r?" in "+r:"")),g.ERR_DEPRECATED);return r&&!at[a]&&(at[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,a,l):!0}},ae.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function Mn(e,t,r){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const o=Object.keys(e);let s=o.length;for(;s-- >0;){const i=o[s],a=t[i];if(a){const l=e[i],u=l===void 0||a(l,i,e);if(u!==!0)throw new g("option "+i+" must be "+u,g.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new g("Unknown option "+i,g.ERR_BAD_OPTION)}}const le={assertOptions:Mn,validators:ae},D=le.validators;let L=class{constructor(t){this.defaults=t,this.interceptors={request:new qe,response:new qe}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{o.stack?i&&!String(o.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(o.stack+=`
`+i):o.stack=i}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=U(this.defaults,r);const{transitional:o,paramsSerializer:s,headers:i}=r;o!==void 0&&le.assertOptions(o,{silentJSONParsing:D.transitional(D.boolean),forcedJSONParsing:D.transitional(D.boolean),clarifyTimeoutError:D.transitional(D.boolean)},!1),s!=null&&(c.isFunction(s)?r.paramsSerializer={serialize:s}:le.assertOptions(s,{encode:D.function,serialize:D.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),le.assertOptions(r,{baseUrl:D.spelling("baseURL"),withXsrfToken:D.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&c.merge(i.common,i[r.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],m=>{delete i[m]}),r.headers=N.concat(a,i);const l=[];let u=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(r)===!1||(u=u&&y.synchronous,l.unshift(y.fulfilled,y.rejected))});const d=[];this.interceptors.response.forEach(function(y){d.push(y.fulfilled,y.rejected)});let p,f=0,b;if(!u){const m=[st.bind(this),void 0];for(m.unshift.apply(m,l),m.push.apply(m,d),b=m.length,p=Promise.resolve(r);f<b;)p=p.then(m[f++],m[f++]);return p}b=l.length;let w=r;for(f=0;f<b;){const m=l[f++],y=l[f++];try{w=m(w)}catch(h){y.call(this,h);break}}try{p=st.call(this,w)}catch(m){return Promise.reject(m)}for(f=0,b=d.length;f<b;)p=p.then(d[f++],d[f++]);return p}getUri(t){t=U(this.defaults,t);const r=Ge(t.baseURL,t.url,t.allowAbsoluteUrls);return je(r,t.params,t.paramsSerializer)}};c.forEach(["delete","get","head","options"],function(t){L.prototype[t]=function(r,o){return this.request(U(o||{},{method:t,url:r,data:(o||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function r(o){return function(i,a,l){return this.request(U(l||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}L.prototype[t]=r(),L.prototype[t+"Form"]=r(!0)});let jn=class _t{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const o=this;this.promise.then(s=>{if(!o._listeners)return;let i=o._listeners.length;for(;i-- >0;)o._listeners[i](s);o._listeners=null}),this.promise.then=s=>{let i;const a=new Promise(l=>{o.subscribe(l),i=l}).then(s);return a.cancel=function(){o.unsubscribe(i)},a},t(function(i,a,l){o.reason||(o.reason=new q(i,a,l),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new _t(function(s){t=s}),cancel:t}}};function qn(e){return function(r){return e.apply(null,r)}}function Hn(e){return c.isObject(e)&&e.isAxiosError===!0}const Se={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Se).forEach(([e,t])=>{Se[t]=e});function lt(e){const t=new L(e),r=Re(L.prototype.request,t);return c.extend(r,L.prototype,t,{allOwnKeys:!0}),c.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return lt(U(e,s))},r}const _=lt(J);_.Axios=L,_.CanceledError=q,_.CancelToken=jn,_.isCancel=Je,_.VERSION=it,_.toFormData=ne,_.AxiosError=g,_.Cancel=_.CanceledError,_.all=function(t){return Promise.all(t)},_.spread=qn,_.isAxiosError=Hn,_.mergeConfig=U,_.AxiosHeaders=N,_.formToJSON=e=>ze(c.isHTMLForm(e)?new FormData(e):e),_.getAdapter=ot.getAdapter,_.HttpStatusCode=Se,_.default=_;const{Axios:Mo,AxiosError:jo,CanceledError:qo,isCancel:Ho,CancelToken:zo,VERSION:Ko,all:Jo,Cancel:Wo,isAxiosError:Xo,spread:Qo,toFormData:Go,AxiosHeaders:Yo,HttpStatusCode:Zo,formToJSON:vo,getAdapter:es,mergeConfig:ts}=_,ct=(e={})=>{const t=F(),{baseURL:r,projectId:o,projectToken:s,userToken:i,csrfToken:a}=t.getAPIConfig,l={baseURL:r,params:{project_id:o,project_token:s,token:i},...e};return(!s||!(o&&i)&&a)&&Object.assign(l,{headers:{"X-CSRF-Token":a}}),_.create({...l})};class zn{static key(t,r){return ct().get(`/observation_matrices/${t}/key`,r)}}const X={Used:"used",Useful:"useful",Useless:"useless"},Kn=e=>({characterStateId:e.id,depictionIds:e.depiction_ids,label:e.label,position:e.position,...dt(e)}),Jn=e=>({depictionId:e.id,caption:e.caption,figureLabel:e.figure_label,imageUrl:e.image.medium}),Q={Qualitative:"Descriptor::Qualitative",Continuous:"Descriptor::Continuous",Sample:"Descriptor::Sample",PresenceAbsence:"Descriptor::PresenceAbsence"},G=e=>({descriptorId:e.id,name:e.name,description:e.description,position:e.position,status:e.status,type:e.type,depictionIds:e.depiction_ids,usefulness:e.usefulness,weight:e.weight}),Wn=e=>({...G(e),defaultUnit:e.default_unit,max:e.max,min:e.min}),Xn=e=>({...G(e),defaultUnit:e.default_unit,max:e.max,min:e.min}),Qn=e=>({...G(e),states:e.states.map(t=>dt(t))}),Gn=e=>({...G(e),characterStates:e.states.map(t=>Kn(t))}),Yn=e=>{switch(e.type){case Q.Continuous:return Wn(e);case Q.Sample:return Xn(e);case Q.PresenceAbsence:return Qn(e);case Q.Qualitative:return Gn(e);default:return G(e)}},Zn=e=>({observationMatrixId:e.observation_matrix_id,name:e.observation_matrix.name,globalId:e.observation_matrix.global_id}),dt=e=>({name:e.name,numberOfObjects:e.number_of_objects,status:e.status}),pt=e=>({errorDescriptors:e.error_descriptors,errors:e.errors,objectLabel:e.object.object_label,objectTag:e.object.object_tag,observationObjectId:e.object.observation_object_id,observationObjectType:e.object.observation_object_type,rowId:e.object.id}),vn=e=>({keywordId:e.id,definition:e.description,name:e.name}),er=e=>({languageId:e.id,name:e.english_name}),V=Y.defineStore("observationMatrix",{state:()=>({observationMatrix:void 0,citation:void 0,descriptors:[],eliminated:[],remaining:[],availableKeywords:[],availableLanguages:[]}),getters:{getCitation:e=>e.citation,getObservationMatrix:e=>e.observationMatrix,getDescriptors:e=>e.descriptors,getDescriptorById:e=>t=>e.descriptors.find(r=>r.descriptorId===t),getDescriptorsUsed:e=>e.descriptors.filter(t=>t.status===X.Used),getDescriptorsUseless:e=>e.descriptors.filter(t=>t.status===X.Useless),getDescriptorsUseful:e=>e.descriptors.filter(t=>t.status===X.Useful),getEliminated:e=>e.eliminated,getKeywords:e=>e.availableKeywords,getLanguages:e=>e.availableLanguages,getRemaining:e=>e.remaining},actions:{setDescriptors(e){this.descriptors=e},setEliminated(e){this.eliminated=e},setRemaining(e){this.remaining=e},setLanguages(e){this.availableLanguages=e},setKeywords(e){this.availableKeywords=e},setObservationMatrix(e){this.observationMatrix=e},async requestInteractiveKey({observationMatrixId:e,params:t={},opt:r={}}){const o=await zn.key(e,{params:t}),{data:s}=o;return r.refreshOnlyTaxa||(this.setObservationMatrix(Zn(s)),this.setDescriptors(s.list_of_descriptors.map(i=>Yn(i))),this.setKeywords(s.descriptor_available_keywords.map(i=>vn(i))),this.setLanguages(s.descriptor_available_languages.map(i=>er(i)))),this.setEliminated(s.eliminated.map(i=>pt(i))),this.setRemaining(s.remaining.map(i=>pt(i))),o}}}),B=Y.defineStore("filter",{state:()=>({descriptors:{},eliminateUnknown:void 0,rowFilter:!0,errorTolerance:void 0,identifiedToRank:void 0,keywordIds:[],languageId:void 0,rowIds:[],sorting:void 0}),getters:{getKeywordIds:e=>e.keywordIds,getLanguageId:e=>e.languageId,getRowIds:e=>e.rowIds,getRowFilter:e=>e.rowFilter,getDescriptors:e=>e.descriptors,getIdentifiedToRank:e=>e.identifiedToRank,getEliminateUknown:e=>e.eliminateUnknown,getErrorTolerance:e=>e.errorTolerance,getSorting:e=>e.sorting,getDescriptorValueById:e=>t=>{const r=e.descriptors[t];return typeof r=="boolean"?r:r||""},getFilterParams:e=>({selected_descriptors:Object.entries(e.descriptors).map(([r,o])=>Array.isArray(o)?`${r}:${o.join("|")}`:`${r}:${o}`).join("||"),language_id:e.languageId,keyword_ids:e.keywordIds,sorting:e.sorting,identified_to_rank:e.identifiedToRank,error_tolerance:e.errorTolerance,eliminate_unknown:e.eliminateUnknown,row_filter:e.rowFilter?e.rowIds.join("|"):[]})},actions:{setDescriptor({descriptorId:e,value:t}){this.descriptors[e]=t},removeDescriptor(e){delete this.descriptors[e]},removeKeywordId(e){const t=this.keywordIds.findIndex(r=>r===e);t>-1&&this.keywordIds.splice(t,1)},addKeywordId(e){this.keywordIds.push(e)},setLanguageId(e){this.languageId=e},setErrorTolerance(e){this.errorTolerance=e},setEliminateUnknown(e){this.eliminateUnknown=e}}}),F=Y.defineStore("settings",{state:()=>({gridLayout:"distinguish-layout-mode-1",isLoading:!1,isRefreshing:!1,refreshOnlyTaxa:!1,shouldUpdate:!0,observationMatrixId:void 0,errorMessage:"",apiConfig:{baseURL:"",projectId:void 0,projectToken:void 0,userToken:void 0}}),getters:{getErrorMessage:e=>e.errorMessage,getIsLoading:e=>e.isLoading,getLayout:e=>e.gridLayout,getRefreshOnlyTaxa:e=>e.refreshOnlyTaxa,getShouldUpdate:e=>e.shouldUpdate,getObservationMatrixId:e=>e.observationMatrixId,getAPIConfig:e=>e.apiConfig},actions:{setObservationMatrixId(e){this.observationMatrixId=e},setShouldUpdate(e){this.shouldUpdate=e},setRefreshOnlyTaxa(e){this.refreshOnlyTaxa=e},setAPIConfig(e){this.apiConfig=e},checkUpdate(){const e=B(),t=V(),r=this.observationMatrixId;this.shouldUpdate&&r&&(this.isLoading=!0,t.requestInteractiveKey({observationMatrixId:r,params:e.getFilterParams,opt:{refreshOnlyTaxa:this.refreshOnlyTaxa}}).then(o=>this.errorMessage="").catch(o=>this.errorMessage=o.message).finally(()=>this.isLoading=!1))}}}),tr=n.defineComponent({__name:"FilterEliminateUnknowns",setup(e){const t=B(),r=n.computed({get:()=>!!t.getEliminateUknown,set:o=>{t.setEliminateUnknown(o)}});return(o,s)=>(n.openBlock(),n.createElementBlock("label",null,[n.withDirectives(n.createElementVNode("input",{"onUpdate:modelValue":s[0]||(s[0]=i=>r.value=i),type:"checkbox"},null,512),[[n.vModelCheckbox,r.value]]),s[1]||(s[1]=n.createTextVNode(" Eliminate unknowns "))]))}}),nr=["value"],rr=n.defineComponent({__name:"FilterErrorTolerance",setup(e){const t=[0,1,2],r=B(),o=n.computed({get:()=>r.getErrorTolerance,set:s=>{r.setErrorTolerance(s)}});return(s,i)=>(n.openBlock(),n.createElementBlock("div",null,[i[2]||(i[2]=n.createElementVNode("label",{for:"languages",class:"distinguish-input-label"}," Error tolerance ",-1)),n.withDirectives(n.createElementVNode("select",{"onUpdate:modelValue":i[0]||(i[0]=a=>o.value=a),name:"languages",role:"listbox"},[i[1]||(i[1]=n.createElementVNode("option",{value:""},null,-1)),(n.openBlock(),n.createElementBlock(n.Fragment,null,n.renderList(t,a=>n.createElementVNode("option",{key:a,value:a},n.toDisplayString(a),9,nr)),64))],512),[[n.vModelSelect,o.value]])]))}}),or=["otu","subspecies","species","subgenus","genus","subtribe","tribe","subfamily","family"],sr=n.defineComponent({__name:"FilterRank",setup(e){const t=B(),r=n.computed({get(){return t.getIdentifiedToRank},set(o){t.$patch({identifiedToRank:o})}});return(o,s)=>(n.openBlock(),n.createElementBlock("div",null,[s[2]||(s[2]=n.createElementVNode("label",{class:"distinguish-input-label"},"Identified to rank",-1)),n.withDirectives(n.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=i=>r.value=i)},[s[1]||(s[1]=n.createElementVNode("option",{value:void 0},null,-1)),(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(or),i=>(n.openBlock(),n.createElementBlock("option",{key:i},n.toDisplayString(i),1))),128))],512),[[n.vModelSelect,r.value]])]))}}),ir=n.defineComponent({__name:"FilterSort",setup(e){const t=["ordered","weighted","optimized"],r=B(),o=n.computed({get(){return r.getSorting},set(s){r.$patch({sorting:s})}});return(s,i)=>(n.openBlock(),n.createElementBlock("div",null,[i[2]||(i[2]=n.createElementVNode("label",{class:"distinguish-input-label"},"Descriptor sorting",-1)),n.withDirectives(n.createElementVNode("select",{"onUpdate:modelValue":i[0]||(i[0]=a=>o.value=a)},[i[1]||(i[1]=n.createElementVNode("option",{value:void 0},null,-1)),(n.openBlock(),n.createElementBlock(n.Fragment,null,n.renderList(t,a=>n.createElementVNode("option",{key:a},n.toDisplayString(a),1)),64))],512),[[n.vModelSelect,o.value]])]))}}),ar=["value"],lr=n.defineComponent({__name:"FilterLanguage",setup(e){const t=B(),r=V(),o=n.computed({get:()=>t.getLanguageId,set:s=>{t.setLanguageId(Number(s))}});return(s,i)=>(n.openBlock(),n.createElementBlock("div",null,[i[1]||(i[1]=n.createElementVNode("label",{for:"languages",class:"distinguish-input-label"}," Languages ",-1)),n.withDirectives(n.createElementVNode("select",{"onUpdate:modelValue":i[0]||(i[0]=a=>o.value=a),name:"languages",role:"listbox"},[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(r).getLanguages,({languageId:a,name:l})=>(n.openBlock(),n.createElementBlock("option",{key:a,value:a},n.toDisplayString(l),9,ar))),128))],512),[[n.vModelSelect,o.value]])]))}}),cr=["disabled"],H=n.defineComponent({__name:"VBtn",props:{color:{default:"primary"},size:{default:"medium"},disabled:{type:Boolean}},setup(e){const t=e,r=n.computed(()=>[`distinguish-btn-${t.color}-color`,`distinguish-btn-${t.size}-size`]);return(o,s)=>(n.openBlock(),n.createElementBlock("button",{type:"button",class:n.normalizeClass(["distinguish-btn",r.value]),disabled:o.disabled},[n.renderSlot(o.$slots,"default")],10,cr))}}),dr={class:"distinguish-modal-wrapper"},pr={class:"distinguish-modal-header"},ur={class:"distinguish-modal-body"},fr={class:"distinguish-modal-footer"},Be=n.defineComponent({__name:"VModal",props:{containerClass:{},containerStyle:{}},emits:["close"],setup(e,{emit:t}){const r=t,o=s=>{s.preventDefault(),s.key==="Escape"&&r("close")};return n.onMounted(()=>document.addEventListener("keydown",o)),n.onUnmounted(()=>document.removeEventListener("keydown",o)),(s,i)=>(n.openBlock(),n.createBlock(n.Transition,{name:"distinguish-modal"},{default:n.withCtx(()=>[n.createElementVNode("div",{class:"distinguish-modal-mask",onClick:i[2]||(i[2]=a=>r("close")),onKey:i[3]||(i[3]=a=>r("close"))},[n.createElementVNode("div",dr,[n.createElementVNode("div",{class:n.normalizeClass(["distinguish-modal-container",s.containerClass]),style:n.normalizeStyle({...s.containerStyle}),onClick:i[1]||(i[1]=n.withModifiers(()=>{},["stop"]))},[n.createElementVNode("div",pr,[n.createElementVNode("div",{class:"distinguish-modal-close",onClick:i[0]||(i[0]=a=>r("close"))}),n.renderSlot(s.$slots,"header")]),n.createElementVNode("div",ur,[n.renderSlot(s.$slots,"body")]),n.createElementVNode("div",fr,[n.renderSlot(s.$slots,"footer")])],6)])],32)]),_:3}))}}),mr={class:"distinguish-list-checkboxes"},hr=["value"],gr=n.defineComponent({__name:"FilterKeywords",setup(e){const t=V(),r=B(),o=n.ref(!1),s=n.computed({get:()=>r.getKeywordIds,set:i=>{r.$patch({keywordIds:i})}});return(i,a)=>(n.openBlock(),n.createElementBlock(n.Fragment,null,[n.createVNode(H,{color:"primary",size:"medium",disabled:!n.unref(t).getKeywords.length,title:n.unref(t).getKeywords.length?"":"No tags defined.",onClick:a[0]||(a[0]=l=>o.value=!0)},{default:n.withCtx(()=>a[3]||(a[3]=[n.createTextVNode(" Keyword ")])),_:1},8,["disabled","title"]),o.value?(n.openBlock(),n.createBlock(Be,{key:0,onClose:a[2]||(a[2]=l=>o.value=!1)},{header:n.withCtx(()=>a[4]||(a[4]=[n.createElementVNode("h3",null,"Keywords",-1)])),body:n.withCtx(()=>[n.createElementVNode("ul",mr,[(n.openBlock(!0),n.createElementBlock(n.Fragment,null,n.renderList(n.unref(t).getKeywords,({keywordId:l,name:u})=>(n.openBlock(),n.createElementBlock("li",{key:l},[n.createElementVNode("label",null,[n.withDirectives(n.createElementVNode("input",{"onUpdate:modelValue":a[1]||(a[1]=d=>s.value=d),value:l,type:"checkbox"},null,8,hr),[[n.vModelCheckbox,s.value]]),n.createTextVNode(" "+n.toDisplayString(u),1)])]))),128))])]),_:1})):n.createCommentVNode("",!0)],64))}}),yr=n.defineComponent({__name:"SettingRefresh",setup(e){const t=F(),r=n.computed({get:()=>t.getRefreshOnlyTaxa,set:o=>{t.setRefreshOnlyTaxa(o)}});return(o,s)=>(n.openBlock(),n.createElementBlock("label",null,[n.withDirectives(n.createElementVNode("input",{"onUpdate:modelValue":s[0]||(s[0]=i=>r.value=i),type:"checkbox"},null,512),[[n.vModelCheckbox,r.value]]),s[1]||(s[1]=n.createTextVNode(" Refresh only taxa "))]))}}),ce=(e,t)=>{const r=e.__vccOpts||e;for(const[o,s]of t)r[o]=s;return r},br={},_r={class:"distinguish-menu-list"};function kr(e,t){return n.openBlock(),n.createElementBlock("ul",_r,[n.renderSlot(e.$slots,"default")])}const wr=ce(br,[["render",kr]]),Er={},Sr={class:"distinguish-list-item"};function Br(e,t){return n.openBlock(),n.createElementBlock("li",Sr,[n.renderSlot(e.$slots,"default")])}const P=ce(Er,[["render",Br]]),ut={"distinguish-layout-mode-1":"distinguish-layout-mode-2","distinguish-layout-mode-2":"distinguish-layout-mode-1"},Cr={},Nr={class:"distinguish-grid"};function Rr(e,t){return n.openBlock(),n.createElementBlock("div",Nr,[n.renderSlot(e.$slots,"default")])}const ft=ce(Cr,[["render",Rr]]),xr=n.defineComponent({__name:"GridToggle",setup(e){const t=F(),r=n.computed(()=>t.getLayout),o=()=>{t.$patch({gridLayout:ut[r.value]})};return(s,i)=>(n.openBlock(),n.createBlock(H,{class:n.normalizeClass(n.unref(ut)[r.value]),onClick:o},{default:n.withCtx(()=>[n.createVNode(ft,{class:"distinguish-grid-icon"},{default:n.withCtx(()=>i[0]||(i[0]=[n.createElementVNode("div",{class:"distinguish-panel-descriptors"},null,-1),n.createElementVNode("div",{class:"distinguish-panel-remaining"},null,-1),n.createElementVNode("div",{class:"distinguish-panel-eliminated"},null,-1)])),_:1})]),_:1},8,["class"]))}}),Tr=n.defineComponent({__name:"ResetButton",setup(e){const t=B();return(r,o)=>(n.openBlock(),n.createBlock(H,{color:"primary",size:"medium",onClick:o[0]||(o[0]=s=>n.unref(t).$reset())},{default:n.withCtx(()=>o[1]||(o[1]=[n.createTextVNode(" Reset ")])),_:1}))}}),Or={class:"distinguish-header-error-message"},Dr=n.defineComponent({__name:"ErrorMessage",setup(e){const t=F();return(r,o)=>(n.openBlock(),n.createElementBlock("span",Or,n.toDisplayString(n.unref(t).getErrorMessage),1))}}),Vr={class:"distinguish-header-bar"},Ar={class:"distinguish-header-bar__buttons"},Ir=n.defineComponent({__name:"HeaderBar",setup(e){return(t,r)=>(n.openBlock(),n.createElementBlock("div",Vr,[n.createVNode(Dr),n.createVNode(wr,null,{default:n.withCtx(()=>[n.createVNode(P,null,{default:n.withCtx(()=>[n.createVNode(yr)]),_:1}),n.createVNode(P,null,{default:n.withCtx(()=>[n.createVNode(tr)]),_:1}),n.createVNode(P,null,{default:n.withCtx(()=>[n.createVNode(rr)]),_:1}),n.createVNode(P,null,{default:n.withCtx(()=>[n.createVNode(sr)]),_:1}),n.createVNode(P,null,{default:n.withCtx(()=>[n.createVNode(lr)]),_:1})