@kit-data-manager/pid-component
Version:
The PID-Component is a web component that can be used to evaluate and display FAIR Digital Objects, PIDs, ORCiDs, and possibly other identifiers in a user-friendly way. It is easily extensible to support other identifier types.
18 lines • 65.4 kB
JavaScript
/*!
*
* Copyright 2024-2026 Karlsruhe Institute of Technology.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import{h as t}from"./p-BeCqCMz1.js";import"./json-viewer.entry.esm.js";class e{constructor(t,e){this._isDarkMode=false;this._settings=[];this._items=[];this._actions=[];this._value=t;this._settings=e?e:[];this.updateDarkMode()}get isDarkMode(){return this._isDarkMode}get settings(){return this._settings}set settings(t){this._settings=t;this.updateDarkMode()}get items(){return this._items}get actions(){return this._actions}get value(){return this._value}get data(){return undefined}isResolvable(){return true}renderBody(){return undefined}updateDarkMode(){var t;const e=(t=this._settings)===null||t===void 0?void 0:t.find((t=>t.name==="darkMode"));if(e){const t=e.value;if(t==="dark"){this._isDarkMode=true}else if(t==="light"){this._isDarkMode=false}else if(t==="system"&&typeof window!=="undefined"&&window.matchMedia){this._isDarkMode=window.matchMedia("(prefers-color-scheme: dark)").matches}}else{this._isDarkMode=false}}}let i;async function s(){if("caches"in self){i=await caches.open("pid-component")}}async function n(t,e){await s();if(i){const s=await i.match(t);if(s){return s.json()}else{let s;try{const i=t.split("://");if(i.length>1&&i[0]!=="https"){s=await fetch(`https://${i[1]}`,e);if(!s){console.log(`404 for https://${i[1]} - trying http://${i[1]}`);s=await fetch(`http://${i[1]}`,e)}}else{s=await fetch(t,e)}}catch(t){console.error("Fetch failed:",t);throw t}await i.put(t,s.clone());return s.json()}}else{const i=await fetch(t,e);return i.json()}}async function r(){if(i){await i.delete("pid-component")}}class o{constructor(t,e,i,s,n,r,o,a,h,l,c){this._orcid=t;this._familyName=i;this._givenNames=s;this._employments=n;this._preferredLocale=r;this._biography=o;this._emails=a;this._keywords=h;this._researcherUrls=l;this._country=c;this._ORCiDJSON=e}get orcid(){return this._orcid}get familyName(){return this._familyName}get givenNames(){return this._givenNames}get ORCiDJSON(){return this._ORCiDJSON}get employments(){return this._employments}get preferredLocale(){return this._preferredLocale}get biography(){return this._biography}get emails(){return this._emails}get keywords(){return this._keywords}get researcherUrls(){return this._researcherUrls}get country(){return this._country}static isORCiD(t){const e=new RegExp("^(https://orcid.org/)?[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]");return e.test(t)}static async getORCiDInfo(t){if(!o.isORCiD(t))throw new Error("Invalid input");if(t.match("^(https://orcid.org/)?[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]")!==null)t=t.replace("https://orcid.org/","");t=t.replace(/^orcid:/i,"").replace(/^https?:\/\/orcid.org\//i,"").replace(/\/+$/,"").replace(/\.+$/,"").replace(/"+/g,"").replace(/'+/g,"").replace(/\s+/g,"").replace(/,+$/,"").replace(/;+$/,"").replace(/:+$/,"").trim();const e=await n(`https://pub.orcid.org/v3.0/${t}`,{headers:{Accept:"application/json"}});let i="";let s=[];try{i=e["person"]["name"]["family-name"]["value"]}catch(t){console.debug(t)}try{s=e["person"]["name"]["given-names"]["value"]}catch(t){console.debug(t)}const r=e["activities-summary"]["employments"]["affiliation-group"];const h=[];try{for(let t=0;t<r.length;t++){const e=r[t]["summaries"][0]["employment-summary"];const i=new a(new Date,null,"","");if(e["start-date"]!==null)i.startDate=new Date(e["start-date"]["year"]["value"],e["start-date"]["month"]["value"],e["start-date"]["day"]["value"]);if(e["end-date"]!==null)i.endDate=new Date(e["end-date"]["year"]["value"],e["end-date"]["month"]["value"],e["end-date"]["day"]["value"]);i.organization=e["organization"]["name"];i.department=e["department-name"];h.push(i)}}catch(t){console.debug(t)}const l=e["preferences"]["locale"]!==null?e["preferences"]["locale"]:undefined;const c=e["person"]["biography"]!==null?e["person"]["biography"]["content"]:undefined;const u=[];if(e["person"]["emails"]["email"]!==null){for(const t of e["person"]["emails"]["email"]){u.push({email:t["email"],primary:t["primary"],verified:t["verified"]})}}const f=[];if(e["person"]["keywords"]["keyword"]!==null){for(const t of e["person"]["keywords"]["keyword"]){f.push({content:t["content"],index:t["display-index"]})}f.sort(((t,e)=>t.index-e.index))}const d=[];if(e["person"]["researcher-urls"]["researcher-url"]!==null){for(const t of e["person"]["researcher-urls"]["researcher-url"]){d.push({url:t["url"]["value"],name:t["url-name"],index:t["display-index"]})}d.sort(((t,e)=>t.index-e.index))}const p=e["person"]["addresses"]["address"].length>0?e["person"]["addresses"]["address"][0]["country"]["value"]:undefined;return new o(t,e,i,s,h,l,c,u,f,d,p)}static fromJSON(t){const e=JSON.parse(t);const i=e.employments.map((t=>a.fromJSON(t)));return new o(e.orcid,e.ORCiDJSON,e.familyName,e.givenNames,i,e.preferredLocale,e.biography,e.emails,e.keywords,e.researcherUrls,e.country)}getAffiliationsAt(t){const e=[];for(const i of this._employments){if(i.startDate<=t&&i.endDate===null)e.push(i);if(i.startDate<=t&&i.endDate!==null&&i.endDate>=t)e.push(i)}return e}getAffiliationAsString(t,e=true){if(t===undefined||t.organization===null)return undefined;else{if(e&&t.department!==null)return`${t.organization} [${t.department}]`;else return t.organization}}toObject(){return{orcid:this._orcid,ORCiDJSON:this._ORCiDJSON,familyName:this._familyName,givenNames:this._givenNames,employments:this._employments.map((t=>JSON.stringify(t.toObject()))),preferredLocale:this._preferredLocale,biography:this._biography,emails:this._emails,keywords:this._keywords,researcherUrls:this._researcherUrls,country:this._country}}}class a{constructor(t,e,i,s){this.startDate=t;this.endDate=e;this.organization=i;this.department=s}static fromJSON(t){const e=JSON.parse(t);const i=new Date(e.startDate);const s=e.endDate===null?null:new Date(e.endDate);return new a(i,s,e.organization,e.department)}toObject(){return{startDate:this.startDate,endDate:this.endDate,organization:this.organization,department:this.department}}}class h{constructor(t,e,i,s,n,r,o){this._estimatedTypePriority=0;this._priority=t;this._keyTitle=e;this._value=i;this._keyTooltip=s;this._keyLink=n;this._valueRegex=r;this._renderDynamically=o!==undefined?o:true;this._estimatedTypePriority=this._renderDynamically?0:Number.MAX_SAFE_INTEGER}get priority(){return this._priority}get keyTitle(){return this._keyTitle}get value(){return this._value}get keyTooltip(){return this._keyTooltip}get keyLink(){return this._keyLink}get valueRegex(){return this._valueRegex}get renderDynamically(){return this._renderDynamically}get estimatedTypePriority(){return this._estimatedTypePriority}isValidValue(){return this._valueRegex?this._valueRegex.test(this._value):true}equals(t){return this._keyTitle===t._keyTitle&&this._value===t._value&&this._keyTooltip===t._keyTooltip&&this._keyLink===t._keyLink&&this._renderDynamically===t._renderDynamically}}class l{constructor(t,e,i,s){this._priority=t;this._title=e;this._link=i;this._style=s}get priority(){return this._priority}get title(){return this._title}get link(){return this._link}get style(){return this._style}equals(t){return this._priority===t._priority&&this._title===t._title&&this._link===t._link&&this._style===t._style}}class c extends e{constructor(){super(...arguments);this.affiliationAt=new Date(Date.now());this.showAffiliation=true}get data(){var t,e;return JSON.stringify((e=(t=this._orcidInfo)===null||t===void 0?void 0:t.toObject())!==null&&e!==void 0?e:{})}quickCheck(){return o.isORCiD(this.value)}async hasMeaningfulInformation(){this._orcidInfo=await o.getORCiDInfo(this.value);return this._orcidInfo.ORCiDJSON!==undefined}async init(t){if(t!==undefined){this._orcidInfo=o.fromJSON(t);console.debug("reload ORCIDInfo from data",this._orcidInfo)}else{this._orcidInfo=await o.getORCiDInfo(this.value);console.debug("load ORCIDInfo from API",this._orcidInfo)}if(this.settings){for(const t of this.settings){switch(t["name"]){case"affiliationAt":this.affiliationAt=new Date(t["value"]);break;case"showAffiliation":this.showAffiliation=t["value"]===true||t["value"]==="true"||t["value"]==="1";break}}}this.items.push(new h(0,"ORCiD",this._orcidInfo.orcid,"ORCiD is a free service for researchers to distinguish themselves by creating a unique personal identifier.","https://orcid.org",undefined,false));try{const t=this._orcidInfo.givenNames;if(t){new h(2,"Given Names",this._orcidInfo.givenNames.toString(),"The given names of the person.")}}catch(t){console.log("Failed to obtain given names from ORCiD record.",t)}this.actions.push(new l(0,"Open ORCiD profile",`https://orcid.org/${this._orcidInfo.orcid}`,"primary"));try{const t=this._orcidInfo.getAffiliationsAt(new Date(Date.now()));for(const e of t){const t=this._orcidInfo.getAffiliationAsString(e);if(t!==undefined&&t.length>2)this.items.push(new h(50,"Current Affiliation",t,"The current affiliation of the person.",undefined,undefined,false))}}catch(t){console.log("Failed to obtain affiliations from ORCiD record.",t)}if(this._orcidInfo.getAffiliationsAt(this.affiliationAt)!==this._orcidInfo.getAffiliationsAt(new Date)&&this.affiliationAt.toLocaleDateString("en-US")!==(new Date).toLocaleDateString("en-US")){const t=this._orcidInfo.getAffiliationsAt(this.affiliationAt);for(const e of t){const t=this._orcidInfo.getAffiliationAsString(e);if(t!==undefined&&t.length>2)this.items.push(new h(49,"Affiliation at "+this.affiliationAt.toLocaleDateString("en-US",{year:"numeric",month:"numeric",day:"numeric"}),t,"The affiliation of the person at the given date.",undefined,undefined,false))}}if(this._orcidInfo.emails){const t=this._orcidInfo.emails.filter((t=>t.primary))[0];const e=this._orcidInfo.emails.filter((t=>!t.primary));if(t){this.items.push(new h(20,"Primary E-Mail address",t.email,"The primary e-mail address of the person."));this.actions.push(new l(0,"Send E-Mail",`mailto:${t.email}`,"secondary"))}if(e.length>0)this.items.push(new h(70,"Other E-Mail addresses",e.map((t=>t.email)).join(", "),"All other e-mail addresses of the person."));if(this._orcidInfo.preferredLocale)this.items.push(new h(25,"Preferred Language",this._orcidInfo.preferredLocale,"The preferred locale/language of the person."));for(const t of this._orcidInfo.researcherUrls){this.items.push(new h(100,t.name.length>1?t.name:"User-specified reference",t.url,"A link to a website specified by the person."))}if(this._orcidInfo.keywords.length>50)this.items.push(new h(60,"Keywords",this._orcidInfo.keywords.map((t=>t.content)).join(", "),"Keywords specified by the person.",undefined,undefined,false));if(this._orcidInfo.biography)this.items.push(new h(200,"Biography",this._orcidInfo.biography,"The biography of the person.",undefined,undefined,false));if(this._orcidInfo.country)this.items.push(new h(30,"Country",this._orcidInfo.country,"The country of the person."))}}isResolvable(){return this._orcidInfo.ORCiDJSON!==undefined}renderPreview(){return t("span",{class:`inline-flex flex-nowrap items-baseline font-mono min-w-0 max-w-full ${this.isDarkMode?"text-gray-200":""}`},t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",class:"mr-1 h-4 flex-none px-0.5 self-center"},t("style",{type:"text/css"},`.st0{fill:#A6CE39;}`,`.st1{fill:#FFFFFF;}`),t("path",{class:"st0",d:"M256,128c0,70.7-57.3,128-128,128C57.3,256,0,198.7,0,128C0,57.3,57.3,0,128,0C198.7,0,256,57.3,256,128z"}),t("g",null,t("path",{class:"st1",d:"M86.3,186.2H70.9V79.1h15.4v48.4V186.2z"}),t("path",{class:"st1",d:"M108.9,79.1h41.6c39.6,0,57,28.3,57,53.6c0,27.5-21.5,53.6-56.8,53.6h-41.8V79.1z M124.3,172.4h24.5\n c34.9,0,42.9-26.5,42.9-39.7c0-21.5-13.7-39.7-43.7-39.7h-23.7V172.4z"}),t("path",{class:"st1",d:"M88.7,56.8c0,5.5-4.5,10.1-10.1,10.1c-5.6,0-10.1-4.6-10.1-10.1c0-5.6,4.5-10.1,10.1-10.1\n C84.2,46.7,88.7,51.3,88.7,56.8z"}))),t("span",{class:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${this.isDarkMode?"text-gray-200":""}`},this._orcidInfo.familyName,", ",this._orcidInfo.givenNames," ",this.showAffiliation&&this._orcidInfo.getAffiliationsAt(new Date).length>0?`(${this._orcidInfo.getAffiliationAsString(this._orcidInfo.getAffiliationsAt(new Date)[0],false)}${this._orcidInfo.getAffiliationsAt(this.affiliationAt).length>0&&this.affiliationAt.toLocaleDateString()!==(new Date).toLocaleDateString()&&this._orcidInfo.getAffiliationsAt(this.affiliationAt)[0].organization!==this._orcidInfo.getAffiliationsAt(new Date)[0].organization?`, then: ${this._orcidInfo.getAffiliationsAt(this.affiliationAt)[0].organization}`:""})`:""))}getSettingsKey(){return"ORCIDType"}}class u extends e{constructor(){super(...arguments);this._parts=[]}get data(){var t,e;return JSON.stringify((e=(t=this._pidRecord)===null||t===void 0?void 0:t.toObject())!==null&&e!==void 0?e:{})}quickCheck(){return K.isPID(this.value)}async hasMeaningfulInformation(){const t=K.getPIDFromString(this.value);this._pidRecord=await t.resolve();return this._pidRecord.values.length>0}async init(t){if(t!==undefined){this._pidRecord=X.fromJSON(t);this._parts=await Promise.all([{text:this._pidRecord.pid.prefix,nextExists:true},{text:this._pidRecord.pid.suffix,nextExists:false}]);console.debug("reload PIDRecord from data",this._pidRecord)}else{const t=K.getPIDFromString(this.value);this._parts=[{text:t.prefix,nextExists:true},{text:t.suffix,nextExists:false}];if(!this._pidRecord){this._pidRecord=await t.resolve();console.debug("load PIDRecord from API",this._pidRecord)}else{console.debug("using cached PIDRecord")}}for(const t of this._pidRecord.values){if(t.type instanceof q){this.items.push(new h(0,t.type.name,t.data.value,t.type.description,t.type.redirectURL,t.type.regex))}}this.actions.push(new l(0,"Open in FAIR-DOscope",`https://kit-data-manager.github.io/fairdoscope/?pid=${this._pidRecord.pid.toString()}`,"primary"));this.actions.push(new l(0,"View in Handle.net registry",`https://hdl.handle.net/${this._pidRecord.pid.toString()}`,"secondary"));return}isResolvable(){return this._pidRecord.values.length>0}renderPreview(){return t("span",{class:"font-mono font-bold align-baseline"},this._parts.map((e=>t("span",null,t("color-highlight",{text:e.text}),e.nextExists?t("span",{class:`mx-0.5`},"/"):""))))}getSettingsKey(){return"HandleType"}}class f{constructor(t){this._doi=t.replace(/^https?:\/\/doi\.org\//i,"").replace(/^https?:\/\/dx\.doi\.org\//i,"").replace(/^doi:/i,"").replace(/\/+$/,"").replace(/\.+$/,"").trim()}get doi(){return this._doi}static isDOI(t){const e=t.replace(/^https?:\/\/doi\.org\//i,"").replace(/^https?:\/\/dx\.doi\.org\//i,"").replace(/^doi:/i,"");return/^10\.\d{4,9}\/[-._;()/:A-Za-z0-9]+$/.test(e)}static getDOIFromString(t){if(!f.isDOI(t))throw new Error("Invalid DOI format");return new f(t)}static fromJSON(t){const e=JSON.parse(t);return new f(e.doi)}toURL(){return`https://doi.org/${this._doi}`}toString(){return this._doi}toObject(){return{doi:this._doi}}}const d={article:"📰 Article",book:"📚 Book",chapter:"📖 Chapter",software:"💻 Software",dataset:"📊 Dataset",image:"🖼️ Image",video:"🎥 Video",audio:"🎵 Audio",presentation:"🧑🏫 Presentation",preprint:"📝 Preprint",thesis:"🎓 Thesis",report:"📋 Report",standard:"📜 Standard",workflow:"🔄 Workflow",model:"🧮 Model",paper:"📄 Paper",journal:"📰 Journal",code:"💻 Code",institution:"🏛️ Institution",conferencepaper:"🎤 Conference Paper",database:"🗄️ Database",other:"❓ Other",journalarticle:"📄 Journal Article",proceedingsarticle:"🎤 Proceedings Article",reportseries:"📋 Report Series",bookchapter:"📖 Book Chapter",monograph:"📚 Monograph",editedbook:"📚 Edited Book",reportpaper:"📋 Report Paper"};function p(t){const e=t.toLowerCase().replace("_","").replace("-","");return d[e]||t}const w=()=>t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 130 103.8",class:"h-4"},t("defs",null,t("style",null,`.cls-1{fill:#00b1e2;}`,`.cls-2{fill:#243b54;}`)),t("path",{class:"cls-1",d:"M5,73.38c.86.16,1.63.32,2.65.47,43.5,8.64,108.26-2.8,116.59-23.89,6.54-17.05-30-29.11-72.62-27.63a13.94,13.94,0,0,0-2.49.15c22.73,2.26,43.2,11.29,35,25.38C75.2,63.27,37.3,73.54,5,73.38"}),t("path",{class:"cls-2",d:"M100.27,75.53C92.72,121.3,53.18,94,43.84,62.15,30.3,29.07,42.36-13.43,76.22,11.48c-28-12.85-31,24.36-19,50.82,10,22.11,31.59,36.35,42,13.54.47-.15.86-.15,1-.31"}));const g=()=>t("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",class:"h-4",viewBox:"0 0 65.400002 95.199999"},t("style",{type:"text/css"},`.st0{fill:#3EB1C8;}`,`.st1{fill:#D8D2C4;}`,`.st2{fill:#4F5858;}`,`.st3{fill:#FFC72C;}`,`.st4{fill:#EF3340;}`),t("g",{id:"g16",transform:"translate(-69.570409,-17.62496)"},t("polygon",{class:"st0",points:"111.8,66.8 135.4,59 177.2,73.3 111.8,95.5 ",id:"polygon1",transform:"translate(-42.229591,17.32496)"}),t("polygon",{class:"st1",points:"111.8,51.2 135.4,59 177.2,44.6 153.6,36.8 ",id:"polygon2",transform:"translate(-42.229591,17.32496)"}),t("polygon",{class:"st2",points:"135.4,59 177.2,44.6 177.2,73.3 ",id:"polygon3",transform:"translate(-42.229591,17.32496)"}),t("polygon",{class:"st3",points:"177.2,29 153.6,36.8 111.8,22.5 177.2,0.3 ",id:"polygon4",transform:"translate(-42.229591,17.32496)"}),t("polygon",{class:"st4",points:"153.6,36.8 111.8,51.2 111.8,22.5 ",id:"polygon5",transform:"translate(-42.229591,17.32496)"})));class y{constructor(t,e){var i;this._doi=t;this._rawMetadata=e;this._attributes=((i=e.data)===null||i===void 0?void 0:i.attributes)||{}}get title(){const t=this._attributes.titles||[];const e=t.find((t=>{if(typeof t==="string")return true;return!t.titleType||t.titleType==="Title"}));if(typeof e==="string")return e;return(e===null||e===void 0?void 0:e.title)||""}get creators(){const t=this._attributes.creators||[];return t.map((t=>{var e,i;if(typeof t==="string"){return{name:t}}const s={name:t.name||"",givenName:t.givenName,familyName:t.familyName};if(!s.name&&t.givenName&&t.familyName){s.name=`${t.givenName} ${t.familyName}`}else if(!s.name){s.name=t.givenName||t.familyName||""}const n=(e=t.nameIdentifiers)===null||e===void 0?void 0:e.find((t=>{var e;return((e=t.nameIdentifierScheme)===null||e===void 0?void 0:e.toLowerCase())==="orcid"}));if(n===null||n===void 0?void 0:n.nameIdentifier){s.orcid=n.nameIdentifier.replace(/^https?:\/\/orcid\.org\//i,"").replace(/^orcid:/i,"")}if(t.affiliation&&t.affiliation.length>0){const e=t.affiliation[0];s.affiliation=e.name;const n=e.affiliationIdentifier;if(n&&((i=e.affiliationIdentifierScheme)===null||i===void 0?void 0:i.toLowerCase())==="ror"){s.ror=n.replace(/^https?:\/\/ror\.org\//i,"")}}return s})).filter((t=>t.name))}get correspondingAuthor(){var t,e;const i=this._attributes.contributors||[];const s=i.find((t=>{var e;return((e=t.contributorType)===null||e===void 0?void 0:e.toLowerCase())==="contactperson"}));if(!s)return undefined;const n={name:s.name||"",givenName:s.givenName,familyName:s.familyName,isCorresponding:true};if(!n.name&&s.givenName&&s.familyName){n.name=`${s.givenName} ${s.familyName}`}const r=(t=s.nameIdentifiers)===null||t===void 0?void 0:t.find((t=>{var e;return((e=t.nameIdentifierScheme)===null||e===void 0?void 0:e.toLowerCase())==="orcid"}));if(r===null||r===void 0?void 0:r.nameIdentifier){n.orcid=r.nameIdentifier.replace(/^https?:\/\/orcid\.org\//i,"").replace(/^orcid:/i,"")}if(s.affiliation&&s.affiliation.length>0){const t=s.affiliation[0];n.affiliation=t.name;const i=t.affiliationIdentifier;if(i&&((e=t.affiliationIdentifierScheme)===null||e===void 0?void 0:e.toLowerCase())==="ror"){n.ror=i.replace(/^https?:\/\/ror\.org\//i,"")}}return n}get publisher(){return this._attributes.publisher}get publicationDate(){const t=this._attributes.dates||[];const e=t.find((t=>{var e;return((e=t.dateType)===null||e===void 0?void 0:e.toLowerCase())==="issued"}));if(e===null||e===void 0?void 0:e.date)return e.date;if(this._attributes.publicationYear){return`${this._attributes.publicationYear}`}return undefined}get resourceType(){var t;return((t=this._attributes.types)===null||t===void 0?void 0:t.resourceTypeGeneral)||this._attributes.resourceTypeGeneral}get resourceTypeSpecific(){var t;return(t=this._attributes.types)===null||t===void 0?void 0:t.resourceType}get description(){const t=this._attributes.descriptions||[];const e=t.find((t=>{var e;if(typeof t==="string")return true;return((e=t.descriptionType)===null||e===void 0?void 0:e.toLowerCase())==="abstract"||!t.descriptionType}));if(typeof e==="string")return e;return e===null||e===void 0?void 0:e.description}get url(){return this._attributes.url||this._doi.toURL()}get subjects(){const t=this._attributes.subjects||[];return t.map((t=>{if(typeof t==="string")return t;return t.subject||""})).filter(Boolean)}get rawMetadata(){return this._rawMetadata}static async fetch(t){const e=`https://api.datacite.org/dois/${encodeURIComponent(t.toString())}`;try{const i=await n(e,{headers:{Accept:"application/vnd.api+json"}});if(!i||!i.data)return null;return new y(t,i)}catch(t){console.debug("DataCite API error:",t);return null}}static fromObject(t,e){return new y(t,e.rawMetadata)}generateItems(){const t=[];let e=10;if(this.title){t.push(new h(e++,"Title",this.title,"The title of the resource.",undefined,undefined,false))}const i=this.correspondingAuthor;if(i){t.push(new h(e++,"Corresponding Author",i.orcid||`${i.name}${i.affiliation?` (${i.affiliation})`:""}`,`This field indicates the first author of the resource, who is often the corresponding author.`))}const s=this.creators;s.forEach(((s,n)=>{if(n===0&&i)return;t.push(new h(e++,`Author`,s.orcid||`${s.name}${s.affiliation?` (${s.affiliation})`:""}`,"A creator/author of the resource.",s.orcid?`https://orcid.org/${s.orcid}`:undefined))}));if(this.publisher){t.push(new h(e++,"Publisher",this.publisher,"The publisher of the resource."))}if(this.publicationDate){t.push(new h(e++,"Publication Date",this.publicationDate,"The publication date in ISO 8601 format."))}if(this.resourceType){const i=this.resourceTypeSpecific||this.resourceType;t.push(new h(e++,"Resource Type",p(i),"The type of the resource."))}if(this.description){t.push(new h(e++,"Description",this.description,"The description or abstract of the resource.",undefined,undefined,false))}this.subjects.forEach((i=>{t.push(new h(e++,"Subject",i,"A subject area or keyword associated with the resource."))}));return t}toObject(){return{doi:JSON.stringify(this._doi.toObject()),rawMetadata:this._rawMetadata}}}var v;(function(t){t["APA"]="APA";t["CHICAGO"]="Chicago";t["IEEE"]="IEEE";t["HARVARD"]="Harvard";t["ANGLIA_RUSKIN"]="Anglia Ruskin"})(v||(v={}));function m(t,e,i,s=v.APA){if(!t||e.length===0){return{citation:t||"Untitled",tooltip:t||"Untitled"}}const n=e[0];const r=e.length;switch(s){case v.APA:return{citation:b(n,r,t,i),tooltip:b(n,r,t,i)};case v.CHICAGO:return{citation:C(n,r,t,i),tooltip:C(n,r,t,i)};case v.IEEE:return{citation:x(n,r,t,i),tooltip:x(n,r,t,i)};case v.HARVARD:return{citation:$(n,r,t,i),tooltip:$(n,r,t,i)};case v.ANGLIA_RUSKIN:return{citation:D(n,r,t,i),tooltip:D(n,r,t,i)};default:return{citation:b(n,r,t,i),tooltip:b(n,r,t,i)}}}function b(t,e,i,s,n){const r=t.familyName||t.name.split(" ").pop()||t.name;const o=e>1?" et al.":"";const a=s?` (${s.split("-")[0]})`:"";O(i,60);return`${r}${o}${a}. ${i}`}function C(t,e,i,s,n){const r=t.familyName||t.name.split(" ").pop()||t.name;const o=t.givenName||t.name.split(" ")[0]||"";const a=e>1?" et al.":"";const h=s?` ${s.split("-")[0]}.`:"";O(i,60);return`${r}, ${o}${a}.${h} "${i}"`}function x(t,e,i,s,n){const r=t.givenName?t.givenName.charAt(0)+".":"";const o=t.familyName||t.name.split(" ").pop()||t.name;const a=e>1?" et al.":"";O(i,60);const h=s?`, ${s.split("-")[0]}`:"";return`${r} ${o}${a}, "${i}"${h}`}function $(t,e,i,s,n){const r=t.familyName||t.name.split(" ").pop()||t.name;const o=t.givenName?t.givenName.split(" ").map((t=>t.charAt(0)+".")).join(""):"";const a=e>1?" et al.":"";const h=s?`, ${s.split("-")[0]}`:"";O(i,60);return`${r}, ${o}${a}${h}. ${i}`}function D(t,e,i,s,n){const r=(t.familyName||t.name.split(" ").pop()||t.name).toUpperCase();const o=e>1?" ET AL.":"";const a=s?` ${s.split("-")[0]}.`:"";O(i,60);return`${r}${o}${a} ${i}`}function O(t,e){if(t.length<=e)return t;const i=t.substring(0,e);const s=i.lastIndexOf(" ");if(s>e*.7){return i.substring(0,s)+"..."}return i+"..."}function S(){return v.APA}function I(t){if(!t)return S();const e=t.find((t=>t.name==="citationStyle"));if(!e)return S();const i=String(e.value).toUpperCase();switch(i){case"APA":return v.APA;case"CHICAGO":return v.CHICAGO;case"IEEE":return v.IEEE;case"HARVARD":return v.HARVARD;case"ANGLIA_RUSKIN":return v.ANGLIA_RUSKIN;default:return S()}}class k extends e{get data(){var t,e;return JSON.stringify((e=(t=this._dataCiteInfo)===null||t===void 0?void 0:t.toObject())!==null&&e!==void 0?e:{})}quickCheck(){return f.isDOI(this.value)}async hasMeaningfulInformation(){this._doi=f.getDOIFromString(this.value);this._dataCiteInfo=await y.fetch(this._doi);return this._dataCiteInfo!==null&&this._dataCiteInfo.title!==""}async init(t){if(t!==undefined){this._dataCiteInfo=y.fromObject(this._doi,JSON.parse(t))}else{this._doi=f.getDOIFromString(this.value);this._dataCiteInfo=await y.fetch(this._doi)}if(!this._dataCiteInfo)return;this.items.push(new h(0,"DOI",this._doi.toString(),"The DOI used for this resource. Digital Object Identifier is a persistent identifier for academic and research resources.","https://www.doi.org/",undefined,false));this.items.push(new h(1,"Metadata Source","DataCite","Metadata provided by DataCite","https://datacite.org"));const e=this._dataCiteInfo.generateItems();this.items.push(...e);if(this._dataCiteInfo.url){this.actions.push(new l(0,"Open Resource",this._dataCiteInfo.url,"primary"))}this.actions.push(new l(1,"Resolve DOI",this._doi.toURL(),"secondary"));this.actions.push(new l(2,"View DataCite Metadata",`https://api.datacite.org/dois/${encodeURIComponent(this._doi.toString())}`,"secondary"))}isResolvable(){return this._dataCiteInfo!==null&&this._dataCiteInfo.title!==""}renderPreview(){var e,i,s;const n=I(this.settings);const r=((e=this._dataCiteInfo)===null||e===void 0?void 0:e.creators)||[];const o=(i=this._dataCiteInfo)===null||i===void 0?void 0:i.publicationDate;const{citation:a,tooltip:h}=m(((s=this._dataCiteInfo)===null||s===void 0?void 0:s.title)||"",r,o,n);return t("span",{class:`inline-flex flex-nowrap items-baseline font-mono min-w-0 max-w-full ${this.isDarkMode?"text-gray-200":""}`},t("span",{class:"flex-none px-0.5 h-4 self-center"},w()),t("span",{class:"min-w-0 pl-2 overflow-hidden text-ellipsis whitespace-nowrap",title:h},a))}getSettingsKey(){return"DataCiteDOIType"}}class R{constructor(t,e,i="work"){this._doi=t;this._type=i;this._rawMetadata=e;if(i==="funder"){this._message={}}else{const t=e;this._message=typeof t.message==="string"?{}:t.message||{}}}get type(){return this._type}get title(){if(this._type==="funder"){const t=this._rawMetadata;const e=typeof t.message==="string"?null:t.message;return(e===null||e===void 0?void 0:e.name)||""}const t=this._message.title||[];return t[0]||""}get creators(){if(this._type==="funder")return[];const t=this._message.author||[];return t.map((t=>{const e={name:t.name||"",givenName:t.given,familyName:t.family};if(!e.name){if(t.given&&t.family){e.name=`${t.given} ${t.family}`}else{e.name=t.given||t.family||""}}if(t.ORCID){e.orcid=t.ORCID.replace(/^https?:\/\/orcid\.org\//i,"")}if(t.affiliation&&t.affiliation.length>0){e.affiliation=t.affiliation[0].name}return e})).filter((t=>t.name))}get correspondingAuthor(){if(this._type==="funder")return undefined;const t=this._message.author||[];const e=t.find((t=>t.sequence==="first"))||t[0];if(!e)return undefined;const i={name:e.name||"",givenName:e.given,familyName:e.family,isCorresponding:true};if(!i.name){if(e.given&&e.family){i.name=`${e.given} ${e.family}`}else{i.name=e.given||e.family||""}}if(e.ORCID){i.orcid=e.ORCID.replace(/^https?:\/\/orcid\.org\//i,"")}if(e.affiliation&&e.affiliation.length>0){i.affiliation=e.affiliation[0].name}return i}get publisher(){if(this._type==="funder")return undefined;return this._message.publisher}get publicationDate(){var t;if(this._type==="funder"){const t=this._rawMetadata;const e=typeof t.message==="string"?null:t.message;if(e===null||e===void 0?void 0:e.established){return`${e.established}`}return undefined}const e=this._message.issued||this._message.published||this._message.created;if(!((t=e===null||e===void 0?void 0:e["date-parts"])===null||t===void 0?void 0:t[0]))return undefined;const i=e["date-parts"][0];const s=i[0];const n=i[1];const r=i[2];if(s&&n&&r){return`${s}-${String(n).padStart(2,"0")}-${String(r).padStart(2,"0")}`}else if(s&&n){return`${s}-${String(n).padStart(2,"0")}`}else if(s){return`${s}`}return undefined}get resourceType(){if(this._type==="funder")return"Funder";return this._message.type}get description(){if(this._type==="funder")return undefined;const t=this._message.abstract;return t?this.parseJATS(t):undefined}get url(){var t,e;if(this._type==="funder"){const t=this._rawMetadata;const e=typeof t.message==="string"?null:t.message;return(e===null||e===void 0?void 0:e.url)||this._doi.toURL()}return this._message.URL||((e=(t=this._message.resource)===null||t===void 0?void 0:t.primary)===null||e===void 0?void 0:e.URL)||this._doi.toURL()}get subjects(){if(this._type==="funder"){const t=this._rawMetadata;const e=typeof t.message==="string"?null:t.message;return(e===null||e===void 0?void 0:e["alternate-name"])||[]}return this._message.subject||[]}get rawMetadata(){return this._rawMetadata}static async fetch(t){const e=await R.fetchWork(t);if(e){return new R(t,e,"work")}const i=await R.fetchFunder(t);if(i){return new R(t,i,"funder")}return null}static async fetchWork(t){try{const e=`https://api.crossref.org/works/${t.toString()}`;const i=await fetch(e);if(!i.ok){console.debug(`CrossRef works error: ${i.status}`);return null}const s=await i.json();if(s.status!=="ok"||!s.message||typeof s.message==="string"){return null}return s}catch(t){console.debug("CrossRef works fetch error:",t);return null}}static async fetchFunder(t){try{const e=`https://api.crossref.org/funders/${t.toString()}`;const i=await fetch(e);if(!i.ok){console.debug(`CrossRef funders error: ${i.status}`);return null}const s=await i.json();if(s.status!=="ok"||!s.message||typeof s.message==="string"){return null}return s}catch(t){console.debug("CrossRef funders fetch error:",t);return null}}static fromObject(t,e){return new R(t,e.rawMetadata,e.type||"work")}generateItems(){const t=[];const e=10;if(this._type==="funder"){return this.generateFunderItems(e)}return this.generateWorkItems(t,e)}generateWorkItems(t,e){if(this.title){t.push(new h(e++,"Title",this.title,"The title of the resource.",undefined,undefined,false))}const i=this.correspondingAuthor;if(i){t.push(new h(e++,"Corresponding Author",i.orcid||`${i.name}${i.affiliation?` (${i.affiliation})`:""}`,"The first author of the resource, often the corresponding author."))}const s=this.creators;s.forEach(((s,n)=>{if(n===0&&i)return;t.push(new h(e++,"Author",s.orcid||`${s.name}${s.affiliation?` (${s.affiliation})`:""}`,"A creator/author of the resource.",s.orcid?`https://orcid.org/${s.orcid}`:undefined))}));if(this.publisher){t.push(new h(e++,"Publisher",this.publisher,"The publisher of the resource."))}if(this.publicationDate){t.push(new h(e++,"Publication Date",this.publicationDate,"The publication date in ISO 8601 format."))}if(this.resourceType){t.push(new h(e++,"Resource Type",p(this.resourceType),"The type of the resource."))}if(this.description){t.push(new h(e++,"Abstract",this.description,"The abstract of the resource.",undefined,undefined,false))}this.subjects.forEach((i=>{t.push(new h(e++,"Subject",i,"A subject area or keyword."))}));return t}generateFunderItems(t){const e=[];const i=this._rawMetadata;const s=typeof i.message==="string"?null:i.message;if(this.title){e.push(new h(t++,"Name",this.title,"The name of the funder.",undefined,undefined,false))}if(s===null||s===void 0?void 0:s.location){e.push(new h(t++,"Location",s.location,"The location of the funder."))}if(s===null||s===void 0?void 0:s.established){e.push(new h(t++,"Established",`${s.established}`,"The year the funder was established."))}if(s===null||s===void 0?void 0:s.id){e.push(new h(t++,"CrossRef Funder ID",s.id,"The CrossRef identifier for this funder."))}if(s===null||s===void 0?void 0:s.url){e.push(new h(t++,"Website",s.url,"The website of the funder.",s.url))}if((s===null||s===void 0?void 0:s["alternate-name"])&&s["alternate-name"].length>0){e.push(new h(t++,"Alternate Names",s["alternate-name"].join(", "),"Alternate names for the funder.",undefined,undefined,false))}if((s===null||s===void 0?void 0:s["hierarchy-names"])&&Object.keys(s["hierarchy-names"]).length>0){const i=Object.entries(s["hierarchy-names"]).map((([t,e])=>`${e} (${t})`)).join(", ");e.push(new h(t++,"Hierarchy",i,"The funder hierarchy in the CrossRef organization tree.",undefined,undefined,false))}if((s===null||s===void 0?void 0:s["replaced-by"])&&s["replaced-by"].length>0){const i=s["replaced-by"].map((t=>t.name||t.id)).filter(Boolean).join(", ");if(i){e.push(new h(t++,"Replaced By",i,"Funders that have replaced this funder."))}}if((s===null||s===void 0?void 0:s.replaces)&&s.replaces.length>0){const i=s.replaces.map((t=>t.name||t.id)).filter(Boolean).join(", ");if(i){e.push(new h(t++,"Replaces",i,"Funders that this funder replaces."))}}if((s===null||s===void 0?void 0:s.descendants)&&s.descendants.length>0){const i=s.descendants.map((t=>t.name||t.id)).filter(Boolean).join(", ");if(i){e.push(new h(t++,"Descendants",i,"Descendant funders in the hierarchy.",undefined,undefined,false))}}return e}toObject(){return{doi:JSON.stringify(this._doi.toObject()),rawMetadata:this._rawMetadata,type:this._type}}parseJATS(t){if(!t)return t;return t.replace(/<jats:p>/g,"").replace(/<\/jats:p>/g,"\n").replace(/<jats:italic>/g,"<i>").replace(/<\/jats:italic>/g,"</i>").replace(/<jats:bold>/g,"<b>").replace(/<\/jats:bold>/g,"</b>").replace(/<jats:sub>/g,"<sub>").replace(/<\/jats:sub>/g,"</sub>").replace(/<jats:sup>/g,"<sup>").replace(/<\/jats:sup>/g,"</sup>").replace(/<jats:title>/g,"<strong>").replace(/<\/jats:title>/g,"</strong>").replace(/\n\n+/g,"\n\n").trim()}}class N extends e{get data(){var t,e;return JSON.stringify((e=(t=this._crossRefInfo)===null||t===void 0?void 0:t.toObject())!==null&&e!==void 0?e:{})}quickCheck(){return f.isDOI(this.value)}async hasMeaningfulInformation(){this._doi=f.getDOIFromString(this.value);this._crossRefInfo=await R.fetch(this._doi);return this._crossRefInfo!==null&&this._crossRefInfo.title!==""}async init(t){if(t!==undefined){this._crossRefInfo=R.fromObject(this._doi,JSON.parse(t))}else{this._doi=f.getDOIFromString(this.value);this._crossRefInfo=await R.fetch(this._doi)}if(!this._crossRefInfo)return;this.items.push(new h(0,"DOI",this._doi.toString(),"The DOI used for this resource. Digital Object Identifier is a persistent identifier for academic and research resources.","https://www.doi.org/",undefined,false));const e=this._crossRefInfo.type==="funder"?"CrossRef (Funder)":"CrossRef";this.items.push(new h(1,"Metadata Source",e,"Metadata provided by CrossRef","https://www.crossref.org"));const i=this._crossRefInfo.generateItems();this.items.push(...i);if(this._crossRefInfo.url){this.actions.push(new l(0,"Open Resource",this._crossRefInfo.url,"primary"))}this.actions.push(new l(1,"Resolve DOI",this._doi.toURL(),"secondary"));const s=this._crossRefInfo.type==="funder"?`https://api.crossref.org/funders/${this._doi.toString()}`:`https://api.crossref.org/works/${this._doi.toString()}`;this.actions.push(new l(2,"View CrossRef Metadata",s,"secondary"))}isResolvable(){return this._crossRefInfo!==null&&this._crossRefInfo.title!==""}renderPreview(){var e,i,s,n,r;const o=I(this.settings);const a=((e=this._crossRefInfo)===null||e===void 0?void 0:e.creators)||[];const h=(i=this._crossRefInfo)===null||i===void 0?void 0:i.publicationDate;const l=(s=this._crossRefInfo)===null||s===void 0?void 0:s.type;let c;let u;if(l==="funder"){c=((n=this._crossRefInfo)===null||n===void 0?void 0:n.title)||"";u=`Funder: ${c}`}else{const t=m(((r=this._crossRefInfo)===null||r===void 0?void 0:r.title)||"",a,h,o);c=t.citation;u=t.tooltip}return t("span",{class:`inline-flex flex-nowrap items-baseline font-mono min-w-0 max-w-full ${this.isDarkMode?"text-gray-200":""}`},t("span",{class:"flex-none px-0.5 h-4 self-center"},g()),t("span",{class:"min-w-0 pl-2 overflow-hidden text-ellipsis whitespace-nowrap",title:u},c))}getSettingsKey(){return"CrossRefDOIType"}}class T extends e{getSettingsKey(){return"DateType"}quickCheck(){return T.FORMAT_REGEX.test(this.value)}async hasMeaningfulInformation(){return Promise.resolve(this.quickCheck())}init(){this._date=new Date(this.value);return Promise.resolve()}renderPreview(){return t("span",null,this._date.toLocaleString())}}T.FORMAT_REGEX=new RegExp("^([0-9]{4})-([0]?[1-9]|1[0-2])-([0-2][0-9]|3[0-1])(T([0-1][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9](.[0-9]*)?(Z|([+|-]([0-1][0-9]|2[0-3]):[0-5][0-9])){1}))$");class P extends e{constructor(){super(...arguments);this.relationshipTypes={parent:{title:"Parent Organization",tooltip:"Organization that this organization is part of"},child:{title:"Child Organization",tooltip:"Organization that is part of this organization"},related:{title:"Related Organization",tooltip:"Organization that is related to this organization"},predecessor:{title:"Predecessor Organization",tooltip:"Organization that preceded this organization"},successor:{title:"Successor Organization",tooltip:"Organization that succeeded this organization"}};this.contentMappings={active:"🟢 Active",inactive:"⚪️ Inactive",withdrawn:"⚠️ Withdrawn",education:"🏫 Education",funder:"💰 Funder",healthcare:"🏥 Healthcare",company:"🏢 Company",archive:"📚 Archive",nonprofit:"🎗️ Nonprofit",government:"🏛️ Government",facility:"🔬 Facility",other:"Other",unknown:"❓ Unknown"}}get data(){return this.rorData}getSettingsKey(){return"RORType"}quickCheck(){return P.FORMAT_REGEX.test(this.value)}async hasMeaningfulInformation(){const t=this.getRorId();try{const e=await fetch(`https://api.ror.org/v2/organizations/${t}`);if(!e.ok)return false;this.rorData=await e.json();return this.rorData!==undefined}catch(t){return false}}async init(){if(!this.rorData){const t=await this.hasMeaningfulInformation();if(!t){this.items.push(new h(0,"Error","No ROR data available"));return}}try{if(!this.rorData.names||this.rorData.names.length===0){this.label="Unknown";this.items.push(new h(0,"Name","Unknown","No names available for this organization"));return}else{for(const t of this.rorData.names){const e=t.types||[];if(e.includes("acronym")){this.acronym=t.value;this.items.push(new h(20,"Acronym",t.value,"Short form of the organization name"))}else if(e.includes("ror_display")){this.label=t.value;this.items.push(new h(1,"Display Name",t.value,"Name used for display purposes"))}else if(e.includes("alias")){this.items.push(new h(5,"Alias",t.value,"Alternative name for the organization"))}else if(e.includes("label")){this.items.push(new h(15,"Label",t.value,"Name in another language or script"))}}}this.items.push(new h(20,"ROR ID",this.rorData.id,"Unique identifier for the organization in the ROR registry",undefined,undefined,false));this.actions.push(new l(10,"View on ROR",this.rorData.id,"primary"));this.items.push(new h(30,"Status",this.getOptimizedContent(this.rorData.status||"unknown"),"Current status of the organization in the ROR registry"));if(!this.rorData.types||this.rorData.types.length===0){this.items.push(new h(25,"Type",this.getOptimizedContent("unknown"),"Type of organization"))}else{for(const t of this.rorData.types){this.items.push(new h(25,"Type",this.getOptimizedContent(t),"Type of organization"))}}if(this.rorData.links&&this.rorData.links.length>0){for(const t of this.rorData.links){if(t.type){this.items.push(new h(35,`Link to ${t.type}`,t.value,"External link related to the organization"))}else{this.items.push(new h(35,`Link`,t.value,"External link related to the organization"))}}}if(this.rorData.external_ids&&this.rorData.external_ids.length>0){for(const t of this.rorData.external_ids){const e=t.type;const i=t.preferred||t.all[0];this.items.push(new h(40,`External ID: ${e}`,i,`Identifier from another system: ${e}`))}}if(this.rorData.relationships&&this.rorData.relationships.length>0){for(const t of this.rorData.relationships){const e=this.relationshipTypes[t.type]||{title:t.type,tooltip:`${t.type} organization`};this.items.push(new h(90,e.title,t.id,e.tooltip))}}if(this.rorData.locations&&this.rorData.locations.length>0){for(const t of this.rorData.locations){const e=t.geonames_details;if(e.country_code){this.items.push(new h(50,"Country",e.country_code,"Country where the organization is located"))}if(e.lat&&e.lng){this.items.push(new h(55,"Coordinates",`${e.lat}, ${e.lng}`,"Geographic coordinates of the organization"));const t=`https://www.openstreetmap.org/?mlat=${e.lat}&mlon=${e.lng}&zoom=15`;this.actions.push(new l(20,"View on OpenStreetMap",t,"secondary"))}}}}catch(t){console.error("Error fetching ROR data:",t);this.items.push(new h(0,"Error",`Failed to fetch data from ROR API: ${t.message}`))}}renderPreview(){if(!this.rorData){return t("span",{class:`font-mono text-sm`},"Loading ROR: ",this.value,"...")}return t("span",{class:`inline-flex flex-nowrap items-baseline font-mono min-w-0 max-w-full`},t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 164 118",version:"1.1",class:"mr-1 h-4 flex-none px-0.5 self-center",style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinejoin:"round",strokeMiterlimit:"2"}},t("g",{transform:"matrix(0.994301,0,0,0.989352,0,0)"},t("rect",{x:"0",y:"0",width:"164.94",height:"119.27",style:{fill:"white"}})),t("g",{transform:"matrix(1,0,0,1,-0.945,-0.815)"},t("path",{d:"M68.65,4.16L56.52,22.74L44.38,4.16L68.65,4.16Z",style:{fill:"rgb(83,186,161)",fillRule:"nonzero"}}),t("path",{d:"M119.41,4.16L107.28,22.74L95.14,4.16L119.41,4.16Z",style:{fill:"rgb(83,186,161)",fillRule:"nonzero"}}),t("path",{d:"M44.38,115.47L56.52,96.88L68.65,115.47L44.38,115.47Z",style:{fill:"rgb(83,186,161)",fillRule:"nonzero"}}),t("path",{d:"M95.14,115.47L107.28,96.88L119.41,115.47L95.14,115.47Z",style:{fill:"rgb(83,186,161)",fillRule:"nonzero"}}),t("path",{d:"M145.53,63.71C149.83,62.91 153.1,61 155.33,57.99C157.57,54.98 158.68,51.32 158.68,47.03C158.68,43.47 158.06,40.51 156.83,38.13C155.6,35.75 153.93,33.86 151.84,32.45C149.75,31.05 147.31,30.04 144.53,29.44C141.75,28.84 138.81,28.54 135.72,28.54L112.16,28.54L112.16,47.37C111.97,46.82 111.77,46.28 111.55,45.74C109.92,41.79 107.64,38.42 104.71,35.64C101.78,32.86 98.32,30.72 94.3,29.23C90.29,27.74 85.9,26.99 81.14,26.99C76.38,26.99 72,27.74 67.98,29.23C63.97,30.72 60.5,32.86 57.57,35.64C54.95,38.13 52.85,41.1 51.27,44.54C51.04,42.07 50.46,39.93 49.53,38.13C48.3,35.75 46.63,33.86 44.54,32.45C42.45,31.05 40.01,30.04 37.23,29.44C34.45,28.84 31.51,28.54 28.42,28.54L4.87,28.54L4.87,89.42L18.28,89.42L18.28,65.08L24.9,65.08L37.63,89.42L53.71,89.42L38.24,63.71C42.54,62.91 45.81,61 48.04,57.99C48.14,57.85 48.23,57.7 48.33,57.56C48.31,58.03 48.3,58.5 48.3,58.98C48.3,63.85 49.12,68.27 50.75,72.22C52.38,76.17 54.66,79.54 57.59,82.32C60.51,85.1 63.98,87.24 68,88.73C72.01,90.22 76.4,90.97 81.16,90.97C85.92,90.97 90.3,90.22 94.32,88.73C98.33,87.24 101.8,85.1 104.73,82.32C107.65,79.54 109.93,76.17 111.57,72.22C111.79,71.69 111.99,71.14 112.18,70.59L112.18,89.42L125.59,89.42L125.59,65.08L132.21,65.08L144.94,89.42L161.02,89.42L145.53,63.71ZM36.39,50.81C35.67,51.73 34.77,52.4 33.68,52.83C32.59,53.26 31.37,53.52 30.03,53.6C28.68,53.69 27.41,53.73 26.2,53.73L18.29,53.73L18.29,39.89L27.06,39.89C28.26,39.89 29.5,39.98 30.76,40.15C32.02,40.32 33.14,40.65 34.11,41.14C35.08,41.63 35.89,42.33 36.52,43.25C37.15,44.17 37.47,45.4 37.47,46.95C37.47,48.6 37.11,49.89 36.39,50.81ZM98.74,66.85C97.85,69.23 96.58,71.29 94.91,73.04C93.25,74.79 91.26,76.15 88.93,77.13C86.61,78.11 84.01,78.59 81.15,78.59C78.28,78.59 75.69,78.1 73.37,77.13C71.05,76.16 69.06,74.79 67.39,73.04C65.73,71.29 64.45,69.23 63.56,66.85C62.67,64.47 62.23,61.85 62.23,58.98C62.23,56.17 62.67,53.56 63.56,51.15C64.45,48.74 65.72,46.67 67.39,44.92C69.05,43.17 71.04,41.81 73.37,40.83C75.69,39.86 78.28,39.37 81.15,39.37C84.02,39.37 86.61,39.86 88.93,40.83C91.25,41.8 93.24,43.17 94.91,44.92C96.57,46.67 97.85,48.75 98.74,51.15C99.63,53.56 100.07,56.17 100.07,58.98C100.07,61.85 99.63,64.47 98.74,66.85ZM143.68,50.81C142.96,51.73 142.06,52.4 140.97,52.83C139.88,53.26 138.66,53.52 137.32,53.6C135.97,53.69 134.7,53.73 133.49,53.73L125.58,53.73L125.58,39.89L134.35,39.89C135.55,39.89 136.79,39.98 138.05,40.15C139.31,40.32 140.43,40.65 141.4,41.14C142.37,41.63 143.18,42.33 143.81,43.25C144.44,44.17 144.76,45.4 144.76,46.95C144.76,48.6 144.4,49.89 143.68,50.81Z",style:{fill:"rgb(32,40,38)",fillRule:"nonzero"}}))),t("span",{class:`min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`},this.label,this.acronym?" ("+this.acronym+")":""))}getRorId(){return this.value.split("/").pop()||""}getOptimizedContent(t){if(this.contentMappings[t.toLowerCase()]){return this.contentMappings[t.toLowerCase()]}return t}}P.FORMAT_REGEX=new RegExp("^https?://ror.org/[0-9a-z]{9}$","i");class A extends e{constructor(){super(...arguments);this.licenseData=null;this.licenseId="";this.corsFallback=true;this.corsProxy="https://corsproxy.io/?";this.spdxBaseUrl="https://spdx.org/licenses";this.fileFormat="json";this.requestTimeout=1e4}get data(){return this.licenseData}getSettingsKey(){return"SPDXType"}quickCheck(){if(A.URL_REGEX.test(this.value))return true;if(A.ID_REGEX.test(this.value))return undefined;return false}async hasMeaningfulInformation(){const t=this.extractLicenseId();if(!t)return false;const e=this.buildLicenseApiUrl(t);const i=new AbortController;const s=setTimeout((()=>i.abort()),this.requestTimeout);try{const n=await fetch(e,{signal:i.signal});clearTimeout(s);if(!n.ok)return false;const r=await n.json();if(r&&r.licenseId){this.licenseData=r;this.licenseId=t;return true}return false}catch(t){return false}}logLicenseData(){console.log("Current license data:",{licenseId:this.licenseId,licenseData:this.licenseData,hasData:Boolean(this.licenseData&&this.licenseData.licenseId&&this.licenseData.name)})}async init(){if(!this.licenseData){const t=await this.hasMeaningfulInformation();if(!t){this.handleInitError(new Error("Failed to fetch SPDX license data"));return}}this.populateLicenseData();this.addActionButtons()}renderPreview(){if(!this.licenseData){return t("span",{class:`font-mono text-sm`},"SPDX: ",this.licenseId||this.value)}return t("span",{class:`inline-flex flex-nowrap items-baseline font-mono min-w-0 max-w-full`},t("span",{class:`font-medium min-w-0 overflow-hidden text-ellipsis whitespace-nowrap`},this.licenseData.name||this.licenseId),this.licenseData.licenseId&&t("span",{class:`flex-none pl-1 text-gray-500`},"(",this.licenseData.licenseId,")"))}extractLicenseId(){if(!this.value.includes("/")&&!this.value.includes("://")){return this.value.trim()}return this.value.replace(/^https?:\/\/spdx\.org\/licenses\//i,"").replace(/\/$/,"").replace(/\.(json|html)$/i,"")}buildLicenseApiUrl(t){const e=this.corsFallback?`${this.corsProxy}${encodeURIComponent(`${this.spdxBaseUrl}/${t}.${this.fileFormat}`)}`:`${this.spdxBaseUrl}/${t}.${this.fileFormat}`;return e}populateLicenseData(){if(!this.licenseData)return;this.items.push(new h(0,"Full Name",this.licenseData.name,"The full legal name of the license",undefined,null,false));this.items.push(new h(10,"SPDX ID",this.licenseData.licenseId,"The unique SPDX identifier for this license",undefined,null,false));this.addDeprecationInfo();this.items.push(new h(20,"OSI Approved",this.licenseData.isOsiApproved?"Yes":"No","Whether the license is approved by the Open Source Initiative","https://opensource.org/licenses/",undefined,false));this.addFsfInfo();this.addRelatedUrls()}addDeprecationInfo(){if(!this.licenseData||!this.licenseData.isDeprecatedLicenseId)return;this.items.push(new h(15,"Deprecated","Yes","This license ID has been deprecated by SPDX",undefined,null,false));if(this.licenseData.deprecatedVersion){this.items.push(new h(16,"Deprecated Since",this.licenseData.deprecatedVersion,"The SPDX version when this license was deprecated",undefined,null,false))}}addFsfInfo(){if(!this.licenseData||this.licenseData.isFsfLibre===undefined)return;this.items.push(new h(25,"FSF Free/Libre",this.licenseData.isFsfLibre?"Yes":"No",'Whether the license is considered "Free" by the Free Software Foundation',"https://www.fsf.org/licensing/",undefined,false))}addRelatedUrls(){if(!this.licenseData||!this.licenseData.seeAlso||this.licenseData.seeAlso.length===0)return;for(let t=0;t<this.licenseData.seeAlso.length;t++){const e=this.licenseData.seeAlso[t];this.items.push(new h(30+t,`Related URL`,e,"A related URL with more information about this license"))}}addActionButtons(){if(!this.licenseData)return;this.actions.push(new l(10,"View on SPDX",`https://spdx.org/licenses/${this.licenseData.licenseId}`,"primary"));if(this.licenseData.isOsiApproved){this.actions.push(new l(20,"View on OSI","https://opensource.org/licenses/","secondary"))}this.addOfficialLicenseLink()}addOfficialLicenseLink(){if(!this.licenseData||!this.licenseData.seeAlso||this.licenseData.seeAlso.length===0)return;const t=this.findOfficialUrl(this.licenseData.seeAlso)||this.licenseData.seeAlso[0];this.actions.push(new l(30,"View Official License",t,"secondary"))}findOfficialUrl(t){const e=["opensource.org","