scicat-widget 26.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scicat_widget/__init__.py +12 -0
- scicat_widget/_logging.py +9 -0
- scicat_widget/_model.py +24 -0
- scicat_widget/_scicat_api.py +68 -0
- scicat_widget/_static/assets.js +1 -0
- scicat_widget/_static/comm.js +1 -0
- scicat_widget/_static/datasetUploadWidget.css +1 -0
- scicat_widget/_static/datasetUploadWidget.js +30 -0
- scicat_widget/_static/datasetWidget.js +1 -0
- scicat_widget/_static/filesWidget.js +1 -0
- scicat_widget/_static/forms.js +1 -0
- scicat_widget/_static/inputWidgets.js +1 -0
- scicat_widget/_static/models.js +0 -0
- scicat_widget/_static/tabs.js +27 -0
- scicat_widget/_static/validation.js +1 -0
- scicat_widget/_upload.py +147 -0
- scicat_widget/_widgets.py +239 -0
- scicat_widget-26.2.0.dist-info/METADATA +76 -0
- scicat_widget-26.2.0.dist-info/RECORD +21 -0
- scicat_widget-26.2.0.dist-info/WHEEL +4 -0
- scicat_widget-26.2.0.dist-info/licenses/LICENSE +29 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Jupyter widget for uploading datasets to SciCat."""
|
|
2
|
+
|
|
3
|
+
import importlib.metadata
|
|
4
|
+
|
|
5
|
+
from ._widgets import DatasetUploadWidget, dataset_upload_widget
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
__version__ = importlib.metadata.version("scicat_widget")
|
|
9
|
+
except importlib.metadata.PackageNotFoundError:
|
|
10
|
+
__version__ = "0.0.0"
|
|
11
|
+
|
|
12
|
+
__all__ = ["DatasetUploadWidget", "dataset_upload_widget"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Copyright (c) 2026 SciCat Project (https://github.com/SciCatProject/scitacean)
|
|
3
|
+
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# TODO does not show up in Jupyter (need to configure handler)
|
|
8
|
+
def get_logger() -> logging.Logger:
|
|
9
|
+
return logging.getLogger("scicat-widget")
|
scicat_widget/_model.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Copyright (c) 2026 SciCat Project (https://github.com/SciCatProject/scitacean)
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, EmailStr
|
|
5
|
+
from scitacean.model import Instrument
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ProposalOverview(BaseModel):
|
|
9
|
+
id_: str
|
|
10
|
+
title: str
|
|
11
|
+
instrument_ids: list[str]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class UserInfo(BaseModel):
|
|
15
|
+
user_id: str
|
|
16
|
+
display_name: str | None
|
|
17
|
+
email: EmailStr | None
|
|
18
|
+
access_groups: list[str]
|
|
19
|
+
orcid_id: str | None
|
|
20
|
+
# The proposals we know the user is a member of, they may have access to more:
|
|
21
|
+
proposals: list[ProposalOverview]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
__all__ = ["Instrument", "ProposalOverview", "UserInfo"]
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Copyright (c) 2026 SciCat Project (https://github.com/SciCatProject/scitacean)
|
|
3
|
+
|
|
4
|
+
from scitacean import Client
|
|
5
|
+
|
|
6
|
+
# Not great but there is no need to reimplement this here,
|
|
7
|
+
# and handling of ORCID iDs is not part of the core functionality of Scitacean.
|
|
8
|
+
from scitacean._internal.orcid import parse_orcid_id
|
|
9
|
+
|
|
10
|
+
from ._model import Instrument, ProposalOverview, UserInfo
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_user_and_scicat_info(client: Client) -> tuple[UserInfo, list[Instrument]]:
|
|
14
|
+
user_info = get_user_info(client)
|
|
15
|
+
instruments = get_instruments(client)
|
|
16
|
+
return user_info, instruments
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_user_info(client: Client) -> UserInfo:
|
|
20
|
+
identity = client.scicat.call_endpoint(
|
|
21
|
+
cmd="GET", url="users/my/identity", operation="get_user_info"
|
|
22
|
+
)
|
|
23
|
+
profile = identity["profile"]
|
|
24
|
+
|
|
25
|
+
access_groups = sorted(profile.get("accessGroups", []))
|
|
26
|
+
proposals = get_proposals(client, access_groups) if access_groups else []
|
|
27
|
+
|
|
28
|
+
return UserInfo(
|
|
29
|
+
user_id=identity["userId"],
|
|
30
|
+
display_name=profile.get("displayName", None),
|
|
31
|
+
email=profile.get("email", None),
|
|
32
|
+
access_groups=access_groups,
|
|
33
|
+
orcid_id=_maybe_parse_orcid_id(
|
|
34
|
+
profile.get("oidcClaims", {}).get("orcid", None)
|
|
35
|
+
),
|
|
36
|
+
proposals=proposals,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_proposals(client: Client, access_groups: list[str]) -> list[ProposalOverview]:
|
|
41
|
+
proposals = client.scicat.call_endpoint(
|
|
42
|
+
cmd="GET", url="proposals", operation="get_proposals"
|
|
43
|
+
)
|
|
44
|
+
# the API call returns all proposals, select only the ones the user has access to:
|
|
45
|
+
# assuming the access groups match proposals (the case at ESS)
|
|
46
|
+
return [
|
|
47
|
+
ProposalOverview(
|
|
48
|
+
id_=p["proposalId"], title=p["title"], instrument_ids=p["instrumentIds"]
|
|
49
|
+
)
|
|
50
|
+
for p in proposals
|
|
51
|
+
if p["proposalId"] in access_groups
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def get_instruments(client: Client) -> list[Instrument]:
|
|
56
|
+
return [
|
|
57
|
+
Instrument.from_download_model(instrument)
|
|
58
|
+
for instrument in client.scicat.get_all_instrument_models()
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def _maybe_parse_orcid_id(orcid_id: str | None) -> str | None:
|
|
63
|
+
if orcid_id is None:
|
|
64
|
+
return None
|
|
65
|
+
try:
|
|
66
|
+
return parse_orcid_id(orcid_id)
|
|
67
|
+
except ValueError:
|
|
68
|
+
return None
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function n(t){return e[t]??null}export{n as fieldInfo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=class{constructor(e){this.callbacks=new Map;this.model=e,this.model.on("msg:custom",t=>{if(t.hasOwnProperty("type")){let s=t.key,r=this.callbacks.get(t.type)?.get(s);r&&r(t.payload);return}console.warn(`Unknown message type: ${t}`)})}sendReqInspectFile(e,t){this.model.send({type:"req:inspect-file",key:e,payload:t})}onResInspectFile(e,t){this.getForMethod("res:inspect-file").set(e,t)}offResInspectFile(e){this.getForMethod("res:inspect-file").delete(e)}sendReqBrowseFiles(e,t){this.model.send({type:"req:browse-files",key:e,payload:t})}onResBrowseFiles(e,t){this.getForMethod("res:browse-files").set(e,t)}offResBrowseFiles(e){this.getForMethod("res:browse-files").delete(e)}sendReqUploadDataset(e,t){this.model.send({type:"req:upload-dataset",key:e,payload:t})}onResUploadDataset(e,t){this.getForMethod("res:upload-dataset").set(e,t)}getForMethod(e){let t=this.callbacks.get(e);if(t!==void 0)return t;let s=new Map;return this.callbacks.set(e,s),s}};export{o as BackendComm};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.cean-ds-general-info{display:grid;grid-template-columns:max-content 1fr max-content 1fr;column-gap:12px;row-gap:10px;align-items:start;>*:nth-child(2n){min-width:0}& input,select,textarea{width:100%;box-sizing:border-box}>.cean-span-3{grid-column:span 3}}.cean-run-row{display:grid;grid-template-columns:1fr max-content max-content max-content max-content;column-gap:12px;row-gap:10px;align-items:start;>*:nth-child(odd){min-width:0}}.cean-ds-owner-columns{display:grid;grid-template-columns:3fr 2fr;column-gap:12px;row-gap:10px;align-items:start}.cean-ds-human-owners,.cean-ds-technical-owners{display:grid;grid-template-columns:max-content 1fr;column-gap:12px;row-gap:10px;align-items:start;>*:nth-child(2n){min-width:0}}.cean-single-owner{margin:.3em 0;display:grid;grid-template-columns:1fr max-content;column-gap:12px;row-gap:10px;align-items:start}.cean-ds-misc-columns{display:grid;grid-template-columns:3fr 2fr;column-gap:12px;row-gap:10px;align-items:start}.cean-ds-misc-left,.cean-ds-misc-right{display:grid;grid-template-columns:max-content 1fr;column-gap:12px;row-gap:10px;align-items:start;& input{width:100%;box-sizing:border-box}}table.cean-scientific-metadata-table{width:100%;border-collapse:collapse;& th:last-child,td:last-child{width:1%;white-space:nowrap;border:none;padding:0}& td:not(:last-child){border:1px solid var(--jp-border-color1);&:hover{box-shadow:inset 0 0 0 var(--jp-border-width) var(--jp-input-active-border-color)}&:focus-within{background:var(--jp-input-active-background);box-shadow:inset 0 0 0 var(--jp-border-width) var(--jp-input-active-border-color)}}& input{width:100%;border:none!important;background:unset!important;&:focus-visible{outline:none}}& button{margin:0 0 0 1rem}}label.cean-required{&:after{content:" *";color:var(--jp-error-color2)}}.cean-person-widget{display:grid;grid-template-columns:max-content 1fr;column-gap:12px;row-gap:10px;align-items:start}.cean-same-as-container{display:grid;grid-template-columns:max-content max-content 1fr;column-gap:5px;align-items:start}.cean-ds textarea{resize:vertical}.cean-datetime-input{display:grid;grid-template-columns:max-content max-content;column-gap:0;row-gap:10px;align-items:start}.cean-tab-buttons{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--jp-border-color1)}.cean-tab-buttons-left{padding:0 1em;& svg{height:1.8rem;width:auto;transform:translateY(.4em)}}.cean-tab-buttons-middle{display:flex;position:relative}.cean-tab-buttons-right{display:flex;align-items:center;padding-right:16px;margin-left:auto;& a{margin-right:1em}& a:hover{text-decoration:underline}}.cean-tab-button{background:none;border:none;padding:8px 16px;cursor:pointer;color:var(--jp-ui-font-color2)}.cean-tab-button:hover{background-color:var(--jp-layout-color2)}.cean-tab-button-active{color:var(--jp-ui-font-color1);background-color:var(--jp-layout-color1);font-weight:700;border-bottom:2px solid var(--jp-brand-color1)}.cean-tab-content{display:grid}.cean-tab-pane{grid-column:1;grid-row:1;padding:10px 0;visibility:hidden}.cean-input{background:var(--jp-cell-editor-background);color:var(--jp-content-font-color1);&::selection{background-color:var(--jp-editor-selected-focused-background)}}input.cean-input,select.cean-input,textarea.cean-input{width:100%;box-sizing:border-box;border:var(--jp-border-width) solid var(--jp-cell-editor-border-color);&:focus-visible{outline:none}&:focus{border-color:var(--jp-input-active-border-color);background-color:var(--jp-input-active-background)}&:hover:not(:disabled){border-color:var(--jp-input-active-border-color)}}input[type=checkbox].cean-input{width:auto;justify-self:start}.cean-input-status{display:none;font-size:var(--jp-ui-font-size0);min-height:1.2em;line-height:1.2em;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.cean-input[data-valid=false]{border-color:var(--jp-error-color2);~.cean-input-status{display:block;color:var(--jp-error-color2)}}.cean-file-input+.cean-input-status{display:block}.cean-input-panel{background:rgba(from var(--jp-layout-color0) r g b / .7);border:1px solid var(--jp-border-color2);border-radius:6px;padding:6px;margin:.25em .5em}.cean-upload-button{background:#27aae1;color:var(--jp-ui-inverse-font-color1);&:hover{background:#3ec2fa;box-shadow:none!important}}.cean-modal-dialog{border:1px solid var(--jp-border-color1);border-radius:var(--jp-border-radius);box-shadow:var(--jp-elevation-z8);background:var(--jp-layout-color1);color:var(--jp-ui-font-color1);padding:0;min-width:min(30%,30em);max-width:50%;width:max-content;>div{padding:1em 2em}&::backdrop{backdrop-filter:brightness(80%)}& a{color:var(--jp-content-link-color)}& a:hover{color:var(--jp-content-link-color);text-decoration:underline}}.cean-dialog-header{margin-bottom:15px;font-size:var(--jp-ui-font-size3);font-weight:400;color:var(--jp-ui-font-color1)}.cean-dialog-body{margin-bottom:20px}.cean-dialog-footer{display:flex;justify-content:flex-end;gap:10px}.cean-warning{color:var(--jp-warn-color1)}.cean-warning-severe{background:var(--jp-warn-color2);color:var(--jp-ui-inverse-font-color0);padding:.3em 0;font-variant:all-small-caps;font-size:var(--jp-ui-font-size2)}.cean-button{background:var(--jp-input-background);color:var(--jp-ui-font-color1);border-radius:var(--jp-border-radius);border:none;cursor:pointer;&:hover{background:var(--jp-input-hover-background);color:var(--jp-ui-font-color0)}&[disabled=true]{background:var(--jp-input-background);color:var(--jp-ui-font-color2);cursor:unset}&:active{box-shadow:0 0 0 1px var(--jp-input-active-border-color)}}.cean-icon-button{&:active{box-shadow:none;background:var(--jp-input-active-background)}}.cean-button i+span{margin-left:.5em}button.cean-button-remove{background:none;&:hover{color:var(--jp-error-color1);background:none}&[disabled=true]{visibility:hidden}&:active{color:var(--jp-error-color2)}}.cean-combox-dropdown{position:relative}.cean-combox-search,.cean-combox-display{display:block;width:100%;box-sizing:border-box;border:var(--jp-border-width) solid var(--jp-cell-editor-border-color);color:var(--jp-content-font-color1);padding:.1rem .5rem;min-height:1.5rem;&:focus-visible{outline:none}&:focus{border-color:var(--jp-input-active-border-color)}}.cean-combox-display{cursor:text;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cean-combox-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);cursor:default;color:var(--jp-ui-font-color2);font-size:.8rem}.cean-combox-list{position:absolute;display:none;top:100%;left:0;width:100%;box-sizing:border-box;z-index:100;border:var(--jp-border-width) solid var(--jp-input-border-color);border-top:none;background-color:var(--jp-notebook-select-background);max-height:16rem;overflow-y:scroll;overflow-x:hidden}.cean-combox-item{cursor:pointer;user-select:none;padding:.1em .5em;&:hover{background-color:var(--jp-editor-selected-background)}& span{padding-right:.5em}}.cean-combox-selected{background-color:var(--jp-layout-color2);font-weight:700}.cean-item-id{color:var(--jp-content-font-color3);font-family:monospace}.cean-file-input{display:grid;grid-template-columns:1fr max-content;& button{margin-left:1em}}.cean-browse-files-button{background:var(--jp-layout-color3);&:hover{background:var(--jp-layout-color4)}}.cean-files-widget{& input{width:100%;box-sizing:border-box}.cean-input-panel{margin-top:.5em}}.cean-files-summary{margin:0 .5em;padding:6px;font-size:.85rem;& span{margin-right:.5em}& span:nth-child(2){margin-right:2em}}.cean-single-file-widget{grid-template-columns:max-content 1fr max-content;margin:1em .5em .5em}.cean-single-file-widget,.cean-single-relationship-widget,.cean-single-owner{background:rgb(from var(--jp-layout-color2) r g b / .8);border:1px solid var(--jp-border-color2);padding:.5em}.cean-single-relationship-widget{grid-template-columns:max-content 1fr max-content;margin:.3em 0}.cean-relationships{grid-column:span 2}.cean-input-grid{display:grid;column-gap:12px;row-gap:10px;align-items:start}select.cean-chk-alg{width:10em!important}.cean-string-list-widget{display:flex;flex-direction:column;gap:8px}.cean-string-list-input-row{display:grid;column-gap:8px;grid-template-columns:1fr max-content}.cean-string-list-items{display:flex;flex-wrap:wrap;gap:4px}.cean-string-list-item{display:flex;align-items:center;background:var(--jp-layout-color2);padding:2px 8px;gap:4px;border:var(--jp-border-width) solid var(--jp-layout-color3);border-radius:var(--jp-border-radius)}.cean-string-list-item span{max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cean-string-list-item .cean-button{padding:0;background:none;min-height:unset;font-size:.8em}.cean-techniques-widget{display:flex;flex-direction:column;gap:8px}.cean-techniques-items{display:flex;flex-direction:column;gap:4px}.cean-techniques-item{display:flex;background:var(--jp-layout-color2);padding:2px 8px;border:var(--jp-border-width) solid var(--jp-layout-color3);border-radius:var(--jp-border-radius)}.cean-techniques-item-content{flex-grow:1}.cean-techniques-item .cean-button{padding:0;background:none;min-height:unset;font-size:.8em}.cean-techniques-selected-item{display:flex;flex-direction:column;.cean-item-id{color:var(--jp-content-link-color);font-family:unset}.cean-item-id:hover{color:var(--jp-content-link-color);text-decoration:underline}}.cean-output-anchor{display:none}.cean-validation-error-list{& strong{color:var(--jp-error-color2);margin-right:.5em}}.cean-spinner{width:48px;height:48px;border:2px solid var(--jp-ui-font-color0);border-radius:50%;display:inline-block;position:relative;box-sizing:border-box;&:after{content:"";box-sizing:border-box;position:absolute;left:0;top:0;width:44px;height:44px;border-radius:50%;border:4px solid transparent;border-bottom-color:#ed6c6b;animation:cean-rotation 1.5s linear infinite}&:before{content:"";box-sizing:border-box;position:absolute;left:-6px;top:-6px;width:56px;height:56px;border-radius:50%;border:4px solid transparent;border-bottom-color:#58caed;animation:cean-rotation 2s linear infinite}}@keyframes cean-rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var je=Object.create;var ye=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var E=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var ze=(a,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Be(t))!Ue.call(a,i)&&i!==e&&ye(a,i,{get:()=>t[i],enumerable:!(n=qe(t,i))||n.enumerable});return a};var $e=(a,t,e)=>(e=a!=null?je(Oe(a)):{},ze(t||!a||!a.__esModule?ye(e,"default",{value:a,enumerable:!0}):e,a));var H=E((P,re)=>{"use strict";Object.defineProperty(P,"__esModule",{value:!0});P.default=Xe;function Xe(a){if(a==null)throw new TypeError("Expected a string but received a ".concat(a));if(a.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(a.constructor.name))}re.exports=P.default;re.exports.default=P.default});var Ce=E((A,se)=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.default=Je;function Ze(a){return Object.prototype.toString.call(a)==="[object RegExp]"}function Je(a,t){for(var e=0;e<t.length;e++){var n=t[e];if(a===n||Ze(n)&&n.test(a))return!0}return!1}se.exports=A.default;se.exports.default=A.default});var Le=E((j,le)=>{"use strict";Object.defineProperty(j,"__esModule",{value:!0});j.default=nt;var et=tt(H());function tt(a){return a&&a.__esModule?a:{default:a}}function oe(a){"@babel/helpers - typeof";return oe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},oe(a)}function nt(a,t){(0,et.default)(a);var e,n;oe(t)==="object"?(e=t.min||0,n=t.max):(e=arguments[1],n=arguments[2]);var i=encodeURI(a).split(/%..|./).length-1;return i>=e&&(typeof n>"u"||i<=n)}le.exports=j.default;le.exports.default=j.default});var ce=E((q,de)=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.default=it;function it(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var e in t)typeof a[e]>"u"&&(a[e]=t[e]);return a}de.exports=q.default;de.exports.default=q.default});var Te=E((B,ue)=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.default=ot;var at=ke(H()),rt=ke(ce());function ke(a){return a&&a.__esModule?a:{default:a}}var st={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function ot(a,t){(0,at.default)(a),t=(0,rt.default)(t,st),t.allow_trailing_dot&&a[a.length-1]==="."&&(a=a.substring(0,a.length-1)),t.allow_wildcard===!0&&a.indexOf("*.")===0&&(a=a.substring(2));var e=a.split("."),n=e[e.length-1];return t.require_tld&&(e.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(n)||/\s/.test(n))||!t.allow_numeric_tld&&/^\d+$/.test(n)?!1:e.every(function(i){return!(i.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(i)||/[\uff01-\uff5e]/.test(i)||/^-|-$/.test(i)||!t.allow_underscores&&/_/.test(i))})}ue.exports=B.default;ue.exports.default=B.default});var Me=E((O,he)=>{"use strict";Object.defineProperty(O,"__esModule",{value:!0});O.default=me;var lt=dt(H());function dt(a){return a&&a.__esModule?a:{default:a}}function pe(a){"@babel/helpers - typeof";return pe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},pe(a)}var _e="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",w="(".concat(_e,"[.]){3}").concat(_e),ct=new RegExp("^".concat(w,"$")),m="(?:[0-9a-fA-F]{1,4})",ut=new RegExp("^("+"(?:".concat(m,":){7}(?:").concat(m,"|:)|")+"(?:".concat(m,":){6}(?:").concat(w,"|:").concat(m,"|:)|")+"(?:".concat(m,":){5}(?::").concat(w,"|(:").concat(m,"){1,2}|:)|")+"(?:".concat(m,":){4}(?:(:").concat(m,"){0,1}:").concat(w,"|(:").concat(m,"){1,3}|:)|")+"(?:".concat(m,":){3}(?:(:").concat(m,"){0,2}:").concat(w,"|(:").concat(m,"){1,4}|:)|")+"(?:".concat(m,":){2}(?:(:").concat(m,"){0,3}:").concat(w,"|(:").concat(m,"){1,5}|:)|")+"(?:".concat(m,":){1}(?:(:").concat(m,"){0,4}:").concat(w,"|(:").concat(m,"){1,6}|:)|")+"(?::((?::".concat(m,"){0,5}:").concat(w,"|(?::").concat(m,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function me(a){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,lt.default)(a);var e=(pe(t)==="object"?t.version:arguments[1])||"";return e?e.toString()==="4"?ct.test(a):e.toString()==="6"?ut.test(a):!1:me(a,{version:4})||me(a,{version:6})}he.exports=O.default;he.exports.default=O.default});var Fe=E((U,fe)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.default=Ct;var pt=W(H()),We=W(Ce()),ge=W(Le()),mt=W(Te()),De=W(Me()),ht=W(ce());function W(a){return a&&a.__esModule?a:{default:a}}var gt={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},ft=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,vt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,bt=/^[a-z\d]+$/,yt=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,wt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,xt=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,Et=254;function It(a){var t=a.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var e=/[\.";<>]/.test(t);if(e){if(t===a)return!1;var n=t.split('"').length===t.split('\\"').length;if(!n)return!1}return!0}function Ct(a,t){if((0,pt.default)(a),t=(0,ht.default)(t,gt),t.require_display_name||t.allow_display_name){var e=a.match(ft);if(e){var n=e[1];if(a=a.replace(n,"").replace(/(^<|>$)/g,""),n.endsWith(" ")&&(n=n.slice(0,-1)),!It(n))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&a.length>Et)return!1;var i=a.split("@"),r=i.pop(),s=r.toLowerCase();if(t.host_blacklist.length>0&&(0,We.default)(s,t.host_blacklist)||t.host_whitelist.length>0&&!(0,We.default)(s,t.host_whitelist))return!1;var o=i.join("@");if(t.domain_specific_validation&&(s==="gmail.com"||s==="googlemail.com")){o=o.toLowerCase();var l=o.split("+")[0];if(!(0,ge.default)(l.replace(/\./g,""),{min:6,max:30}))return!1;for(var d=l.split("."),u=0;u<d.length;u++)if(!bt.test(d[u]))return!1}if(t.ignore_max_length===!1&&(!(0,ge.default)(o,{max:64})||!(0,ge.default)(r,{max:254})))return!1;if(!(0,mt.default)(r,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,De.default)(r)){if(!r.startsWith("[")||!r.endsWith("]"))return!1;var x=r.slice(1,-1);if(x.length===0||!(0,De.default)(x))return!1}}if(t.blacklisted_chars&&o.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1;if(o[0]==='"'&&o[o.length-1]==='"')return o=o.slice(1,o.length-1),t.allow_utf8_local_part?xt.test(o):yt.test(o);for(var D=t.allow_utf8_local_part?wt:vt,Y=o.split("."),T=0;T<Y.length;T++)if(!D.test(Y[T]))return!1;return!0}fe.exports=U.default;fe.exports.default=U.default});var c=class{constructor(t,e,n=!1,i){this.key=t,this.required=n,this.inputElement_=e,this.inputElement_.id=crypto.randomUUID(),e.addEventListener("input",()=>this.rawUpdate()),[this.container_,this.statusElement]=Ne(e),this.validator=Ve(n,i)}inputElement(){return this.inputElement_}get container(){return this.container_}get id(){return this.inputElement_.id}updated(){this.validate()&&this.container.dispatchEvent(new ae(this.key,this.value,{bubbles:!0}))}rawUpdate(){this.validate()}validate(){let t=this.validator(this.value);return t!==null?(this.statusElement.textContent=t,this.inputElement_.dataset.valid="false",!1):(this.inputElement_.dataset.valid="true",!0)}listenToWidget(t,e,n=document){let i=this.inputUpdatedListener(t,e);n.addEventListener("input-updated",i),n.addEventListener("input-updated",this.inputUpdatedListener(this.key,()=>n.removeEventListener("input-updated",i)))}inputUpdatedListener(t,e){return n=>{let i=n;i.key===t&&e(this,i.value_as())}}};function Ne(a){a.classList.add("cean-input");let t=document.createElement("div");t.classList.add("cean-input-status");let e=document.createElement("div");return e.classList.add("cean-input-container"),e.replaceChildren(a,t),[e,t]}var ae=class extends Event{#e;#t;constructor(t,e,n){super("input-updated",n),this.#e=t,this.#t=e}get key(){return this.#e}get value(){return this.#t}value_as(){return this.value}};function Ve(a,t){let e="Required";return a&&t?n=>n==null?e:t(n):t?n=>n==null?null:t(n):a?n=>n==null?e:null:()=>null}var we={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function xe(a){return we[a]??null}function g(a){let t=document.createElement(a);return t.id=crypto.randomUUID(),t}function Ke(a,t){let e=document.createElement("label");return e.textContent=t,e.setAttribute("for",a),e}function h(a,t,e,n){let i=new t(a,...e??[]),r=xe(a),s=Ke(i.id,n??(r===null?a:r.label));return s.title=r?.description??"",i.required&&s.classList.add("cean-required"),[s,i]}var I=class extends c{constructor(t){let e=g("input");e.type="checkbox",e.addEventListener("blur",()=>this.updated(),!0),e.addEventListener("keydown",n=>{n.key==="Enter"&&this.updated()}),super(t,e)}get value(){return this.inputElement().checked}set value(t){this.inputElement().checked=!!t}};var f=class extends c{constructor(e,{choices:n,renderChoice:i,allowArbitrary:r=!0,filter:s=!0,required:o=!1}){let l=document.createElement("div");l.classList.add("cean-combox-dropdown");super(e,l,o);this._value=null;this.isFocused=!1;this.isMouseDownInside=!1;this.choices=n,this.renderChoice=i,this.allowArbitrary=r,this.filter=s,this.searchInput=document.createElement("input"),this.searchInput.id=crypto.randomUUID(),this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.classList.add("cean-combox-search","cean-input"),this.searchInput.style.display="none",l.appendChild(this.searchInput),this.displayElement=document.createElement("div"),this.displayElement.classList.add("cean-combox-display","cean-input"),l.appendChild(this.displayElement),this.showPlaceholder();let d=document.createElement("i");d.className="fa fa-chevron-down cean-combox-arrow",l.appendChild(d),d.addEventListener("click",u=>{u.stopPropagation(),this.enterEditMode()}),this.dropdownList=document.createElement("div"),this.dropdownList.classList.add("cean-combox-list"),this.dropdownList.style.display="none",l.appendChild(this.dropdownList),this.renderChoices(),this.container.addEventListener("mousedown",()=>{this.isMouseDownInside=!0}),document.addEventListener("mouseup",()=>{this.isMouseDownInside=!1}),this.displayElement.addEventListener("click",()=>{this.enterEditMode()}),this.searchInput.addEventListener("focus",()=>{this.isFocused=!0,this.openDropdown(),this.searchInput.select()}),this.searchInput.addEventListener("input",()=>{this.filterItems(),this.openDropdown()}),this.searchInput.addEventListener("keydown",u=>{u.key==="Enter"?(u.preventDefault(),this.selectFromSearch(),this.closeDropdown()):u.key=="Escape"&&(u.preventDefault(),this.closeDropdown())}),this.searchInput.addEventListener("blur",()=>{if(this.isFocused=!1,this.isMouseDownInside){this.searchInput.focus();return}this.selectFromSearch(),this.closeDropdown(),this.updateDisplay()}),document.addEventListener("click",u=>{this.container.contains(u.target)||this.closeDropdown()})}get value(){return this._value}set value(e){if(this._value!==e){if(this._value=e,e===null)this.searchInput.value="";else{let n=this.findChoice(e);n?this.searchInput.value=n.text:this.searchInput.value=e}this.updateDisplay()}}get id(){return this.searchInput.id}enterEditMode(){this.isFocused=!0,this.updateDisplay(),this.searchInput.focus()}updateDisplay(){if(this.isFocused||this._value===null&&this.allowArbitrary)this.searchInput.style.display="block",this.displayElement.style.display="none";else{if(this.searchInput.style.display="none",this.displayElement.style.display="block",this.displayElement.innerHTML="",this._value===null){this.showPlaceholder();return}let e=this.findChoice(this._value);e||(e={key:this._value,text:this._value,data:{}}),this.displayElement.appendChild(this.renderChoice(e))}}renderChoices(){this.dropdownList.innerHTML="";for(let e of this.choices){let n=document.createElement("div");n.classList.add("cean-combox-item"),n.dataset.key=e.key,e.key===this._value&&n.classList.add("cean-combox-selected");let i=this.renderChoice(e);n.appendChild(i),n.addEventListener("mousedown",r=>{r.preventDefault(),this.selectChoice(e),this.closeDropdown()}),this.dropdownList.appendChild(n)}}updateSelectedHighlight(){this.dropdownList.querySelectorAll(".cean-combox-item").forEach(n=>{let i=n;i.dataset.key===this._value?i.classList.add("cean-combox-selected"):i.classList.remove("cean-combox-selected")})}openDropdown(){this.dropdownList.style.display="block",this.updateSelectedHighlight(),this.filterItems()}closeDropdown(){this.dropdownList.style.display="none"}filterItems(){if(!this.filter)return;let e=this.searchInput.value.toLowerCase();this.dropdownList.querySelectorAll(".cean-combox-item").forEach(i=>{let r=i;r.textContent?.toLowerCase().includes(e)?r.style.display="block":r.style.display="none"})}selectChoice(e){this.searchInput.value=e.text,this._value!==e.key&&(this._value=e.key,this.updated()),this.searchInput.blur()}selectFromSearch(){let e=this.searchInput.value;if(e===""){this._value!==null&&(this._value=null,this.updated());return}let n=this.findChoice(e,!0);if(n){this.selectChoice(n);return}this.allowArbitrary?(this._value!==e&&(this._value=e,this.updated()),this.searchInput.blur()):(this._value!==null&&(this._value=null,this.updated()),this.updateDisplay())}findChoice(e,n=!1){let i=this.choices.find(r=>r.key===e);return i||(n?this.choices.find(r=>r.text===e)??null:null)}showPlaceholder(){this.displayElement.textContent=this.allowArbitrary?"Search\u2026":"Select\u2026"}};var _=class extends c{constructor(t){let e=document.createElement("div");e.classList.add("cean-datetime-input");let n=g("input");n.classList.add("cean-input"),n.type="date";let i=g("input");i.classList.add("cean-input"),i.type="time",i.step="1",e.appendChild(n),e.appendChild(i);let r=()=>this.updated();n.addEventListener("blur",r,!0),i.addEventListener("blur",r,!0),n.addEventListener("keydown",s=>{s.key==="Enter"&&r()}),i.addEventListener("keydown",s=>{s.key==="Enter"&&r()}),super(t,e),this.dateElement=n,this.timeElement=i}get value(){let t=this.dateElement.value;if(t==="")return null;let e=this.timeElement.value||"00:00:00";return new Date(`${t}T${e}`)}set value(t){if(!t){this.dateElement.value="",this.timeElement.value="";return}let n=new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString();this.dateElement.value=n.slice(0,10),this.timeElement.value=n.slice(11,19)}get id(){return this.dateElement.id}};var C=class extends c{constructor(t,e){let n=g("select");n.classList.add("cean-dropdown","cean-input"),n.addEventListener("blur",()=>this.updated(),!0),n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}),super(t,n),this.buildOptions(e)}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement(),n=t??"";Array.from(e.options).some(r=>r.value===n)?e.value=n:e.value=""}set options(t){this.inputElement().replaceChildren(),this.buildOptions(t)}disable(){this.container.setAttribute("disabled","true")}enable(){this.container.removeAttribute("disabled")}buildOptions(t){let e=this.inputElement();t.forEach(n=>{let i=document.createElement("option");i.value=n,i.textContent=n,e.appendChild(i)})}};function F(a){let t=document.createElement("span");if(a===null)t.innerText="ERROR";else{let e=a==0?0:Math.floor(Math.log(a)/Math.log(1024)),n=(a/Math.pow(1024,e)).toFixed(2),i=["B","kiB","MiB","GiB","TiB"][e];t.innerText=`${n} ${i}`}return t}function S(a){let t=a.replace(/^https?:\/\/|\/$/g,"");return`<a href="${a}" target=_blank>${t}</a>`}function M(a,t){let e=document.createElement(a);return e.textContent=t,e}function y(a,t,e){let n=Ie(t,e??a);return n.textContent=a,n}function Q(a,t,e){let n=document.createElement("i");n.className=`fa fa-${a}`;let i=Ie(t,e);return i.classList.add("cean-icon-button"),i.appendChild(n),i}function v(a){let t=Q("trash",a,"Remove item");return t.classList.add("cean-button-remove"),t.setAttribute("tabindex","-1"),t}function Ee(a,t,e,n){let i=Q(a,e,n??t),r=document.createElement("span");return r.textContent=t,i.appendChild(r),i}function Ie(a,t){let e=document.createElement("button");return e.classList.add("cean-button"),t!==void 0&&(e.title=t),e.addEventListener("click",a),e}var p=class extends c{constructor(t,e={}){let n=Ye(e.multiLine??!1);super(t,n,e.required,e.validator),n.addEventListener("blur",()=>this.updated(),!0),n.tagName.toLowerCase()==="input"?n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}):n.addEventListener("keydown",i=>{i.key==="Enter"&&i.stopPropagation()})}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement();e.value=t??""}set placeholder(t){let e=this.inputElement();e.placeholder=t??""}};function Ye(a){if(a)return g("textarea");{let t=g("input");return t.type="text",t}}var R=class extends c{constructor(e,n){let i=document.createElement("div");i.classList.add("cean-file-input");let r=new p(`${e}_string`,{validator:o=>this.checkValidation(o)});r.container.addEventListener("input",()=>{this.callDebouncedAfter(()=>{this.inspectFile()},500)}),i.appendChild(r.container);let s=Ee("folder-open","Browse",()=>{n.sendReqBrowseFiles(e,{})},"Browse files");s.classList.add("cean-browse-files-button"),i.appendChild(s),n.onResInspectFile(e,o=>{this.applyInspectionResult(o)}),n.onResBrowseFiles(e,o=>{this.applySelectedFile(o)});super(e,i);this.debounceTimer=null;this.previousValue=null;this.validationResult=null;this.size_=null;this.creationTime_=null;this.stringInput=r,this.comm=n,i.classList.remove("cean-input")}destroy(){this.comm.offResInspectFile(this.key),this.comm.offResBrowseFiles(this.key)}get value(){return this.stringInput.value}set value(e){this.stringInput.value=e}get size(){return this.size_}get creationTime(){return this.creationTime_}checkValidation(e){return this.validationResult}updated_(){this.stringInput.updated(),this.updated()}inspectFile(){let e=this.value;e===null?(this.previousValue=null,this.validationResult=null,this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren(),this.updated_()):e!==this.previousValue&&this.comm.sendReqInspectFile(this.key,{filename:e})}applyInspectionResult(e){this.validationResult=e.error??null,this.previousValue=this.value,e.success?(this.size_=e.size??null,this.creationTime_=new Date(e.creationTime??""),Qe(this.statusElement,this.size_,this.creationTime_)):(this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren()),this.updated_(),this.container.dispatchEvent(new CustomEvent("file-inspected",{bubbles:!1,detail:{payload:e}}))}applySelectedFile(e){this.value=e.selected,this.inspectFile()}callDebouncedAfter(e,n){this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{e(),this.debounceTimer=null},n)}};function Qe(a,t,e){let n=F(t),i=e!==null?e.toLocaleString():"ERROR";a.innerHTML=`<span>Size:</span>${n.outerHTML}<span>Creation time:</span><span>${i}</span>`}var Re=$e(Fe());function Pe(a){return(0,Re.default)(a)?null:"Invalid email address"}function X(a){return kt(a)}var Se="orcid.org";function Lt(a){let t=a.match(/^((https?:\/\/)?(.*)\/)?([^/]+)$/);return t===null?{error:"Invalid ORCID ID structure"}:[t[3]??null,t[4]]}function kt(a){a.match(/^((https?:\/\/)?(.*))?\/.[^/]$/);let t=Lt(a);if(typeof t=="object"&&"error"in t)return t.error;let[e,n]=t;return e!==null&&e!==Se?`Invalid ORCID host, must be '${Se}' or empty.`:Tt(n)??_t(n)}function Tt(a){let t=a.split("-");if(t.length!==4)return"Invalid ORCID ID: expected 4 groups separated by dashes.";for(let e of t)if(e.length!==4)return"Invalid ORCID ID: expected 4 digits per group.";return null}function _t(a){let t=0;for(let i=0;i<a.length-1;i++){let r=a[i];if(r==="-")continue;let s=parseInt(r);if(isNaN(s))return`Invalid ORCID ID: expected a digit, got '${r}'.`;t=(t+s)*2}let e=(12-t%11)%11;return(e===10?"X":e.toString())!==a[a.length-1]?"Invalid ORCID ID checksum":null}var L=class extends c{constructor(t,e,n){let[i,r]=Mt(t,e,n),s=()=>this.updated();i.addEventListener("blur",s,!0),i.addEventListener("keydown",o=>{o.key==="Enter"&&s()}),super(t,i),i.classList.remove("cean-input"),this.widgets=r}get value(){let t=this.widgets.name?.value,e=this.widgets.email?.value,n=this.widgets.orcid?.value??null;if(t===null&&e===null&&n===null)return null;let i={name:t??"",email:e??""};return n!==null&&n!==""&&(i.orcid=n),i}set value(t){t?(this.widgets.name.value=t.name??"",this.widgets.email.value=t.email??"",this.widgets.orcid&&(this.widgets.orcid.value=t.orcid??"")):(this.widgets.name.value="",this.widgets.email.value="",this.widgets.orcid&&(this.widgets.orcid.value=""))}disable(){this.widgets.name.container.setAttribute("disabled","true"),this.widgets.email.container.setAttribute("disabled","true"),this.widgets.orcid?.container.setAttribute("disabled","true")}enable(){this.widgets.name.container.removeAttribute("disabled"),this.widgets.email.container.removeAttribute("disabled"),this.widgets.orcid?.container.removeAttribute("disabled")}};function Mt(a,t,e){let n=document.createElement("div");n.classList.add("cean-person-widget");let[i,r]=h(`${a}_name`,p,[{required:!0}],"Name");n.appendChild(i),n.appendChild(r.container);let[s,o]=h(`${a}_email`,p,[{validator:Pe,required:e}],"Email");n.appendChild(s),n.appendChild(o.container);let l={name:r,email:o};if(t){let[d,u]=h(`${a}_orcid`,p,[{validator:X}],"ORCID");n.appendChild(d),n.appendChild(u.container),l.orcid=u}return[n,l]}var z=class extends c{constructor(t){let e=new Map,n=Wt(e),i=()=>this.updated();n.addEventListener("blur",i,!0),n.addEventListener("keydown",r=>{r.key==="Enter"&&i()}),super(t,n),n.classList.remove("cean-input"),this.ownerWidgets=e}get value(){let t=[];return this.ownerWidgets.forEach(e=>{let n=e.value;n!==null&&t.push(n)}),t.length>0?t:null}set value(t){if(!t)return;this.clearOwners();let e=this.container.querySelector(".cean-owners-container");t.forEach(n=>{let i=$(this.ownerWidgets,e);i.value=n}),t.length===0&&$(this.ownerWidgets,e),this.updated()}clearOwners(){this.ownerWidgets.clear(),this.container.querySelector(".cean-owners-container")?.replaceChildren()}};function Wt(a){let t=g("div"),e=document.createElement("div");return e.classList.add("cean-owners-container"),t.appendChild(e),t.addEventListener("owner-removed",n=>{let i=n;a.delete(i.detail.ownerId)},!1),$(a,e),t.appendChild(y("Add owner",()=>{$(a,e)})),t}function $(a,t){let e=crypto.randomUUID(),n=Dt(t,e,a);return a.set(e,n),n}function Dt(a,t,e){let n=document.createElement("div");n.classList.add("cean-single-owner");let i=new L(t,!0,!1);return n.appendChild(i.container),n.appendChild(v(()=>{n.dispatchEvent(new CustomEvent("owner-removed",{bubbles:!0,detail:{ownerId:t}})),a.removeChild(n),e.size===0&&$(e,a)})),a.appendChild(n),i}var N=class extends c{constructor(t,e){let n=document.createElement("div");super(t,n),n.classList.remove("cean-input");let[i,r,s,o]=this.createPiWidget();n.replaceChildren(i,r.container),this.ownersInput=e;let l=()=>this.updated();n.addEventListener("blur",l,!0),n.addEventListener("keydown",d=>{d.key==="Enter"&&l()}),this.personWidget=r,this.sameAsCheckbox=s,this.sameAsDropdown=o,this.updateDropdown(),this.ownersInput.container.addEventListener("input-updated",()=>{this.updateDropdown()})}updateDropdown(){let t=this.ownersInput.value||[];this.sameAsDropdown.options=t.map(e=>e.name).filter(e=>!!e),this.sameAsCheckbox.value&&this.updateFromDropdown()}updateFromDropdown(){let t=this.sameAsDropdown.value,n=(this.ownersInput.value||[]).find(i=>i.name===t);n&&(this.personWidget.value=n)}get value(){return this.personWidget.value}set value(t){this.personWidget.value=t}createPiWidget(){let[t,e]=h(`${this.key}_same_as_checkbox`,I);t.textContent="same as";let n=new C(`${this.key}_same_as`,[]),i=document.createElement("div");i.classList.add("cean-same-as-container"),i.appendChild(e.container),i.appendChild(t),i.appendChild(n.container);let r=new L(`${this.key}_person`,!1,!0);return e.container.addEventListener("change",s=>{s.target.checked?(r.disable(),n.enable(),this.updateFromDropdown()):(r.enable(),n.disable())}),n.disable(),n.container.addEventListener("change",()=>{e.value&&this.updateFromDropdown()}),[i,r,e,n]}};var Ft=[{key:"input",text:"input",data:{}}],V=class extends c{constructor(e){let n=document.createElement("div");super(e,n);this.relationshipWidgets=[];n.classList.remove("cean-input"),this.wrapElement=n,this.container.classList.add("cean-relationships");let i=document.createElement("div");i.textContent="Relationships",this.wrapElement.prepend(i),this.addRelationshipWidget()}get value(){let e=[];for(let n of this.relationshipWidgets){let i=n.value;i!==null&&e.push(i)}return e.length>0?e:null}set value(e){if(this.clearRelationships(),e&&e.length>0)for(let n of e){let i=this.addRelationshipWidget();i.value=n}this.addRelationshipWidget()}clearRelationships(){for(let e of this.relationshipWidgets)e.remove();this.relationshipWidgets=[]}addRelationshipWidget(){let e=new ve(()=>this.onWidgetChange(e),()=>this.removeRelationshipWidget(e));return this.wrapElement.appendChild(e.element),this.relationshipWidgets.push(e),e}onWidgetChange(e){e===this.relationshipWidgets[this.relationshipWidgets.length-1]&&e.value!==null&&this.addRelationshipWidget(),this.updated()}removeRelationshipWidget(e){let n=this.relationshipWidgets.indexOf(e),i=n===this.relationshipWidgets.length-1&&this.relationshipWidgets[this.relationshipWidgets.length-1].value===null;n!==-1&&this.relationshipWidgets.splice(n,1),e.remove(),(this.relationshipWidgets.length===0||i)&&this.addRelationshipWidget(),this.updated()}},ve=class{constructor(t,e){this.key=crypto.randomUUID(),this.element=document.createElement("div"),this.element.id=this.key,this.element.classList.add("cean-single-relationship-widget","cean-input-grid");let[n,i]=h(`${this.key}_relationship`,f,[{choices:Ft,renderChoice:o=>{let l=document.createElement("div");return l.textContent=o.text,l},allowArbitrary:!0,filter:!0,required:!1}],"Relationship");this.relationshipInput=i,this.relationshipInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(n),this.element.appendChild(i.container),this.element.appendChild(v(()=>{e()}));let[r,s]=h(`${this.key}_relationship`,p,[],"Dataset");this.datasetInput=s,this.datasetInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(r),this.element.appendChild(s.container)}get value(){let t=this.relationshipInput.value?.trim(),e=this.datasetInput.value?.trim();return t&&e?{relationship:t,dataset:e}:null}set value(t){t?(this.relationshipInput.value=t.relationship,this.datasetInput.value=t.dataset):(this.relationshipInput.value=null,this.datasetInput.value=null)}remove(){this.element.remove()}};var G=class extends c{constructor(e){let n=g("div");n.classList.add("cean-scientific-metadata-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let i=document.createElement("table");i.classList.add("cean-scientific-metadata-table");let r=document.createElement("thead"),s=document.createElement("tr");["Name","Value","Unit",""].forEach(o=>{let l=document.createElement("th");l.textContent=o,s.appendChild(l)}),r.appendChild(s),i.appendChild(r),this.tableBody=document.createElement("tbody"),i.appendChild(this.tableBody),n.appendChild(i),n.appendChild(y("Add item",()=>{this.addNewRow()})),this.addNewRow()}addNewRow(e){let n=e??{name:"",value:"",unit:""};this.items.push(n),this.tableBody.appendChild(this.createRow(n,this.items.length-1))}removeItem(e){this.items.splice(e,1),this.items.length===0?(this.tableBody.replaceChildren(),this.addNewRow()):this.renderRows(),this.updated()}renderRows(){this.tableBody.replaceChildren(...this.items.map((e,n)=>this.createRow(e,n)))}createRow(e,n){let i=document.createElement("tr");["name","value","unit"].forEach(o=>{let l=document.createElement("td"),d=document.createElement("input");d.type="text",d.value=e[o]??"",d.addEventListener("input",()=>{e[o]=d.value,this.checkAutoAdd(n),this.updated()}),l.appendChild(d),i.appendChild(l)});let s=document.createElement("td");return s.appendChild(v(()=>this.removeItem(n))),i.appendChild(s),i}checkAutoAdd(e){if(e===this.items.length-1){let n=this.items[e];(n.name.trim()!==""||n.value.trim()!==""||n.unit&&n.unit.trim()!=="")&&this.addNewRow()}}get value(){let e=[];for(let n of this.items){let i=n.name.trim(),r=n.value.trim();i!==""&&r!==""&&e.push({name:i,value:r,unit:n.unit?.trim()||void 0})}return e.length>0?e:null}set value(e){this.items=e||[],this.renderRows()}};var k=class extends c{constructor(e){let n=document.createElement("div");n.classList.add("cean-string-list-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let i=document.createElement("div");i.classList.add("cean-string-list-input-row"),this.input=document.createElement("input"),this.input.id=crypto.randomUUID(),this.input.type="text",this.input.classList.add("cean-input"),this.input.placeholder="Add new item...",this.input.addEventListener("keydown",s=>{s.key==="Enter"&&(s.preventDefault(),this.addItem())});let r=Q("plus",()=>this.addItem());r.title="Add item",r.setAttribute("tabindex","-1"),i.appendChild(this.input),i.appendChild(r),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-string-list-items"),n.appendChild(i),n.appendChild(this.itemsContainer),this.updateItems()}addItem(){let e=this.input.value.trim();e&&(this.items.push(e),this.input.value="",this.updateItems(),this.updated())}removeItem(e){this.items.splice(e,1),this.updateItems(),this.updated()}updateItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let i=document.createElement("div");i.classList.add("cean-string-list-item");let r=document.createElement("span");return r.textContent=e,i.appendChild(r),i.appendChild(v(()=>this.removeItem(n))),i}get value(){return this.items.length>0?this.items:null}set value(e){this.items=e??[],this.updateItems()}get id(){return this.input.id}};var K=class extends c{constructor(e,n){let i=document.createElement("div");i.classList.add("cean-techniques-widget");super(e,i);this.items=[];i.classList.remove("cean-input"),this.idPrefix=n.prefix,this.choices=n.techniques.map(s=>({key:s.id,text:s.name,data:{}})).sort((s,o)=>s.key.localeCompare(o.key));let r=`${this.key}_choices`;this.combobox=new f(r,{choices:this.choices,renderChoice:St,filter:!0,allowArbitrary:!1,required:!1}),this.combobox.container.addEventListener("input-updated",s=>{let o=s;o.key===r&&o.value!==null&&this.addItem()}),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-techniques-items"),i.appendChild(this.combobox.container),i.appendChild(this.itemsContainer),this.renderItems()}addItem(){let e=this.combobox.value;e&&!this.items.includes(e)&&(this.items.push(e),this.combobox.value=null,this.itemsContainer.appendChild(this.createItemBox(e,this.items.length-1)),this.updated())}removeItem(e){this.items.splice(e,1),this.renderItems(),this.updated()}renderItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let i=document.createElement("div");i.classList.add("cean-techniques-item");let r=this.choices.find(l=>l.key===e)||{key:e,text:e,data:{}},s=Rt(r,this.idPrefix);s.classList.add("cean-techniques-item-content"),i.appendChild(s);let o=v(()=>this.removeItem(n));return i.appendChild(o),i}get value(){let e=this.items.map(n=>`${this.idPrefix}/${n}`);return e.length>0?e:null}set value(e){this.items=e??[],this.renderItems()}};function St(a){let t=document.createElement("div"),e=document.createElement("span");e.textContent=a.key,e.classList.add("cean-item-id"),t.appendChild(e);let n=document.createElement("span");return n.textContent=a.text,t.appendChild(n),t}function Rt(a,t){let e=document.createElement("div");e.classList.add("cean-techniques-selected-item");let n=document.createElement("div");n.textContent=a.text,e.appendChild(n);let i=document.createElement("div"),r=document.createElement("a");return r.text=a.key,r.href=`${t}/${a.key}`,r.target="_blank",r.classList.add("cean-item-id"),i.appendChild(r),e.appendChild(i),e}var Z=class{constructor(t,e,n,i){X("");let r=document.createElement("div");r.classList.add("cean-ds"),this.inputWidgets=new Map,r.appendChild(Pt(this.inputWidgets,t,e)),r.appendChild(Ht(this.inputWidgets,n)),r.appendChild(qt(this.inputWidgets,i)),r.appendChild(Bt(this.inputWidgets)),this.element=r}gatherData(){let t={};return this.inputWidgets.forEach((e,n)=>{let i=e.value;i!==null&&(t[n]=i)}),{validationErrors:!1,data:t}}setValue(t,e){let n=this.inputWidgets.get(t);n!==void 0&&(n.value=e)}};function Pt(a,t,e){let n=b.bind(null,a),i=document.createElement("section");i.classList.add("cean-ds-general-info","cean-input-panel"),n(i,"datasetName",p,[{required:!0}]).container.classList.add("cean-span-3"),n(i,"description",p,[{multiLine:!0}]).container.classList.add("cean-span-3"),Ut(a,i,t).container.classList.add("cean-span-3"),Ot(a,i,e),n(i,"creationLocation",p,[{required:!0}]).listenToWidget("instrumentId",(D,Y)=>{let T=e.find(Ae=>Ae.id==Y);T?D.value=`ESS:${T.name}`:D.value=""});let d=document.createElement("div");d.classList.add("cean-run-row"),d.classList.add("cean-span-3");let[u,x]=h("runNumber",p,[]);return a.set("runNumber",x),d.appendChild(x.container),n(d,"startTime",_),n(d,"endTime",_),i.appendChild(u),i.appendChild(d),i}function Ht(a,t){let e=document.createElement("section");return e.classList.add("cean-ds-owner-columns"),e.appendChild(At(a)),e.appendChild(jt(a,t)),e}function At(a){let t=document.createElement("div");t.classList.add("cean-ds-human-owners","cean-input-panel");let e=b(a,t,"owners",z);return b(a,t,"principalInvestigator",N,[e]),t}function jt(a,t){let e=document.createElement("div");e.classList.add("cean-ds-technical-owners","cean-input-panel");let n=b.bind(null,a,e);return zt(a,e,t),n("accessGroups",k),n("license",p),n("isPublished",I),e}function qt(a,t){let e=document.createElement("section");e.classList.add("cean-ds-misc-columns");let n=document.createElement("div");n.classList.add("cean-ds-misc-left","cean-input-panel");let i=document.createElement("div");i.classList.add("cean-ds-misc-right","cean-input-panel");let r=b.bind(null,a,n);r("techniques",K,[t]),r("usedSoftware",k),r("sampleId",p);let s=b.bind(null,a,i);$t(a,i),s("keywords",k);let o=new V("relationships");return a.set("relationships",o),i.appendChild(o.container),e.appendChild(n),e.appendChild(i),e}function Bt(a){let t=document.createElement("section");return t.classList.add("cean-ds-scientific-metadata","cean-input-panel"),b(a,t,"scientificMetadata",G),t}function Ot(a,t,e){let n=e.map(i=>({key:i.id,text:i.uniqueName,data:{}})).sort((i,r)=>i.text.localeCompare(r.text));b(a,t,"instrumentId",f,[{choices:n,renderChoice:i=>{let r=document.createElement("div");return r.textContent=i.text,r},allowArbitrary:!1}])}function Ut(a,t,e){let n=e.map(i=>({key:i.id,text:i.title,data:{}})).sort((i,r)=>i.text.localeCompare(r.text));return b(a,t,"proposalId",f,[{choices:n,renderChoice:i=>{let r=document.createElement("div"),s=document.createElement("span");s.textContent=i.key,s.classList.add("cean-item-id"),r.appendChild(s);let o=document.createElement("span");return o.textContent=i.text,r.appendChild(o),r}}])}function zt(a,t,e){let n=e.sort().map(i=>({key:i,text:i,data:{}}));return b(a,t,"ownerGroup",f,[{choices:n,renderChoice:i=>{let r=document.createElement("div");return r.textContent=i.text,r},required:!0}])}function $t(a,t){let n=b(a,t,"type",f,[{choices:[{key:"derived",text:"derived",data:{}},{key:"raw",text:"raw",data:{}}],renderChoice:i=>{let r=document.createElement("div");return r.textContent=i.text,r},filter:!1}]);return n.value="derived",n}function b(a,t,e,n,i=[]){let[r,s]=h(e,n,i);return t.appendChild(r),t.appendChild(s.container),a.set(e,s),s}var He=`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
3
|
+
<svg width="800" height="800" viewBox="0 0 211.66666 211.66666" version="1.1" id="svg1192" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" sodipodi:docname="SciCat_logo_icon.svg" inkscape:export-filename="/home/nitrosx/repos/scicat-branding/logo/png/SciCat_logo_icon.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
|
4
|
+
<sodipodi:namedview id="namedview1194" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:document-units="mm" showgrid="false" inkscape:zoom="0.77504209" inkscape:cx="403.84903" inkscape:cy="561.25984" inkscape:window-width="2560" inkscape:window-height="1408" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="g1565" units="px" width="800px"/>
|
|
5
|
+
<defs id="defs1189">
|
|
6
|
+
<clipPath id="SVGID_2_">
|
|
7
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102" x="0" y="0" width="100%" height="100%"/>
|
|
8
|
+
</clipPath>
|
|
9
|
+
<circle id="SVGID_1_" cx="153.5" cy="124.2" r="77.5"/>
|
|
10
|
+
<clipPath id="SVGID_2_-8">
|
|
11
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102-5" x="0" y="0" width="100%" height="100%"/>
|
|
12
|
+
</clipPath>
|
|
13
|
+
<clipPath id="SVGID_2_-4">
|
|
14
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102-8" x="0" y="0" width="100%" height="100%"/>
|
|
15
|
+
</clipPath>
|
|
16
|
+
</defs>
|
|
17
|
+
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1">
|
|
18
|
+
<g id="g1565" transform="matrix(0.26458333,0,0,0.26458333,92.68376,105.28284)">
|
|
19
|
+
<polygon class="st0" points="101.7,191.2 89.6,179.5 80.1,189.3 75,188.9 28.9,236.4 46.6,253.6 92.8,206.1 92.1,201.1 " id="polygon7-4" style="fill:#27aae1" transform="matrix(3.6727096,0,0,3.6727096,-430.85069,-550.13486)"/>
|
|
20
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible;fill:#27aae1" id="use100-4" x="0" y="0" width="100%" height="100%" transform="matrix(3.6727096,0,0,3.6727096,-430.85069,-550.13486)"/>
|
|
21
|
+
<path class="st4" d="m 182.85908,-158.25675 h 53.62156 m -52.88702,73.821464 -0.36727,-73.821464 -21.66898,-21.66898 v -21.30172 h 128.9121 v 21.66899 l -21.66898,21.66898 v 279.4932 c 0,17.99628 -14.32357,32.31984 -32.31985,32.31984 h -21.66899 c -17.629,0 -32.31984,-14.32356 -32.31984,-32.31984 V 99.93473" id="path105-4" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10"/>
|
|
22
|
+
<path class="st5" d="m 75.615962,-277.25254 v -10.65086 c 0,-40.03253 36.359828,-64.63968 76.392358,-64.63968 h -0.36727 c 40.03253,0 74.556,35.25801 74.556,75.29054 v 42.9707" id="path107-4" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-miterlimit:10"/>
|
|
23
|
+
<path class="st4" d="m 21.627132,-244.19815 v 21.66898 l 21.668986,21.66899 v 78.96326 c -61.70152,14.69083 -107.61039,69.781478 -107.61039,135.89025 0,77.126901 62.4360625,139.93023 139.930234,139.93023 77.126898,0 139.930238,-62.436058 139.930238,-139.93023 0,-66.108772 -45.90887,-121.19942 -107.61039,-135.89025 v -79.33053 l 21.66898,-21.66899 v -21.66898 H 21.627132 Z m 53.98883,42.9707 H 43.296118" id="path109-7" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10"/>
|
|
24
|
+
</g>
|
|
25
|
+
</g>
|
|
26
|
+
</svg>
|
|
27
|
+
`;var J=class{constructor(t,e,n){let[i,r,s,o]=Vt(t,l=>this.selectTab(l),n);this.element=i,this.tabButtonsContainer=r,this.tabs=s.map((l,d)=>({label:t[d].label,element:l})),Kt(o,e),this.selectTab(0)}selectTab(t){this.tabButtonsContainer.querySelectorAll(".cean-tab-button").forEach((n,i)=>{i===t?n.classList.add("cean-tab-button-active"):n.classList.remove("cean-tab-button-active")}),this.tabs.forEach((n,i)=>{i===t?n.element.style.visibility="visible":n.element.style.visibility="hidden"})}};function Vt(a,t,e){let n=document.createElement("div");n.classList.add("cean-tabs");let i=document.createElement("div");i.classList.add("cean-tab-buttons"),n.appendChild(i);let r=document.createElement("div");r.classList.add("cean-tab-buttons-left"),r.appendChild(Yt(e)),i.appendChild(r);let s=document.createElement("div");s.classList.add("cean-tab-buttons-middle"),i.appendChild(s);let o=document.createElement("div");o.classList.add("cean-tab-buttons-right"),i.appendChild(o);let l=document.createElement("div");l.classList.add("cean-tab-content"),n.appendChild(l);let d=Gt(s,l,a,t);return[n,i,d,o]}function Gt(a,t,e,n){let i=[];return e.forEach((r,s)=>{let o=document.createElement("button");o.appendChild(r.label),o.classList.add("cean-tab-button"),o.addEventListener("click",()=>n(s)),a.appendChild(o);let l=document.createElement("div");l.classList.add("cean-tab-pane"),l.appendChild(r.element),i.push(l),t.appendChild(l)}),i}function Kt(a,t){t.forEach(e=>a.appendChild(e))}function Yt(a){let t=document.createElement("a");return t.href=a,t.target="_blank",t.innerHTML=He,t}var ee=class{constructor(t,e){this.fileWidgets=[];this.comm=t,this.nFilesTabElement=e;let n=document.createElement("div");n.classList.add("cean-files-widget"),n.appendChild(this.createSummary());let[i,r,s]=Qt();this.sourceFolderInput=r,this.algInput=s,n.appendChild(i),n.appendChild(this.createFileWidgets()),this.element=n}gatherData(){return{validationErrors:!1,data:{sourceFolder:this.sourceFolderInput.value,checksumAlgorithm:this.algInput.value,files:this.fileWidgets.filter(e=>e.fileExists()).map(e=>({localPath:e.localPath,remotePath:e.remotePath})).filter(e=>e.localPath)}}}updateSummary(){let t=this.fileWidgets.filter(n=>n.size!==null).length.toString();this.nFilesElement.textContent=t,this.nFilesTabElement.textContent=`(${t})`;let e=0;for(let n of this.fileWidgets)e+=n.size??0;this.totalSizeElement.replaceChildren(F(e))}createSummary(){let t=document.createElement("section");t.classList.add("cean-files-summary"),this.nFilesElement=document.createElement("span"),this.nFilesElement.textContent="0",t.appendChild(this.nFilesElement);let e=document.createElement("span");e.textContent="Files",t.appendChild(e);let n=document.createElement("span");return n.textContent="Total Size:",t.appendChild(n),this.totalSizeElement=document.createElement("span"),this.totalSizeElement.replaceChildren(F(0)),t.appendChild(this.totalSizeElement),t}createFileWidgets(){this.widgetsContainer=document.createElement("section"),this.widgetsContainer.classList.add("cean-files-container","cean-input-panel");let t=document.createElement("div");return t.textContent="Files",this.widgetsContainer.appendChild(t),this.addFileWidget(),this.widgetsContainer}addFileWidget(){let t=new be(this.comm,()=>{this.updateSummary(),t===this.fileWidgets[this.fileWidgets.length-1]&&t.localPath!==null&&this.addFileWidget()},()=>this.removeFileWidget(t));this.widgetsContainer.appendChild(t.element),this.fileWidgets.push(t),this.updateRemoveButtonsState()}removeFileWidget(t){let e=this.fileWidgets.indexOf(t);e!==-1&&this.fileWidgets.splice(e,1),this.updateSummary(),this.updateRemoveButtonsState()}updateRemoveButtonsState(){this.fileWidgets.forEach((t,e)=>{let n=e===this.fileWidgets.length-1;t.setRemoveDisabled(n)})}},be=class{constructor(t,e,n){this.key=crypto.randomUUID(),this.element=document.createElement("div"),this.element.id=this.key,this.element.classList.add("cean-single-file-widget","cean-input-grid");let[i,r]=h(`${this.key}_localPath`,R,[t],"Path");this.localPathInput=r,this.localPathInput.container.addEventListener("input-updated",()=>{e()}),this.element.appendChild(i),this.element.appendChild(this.localPathInput.container),this.removeButton=v(()=>{this.remove(),n()}),this.removeButton.setAttribute("disabled","true"),this.element.appendChild(this.removeButton);let[s,o]=h(`${this.key}_remotePath`,p,[],"Remote path");this.remotePathInput=o,this.element.appendChild(s),this.element.appendChild(o.container),this.localPathInput.container.addEventListener("file-inspected",l=>{let u=l.detail.payload;u.success?this.remotePathInput.placeholder=u.remotePath:this.remotePathInput.placeholder=null}),this.localPathInput.container.addEventListener("input",l=>{l.target.value||(this.remotePathInput.placeholder=null)})}get localPath(){return this.localPathInput.value?.trim()??null}get remotePath(){return this.remotePathInput.value?.trim()??null}get size(){return this.localPathInput.size}fileExists(){return this.size!==null}setRemoveDisabled(t){t?this.removeButton.setAttribute("disabled","true"):this.removeButton.removeAttribute("disabled")}remove(){this.element.remove(),this.localPathInput.destroy()}};function Qt(){let a=document.createElement("section");a.style.gridTemplateColumns="max-content 1fr",a.classList.add("cean-input-grid","cean-input-panel");let[t,e]=h("sourceFolder",p,[{required:!0}]);a.appendChild(t),a.appendChild(e.container);let[n,i]=h("checksumAlgorithm",C,[Xt]);return i.container.classList.add("cean-chk-alg"),a.appendChild(n),a.appendChild(i.container),[a,e,i]}var Xt=["blake2b","sha256","md5"];var te=class{constructor(t){this.callbacks=new Map;this.model=t,this.model.on("msg:custom",e=>{if(e.hasOwnProperty("type")){let n=e.key,i=this.callbacks.get(e.type)?.get(n);i&&i(e.payload);return}console.warn(`Unknown message type: ${e}`)})}sendReqInspectFile(t,e){this.model.send({type:"req:inspect-file",key:t,payload:e})}onResInspectFile(t,e){this.getForMethod("res:inspect-file").set(t,e)}offResInspectFile(t){this.getForMethod("res:inspect-file").delete(t)}sendReqBrowseFiles(t,e){this.model.send({type:"req:browse-files",key:t,payload:e})}onResBrowseFiles(t,e){this.getForMethod("res:browse-files").set(t,e)}offResBrowseFiles(t){this.getForMethod("res:browse-files").delete(t)}sendReqUploadDataset(t,e){this.model.send({type:"req:upload-dataset",key:t,payload:e})}onResUploadDataset(t,e){this.getForMethod("res:upload-dataset").set(t,e)}getForMethod(t){let e=this.callbacks.get(t);if(e!==void 0)return e;let n=new Map;return this.callbacks.set(t,n),n}};var ne=class{constructor(){this.closeOnClickOutside=!0;this._header=document.createElement("header"),this._header.className="cean-dialog-header",this._header.textContent="Confirm Upload",this._body=document.createElement("div"),this._body.className="cean-dialog-body",this._footer=document.createElement("footer"),this._footer.className="cean-dialog-footer";let t=document.createElement("div");t.append(this._header,this._body,this._footer),t.addEventListener("click",e=>e.stopPropagation()),this._dialog=document.createElement("dialog"),this._dialog.className="cean-modal-dialog",this._dialog.append(t),this._dialog.onclick=e=>{this.closeOnClickOutside&&e.target===this._dialog&&this.close()},this._dialog.addEventListener("keydown",e=>{e.key==="Enter"&&e.shiftKey&&(e.stopPropagation(),e.preventDefault())}),this._dialog.onclose=()=>{this._dialog.remove()}}get header(){return this._header}get body(){return this._body}get footer(){return this._footer}close(){this._dialog.close()}showModal(){document.body.appendChild(this._dialog),this._dialog.showModal()}};var ie=class{constructor(t,e,n,i){this.key=crypto.randomUUID();this.comm=t,this.scicatUrl=e,this.skipConfirmation=n,this.gatherData=i,this.dialog=new ne,this.comm.onResUploadDataset(this.key,r=>{this.onUploadResult(r)})}createButton(){let t=document.createElement("button");return t.textContent="Upload dataset",t.classList.add("cean-upload-button","jupyter-button"),t.addEventListener("click",()=>{this.askDoUpload()}),t}askDoUpload(){let t=this.gatherData();t.validationErrors||!this.skipConfirmation?this.showConfirmationDialog(t.data,t.validationErrors):this.showProcessingDialog(t.data)}startUpload(t){this.comm.sendReqUploadDataset(this.key,t)}onUploadResult(t){t.errors!==void 0?this.showErrorDialog(t.errors):this.showSuccessDialog(t.datasetName,t.pid??"UNKNOWN",t.datasetUrl??"UNKNOWN")}showConfirmationDialog(t,e){this.dialog.closeOnClickOutside=!0,this.dialog.header.textContent="Confirm Upload";let n=`<p>Are you sure you want to upload this dataset to
|
|
28
|
+
${S(this.scicatUrl)}?</p>
|
|
29
|
+
<p class="cean-warning" style="text-align: center;">This cannot be undone!</p>
|
|
30
|
+
`;e&&(n+='<p class="cean-warning-severe" style="text-align: center;">There are validation errors. The upload may fail.</p>'),this.dialog.body.innerHTML=n;let i=y("Cancel",()=>{this.dialog.close()},"Cancel upload");i.classList.add("jupyter-button");let r=y("Upload",()=>{this.showProcessingDialog(t)},"Upload dataset");r.setAttribute("autofocus",""),r.className="cean-upload-button jupyter-button",this.dialog.footer.replaceChildren(i,r),this.dialog.showModal()}showProcessingDialog(t){this.startUpload(t),this.dialog.closeOnClickOutside=!1,this.dialog.header.textContent="Uploading dataset",this.dialog.body.innerHTML='<p style="text-align: center;">Please wait...</p><div style="display: flex; justify-content: center;"><span class="cean-spinner"></span></div>';let e=y("Abort",()=>{this.dialog.close()},"Abort upload");e.setAttribute("tabindex","-1"),e.classList.add("jupyter-button"),this.dialog.footer.replaceChildren(e)}showErrorDialog(t){this.dialog.closeOnClickOutside=!0,this.dialog.header.textContent="Error";let e=document.createElement("p");e.textContent="There were errors during the upload:";let n=document.createElement("ul");n.classList.add("cean-validation-error-list");for(let s of t){let o=document.createElement("strong");o.textContent=s.field;let l=document.createElement("span");l.textContent=s.error;let d=document.createElement("li");d.append(o,l),n.appendChild(d)}let i=document.createElement("p");i.textContent="The dataset was not uploaded. Please fix the listed fields and try again.",this.dialog.body.replaceChildren(e,n,i);let r=y("Close",()=>{this.dialog.close()},"Close dialog");r.setAttribute("autofocus",""),r.classList.add("jupyter-button"),this.dialog.footer.replaceChildren(r)}showSuccessDialog(t,e,n){this.dialog.closeOnClickOutside=!0,this.dialog.header.textContent="Success";let i=M("p","Dataset"),r=M("p",`"${t}"`);r.style.fontWeight="bold",r.style.textAlign="center";let s=M("p","with ID"),o=document.createElement("div");o.style.display="flex",o.style.justifyContent="center",o.style.color="var(--jp-success-color2)",o.append(M("code",e));let l=M("p","was uploaded successfully. You can find it at"),d=document.createElement("div");d.style.display="flex",d.style.textAlign="center",d.innerHTML=S(n),this.dialog.body.replaceChildren(i,r,s,o,l,d);let u=y("Close",()=>{this.dialog.close()},"Close dialog");u.setAttribute("autofocus",""),u.classList.add("jupyter-button"),this.dialog.footer.replaceChildren(u)}};async function Zt({model:a,el:t}){let e=new te(a),[n,i,r,s]=Jt(a,a.get("scicatUrl"),e),o=a.get("initial");o&&o.hasOwnProperty("owners")&&i.setValue("owners",o.owners),t.appendChild(n.element),t.addEventListener("keydown",l=>{l.key==="Enter"&&l.shiftKey&&(l.stopPropagation(),l.preventDefault())},!0)}function Jt(a,t,e){let n=document.createElement("span");n.textContent="Dataset";let i=document.createElement("div"),r=document.createElement("span");r.textContent="Files",i.appendChild(r);let s=document.createElement("span");s.textContent="(0)",s.style.marginLeft="0.5em",i.appendChild(s);let o=document.createElement("span");o.textContent="Attachments";let l=new Z(a.get("proposals"),a.get("instruments"),a.get("accessGroups"),a.get("techniques")),d=new ee(e,s),u=new p("attachments"),x=new ie(e,t,a.get("skipConfirm"),()=>en(l,d,u));return[new J([{label:n,element:l.element},{label:i,element:d.element},{label:o,element:u.container}],[tn(t),x.createButton()],t),l,d,u]}function en(a,t,e){let n=a.gatherData(),i=t.gatherData(),r={validationErrors:!1,data:{attachments:e.value}};return{validationErrors:n.validationErrors||i.validationErrors||r.validationErrors,data:{...n.data,files:i.data,attachments:r.data}}}function tn(a){let t=document.createElement("div");return t.innerHTML=S(a),t}var sa={render:Zt};export{sa as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _e=Object.create;var le=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty;var w=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var De=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Me(t))!ke.call(s,i)&&i!==e&&le(s,i,{get:()=>t[i],enumerable:!(n=Te(t,i))||n.enumerable});return s};var Ae=(s,t,e)=>(e=s!=null?_e(We(s)):{},De(t||!s||!s.__esModule?le(e,"default",{value:s,enumerable:!0}):e,s));var k=w((W,Q)=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.default=qe;function qe(s){if(s==null)throw new TypeError("Expected a string but received a ".concat(s));if(s.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(s.constructor.name))}Q.exports=W.default;Q.exports.default=W.default});var pe=w((D,X)=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.default=Be;function Oe(s){return Object.prototype.toString.call(s)==="[object RegExp]"}function Be(s,t){for(var e=0;e<t.length;e++){var n=t[e];if(s===n||Oe(n)&&n.test(s))return!0}return!1}X.exports=D.default;X.exports.default=D.default});var me=w((A,J)=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.default=Ne;var $e=Ue(k());function Ue(s){return s&&s.__esModule?s:{default:s}}function Z(s){"@babel/helpers - typeof";return Z=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(s)}function Ne(s,t){(0,$e.default)(s);var e,n;Z(t)==="object"?(e=t.min||0,n=t.max):(e=arguments[1],n=arguments[2]);var i=encodeURI(s).split(/%..|./).length-1;return i>=e&&(typeof n>"u"||i<=n)}J.exports=A.default;J.exports.default=A.default});var ee=w((H,Y)=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.default=Ve;function Ve(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var e in t)typeof s[e]>"u"&&(s[e]=t[e]);return s}Y.exports=H.default;Y.exports.default=H.default});var fe=w((S,te)=>{"use strict";Object.defineProperty(S,"__esModule",{value:!0});S.default=Ge;var ze=he(k()),je=he(ee());function he(s){return s&&s.__esModule?s:{default:s}}var Ke={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function Ge(s,t){(0,ze.default)(s),t=(0,je.default)(t,Ke),t.allow_trailing_dot&&s[s.length-1]==="."&&(s=s.substring(0,s.length-1)),t.allow_wildcard===!0&&s.indexOf("*.")===0&&(s=s.substring(2));var e=s.split("."),n=e[e.length-1];return t.require_tld&&(e.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(n)||/\s/.test(n))||!t.allow_numeric_tld&&/^\d+$/.test(n)?!1:e.every(function(i){return!(i.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(i)||/[\uff01-\uff5e]/.test(i)||/^-|-$/.test(i)||!t.allow_underscores&&/_/.test(i))})}te.exports=S.default;te.exports.default=S.default});var ve=w((F,se)=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.default=ie;var Qe=Xe(k());function Xe(s){return s&&s.__esModule?s:{default:s}}function ne(s){"@babel/helpers - typeof";return ne=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ne(s)}var ge="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",b="(".concat(ge,"[.]){3}").concat(ge),Ze=new RegExp("^".concat(b,"$")),c="(?:[0-9a-fA-F]{1,4})",Je=new RegExp("^("+"(?:".concat(c,":){7}(?:").concat(c,"|:)|")+"(?:".concat(c,":){6}(?:").concat(b,"|:").concat(c,"|:)|")+"(?:".concat(c,":){5}(?::").concat(b,"|(:").concat(c,"){1,2}|:)|")+"(?:".concat(c,":){4}(?:(:").concat(c,"){0,1}:").concat(b,"|(:").concat(c,"){1,3}|:)|")+"(?:".concat(c,":){3}(?:(:").concat(c,"){0,2}:").concat(b,"|(:").concat(c,"){1,4}|:)|")+"(?:".concat(c,":){2}(?:(:").concat(c,"){0,3}:").concat(b,"|(:").concat(c,"){1,5}|:)|")+"(?:".concat(c,":){1}(?:(:").concat(c,"){0,4}:").concat(b,"|(:").concat(c,"){1,6}|:)|")+"(?::((?::".concat(c,"){0,5}:").concat(b,"|(?::").concat(c,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function ie(s){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,Qe.default)(s);var e=(ne(t)==="object"?t.version:arguments[1])||"";return e?e.toString()==="4"?Ze.test(s):e.toString()==="6"?Je.test(s):!1:ie(s,{version:4})||ie(s,{version:6})}se.exports=F.default;se.exports.default=F.default});var we=w((R,re)=>{"use strict";Object.defineProperty(R,"__esModule",{value:!0});R.default=ct;var Ye=_(k()),Ee=_(pe()),ae=_(me()),et=_(fe()),be=_(ve()),tt=_(ee());function _(s){return s&&s.__esModule?s:{default:s}}var nt={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},it=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,st=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,at=/^[a-z\d]+$/,rt=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,ot=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,lt=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,dt=254;function ut(s){var t=s.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var e=/[\.";<>]/.test(t);if(e){if(t===s)return!1;var n=t.split('"').length===t.split('\\"').length;if(!n)return!1}return!0}function ct(s,t){if((0,Ye.default)(s),t=(0,tt.default)(t,nt),t.require_display_name||t.allow_display_name){var e=s.match(it);if(e){var n=e[1];if(s=s.replace(n,"").replace(/(^<|>$)/g,""),n.endsWith(" ")&&(n=n.slice(0,-1)),!ut(n))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&s.length>dt)return!1;var i=s.split("@"),a=i.pop(),r=a.toLowerCase();if(t.host_blacklist.length>0&&(0,Ee.default)(r,t.host_blacklist)||t.host_whitelist.length>0&&!(0,Ee.default)(r,t.host_whitelist))return!1;var o=i.join("@");if(t.domain_specific_validation&&(r==="gmail.com"||r==="googlemail.com")){o=o.toLowerCase();var d=o.split("+")[0];if(!(0,ae.default)(d.replace(/\./g,""),{min:6,max:30}))return!1;for(var u=d.split("."),p=0;p<u.length;p++)if(!at.test(u[p]))return!1}if(t.ignore_max_length===!1&&(!(0,ae.default)(o,{max:64})||!(0,ae.default)(a,{max:254})))return!1;if(!(0,et.default)(a,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,be.default)(a)){if(!a.startsWith("[")||!a.endsWith("]"))return!1;var T=a.slice(1,-1);if(T.length===0||!(0,be.default)(T))return!1}}if(t.blacklisted_chars&&o.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1;if(o[0]==='"'&&o[o.length-1]==='"')return o=o.slice(1,o.length-1),t.allow_utf8_local_part?lt.test(o):rt.test(o);for(var N=t.allow_utf8_local_part?ot:st,V=o.split("."),L=0;L<V.length;L++)if(!N.test(V[L]))return!1;return!0}re.exports=R.default;re.exports.default=R.default});var l=class{constructor(t,e,n=!1,i){this.key=t,this.required=n,this.inputElement_=e,this.inputElement_.id=crypto.randomUUID(),e.addEventListener("input",()=>this.rawUpdate()),[this.container_,this.statusElement]=He(e),this.validator=Se(n,i)}inputElement(){return this.inputElement_}get container(){return this.container_}get id(){return this.inputElement_.id}updated(){this.validate()&&this.container.dispatchEvent(new K(this.key,this.value,{bubbles:!0}))}rawUpdate(){this.validate()}validate(){let t=this.validator(this.value);return t!==null?(this.statusElement.textContent=t,this.inputElement_.dataset.valid="false",!1):(this.inputElement_.dataset.valid="true",!0)}listenToWidget(t,e,n=document){let i=this.inputUpdatedListener(t,e);n.addEventListener("input-updated",i),n.addEventListener("input-updated",this.inputUpdatedListener(this.key,()=>n.removeEventListener("input-updated",i)))}inputUpdatedListener(t,e){return n=>{let i=n;i.key===t&&e(this,i.value_as())}}};function He(s){s.classList.add("cean-input");let t=document.createElement("div");t.classList.add("cean-input-status");let e=document.createElement("div");return e.classList.add("cean-input-container"),e.replaceChildren(s,t),[e,t]}var K=class extends Event{#e;#t;constructor(t,e,n){super("input-updated",n),this.#e=t,this.#t=e}get key(){return this.#e}get value(){return this.#t}value_as(){return this.value}};function Se(s,t){let e="Required";return s&&t?n=>n==null?e:t(n):t?n=>n==null?null:t(n):s?n=>n==null?e:null:()=>null}var de={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function ue(s){return de[s]??null}function h(s){let t=document.createElement(s);return t.id=crypto.randomUUID(),t}function Re(s,t){let e=document.createElement("label");return e.textContent=t,e.setAttribute("for",s),e}function f(s,t,e,n){let i=new t(s,...e??[]),a=ue(s),r=Re(i.id,n??(a===null?s:a.label));return r.title=a?.description??"",i.required&&r.classList.add("cean-required"),[r,i]}var y=class extends l{constructor(t){let e=h("input");e.type="checkbox",e.addEventListener("blur",()=>this.updated(),!0),e.addEventListener("keydown",n=>{n.key==="Enter"&&this.updated()}),super(t,e)}get value(){return this.inputElement().checked}set value(t){this.inputElement().checked=!!t}};var g=class extends l{constructor(e,{choices:n,renderChoice:i,allowArbitrary:a=!0,filter:r=!0,required:o=!1}){let d=document.createElement("div");d.classList.add("cean-combox-dropdown");super(e,d,o);this._value=null;this.isFocused=!1;this.isMouseDownInside=!1;this.choices=n,this.renderChoice=i,this.allowArbitrary=a,this.filter=r,this.searchInput=document.createElement("input"),this.searchInput.id=crypto.randomUUID(),this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.classList.add("cean-combox-search","cean-input"),this.searchInput.style.display="none",d.appendChild(this.searchInput),this.displayElement=document.createElement("div"),this.displayElement.classList.add("cean-combox-display","cean-input"),d.appendChild(this.displayElement),this.showPlaceholder();let u=document.createElement("i");u.className="fa fa-chevron-down cean-combox-arrow",d.appendChild(u),u.addEventListener("click",p=>{p.stopPropagation(),this.enterEditMode()}),this.dropdownList=document.createElement("div"),this.dropdownList.classList.add("cean-combox-list"),this.dropdownList.style.display="none",d.appendChild(this.dropdownList),this.renderChoices(),this.container.addEventListener("mousedown",()=>{this.isMouseDownInside=!0}),document.addEventListener("mouseup",()=>{this.isMouseDownInside=!1}),this.displayElement.addEventListener("click",()=>{this.enterEditMode()}),this.searchInput.addEventListener("focus",()=>{this.isFocused=!0,this.openDropdown(),this.searchInput.select()}),this.searchInput.addEventListener("input",()=>{this.filterItems(),this.openDropdown()}),this.searchInput.addEventListener("keydown",p=>{p.key==="Enter"?(p.preventDefault(),this.selectFromSearch(),this.closeDropdown()):p.key=="Escape"&&(p.preventDefault(),this.closeDropdown())}),this.searchInput.addEventListener("blur",()=>{if(this.isFocused=!1,this.isMouseDownInside){this.searchInput.focus();return}this.selectFromSearch(),this.closeDropdown(),this.updateDisplay()}),document.addEventListener("click",p=>{this.container.contains(p.target)||this.closeDropdown()})}get value(){return this._value}set value(e){if(this._value!==e){if(this._value=e,e===null)this.searchInput.value="";else{let n=this.findChoice(e);n?this.searchInput.value=n.text:this.searchInput.value=e}this.updateDisplay()}}get id(){return this.searchInput.id}enterEditMode(){this.isFocused=!0,this.updateDisplay(),this.searchInput.focus()}updateDisplay(){if(this.isFocused||this._value===null&&this.allowArbitrary)this.searchInput.style.display="block",this.displayElement.style.display="none";else{if(this.searchInput.style.display="none",this.displayElement.style.display="block",this.displayElement.innerHTML="",this._value===null){this.showPlaceholder();return}let e=this.findChoice(this._value);e||(e={key:this._value,text:this._value,data:{}}),this.displayElement.appendChild(this.renderChoice(e))}}renderChoices(){this.dropdownList.innerHTML="";for(let e of this.choices){let n=document.createElement("div");n.classList.add("cean-combox-item"),n.dataset.key=e.key,e.key===this._value&&n.classList.add("cean-combox-selected");let i=this.renderChoice(e);n.appendChild(i),n.addEventListener("mousedown",a=>{a.preventDefault(),this.selectChoice(e),this.closeDropdown()}),this.dropdownList.appendChild(n)}}updateSelectedHighlight(){this.dropdownList.querySelectorAll(".cean-combox-item").forEach(n=>{let i=n;i.dataset.key===this._value?i.classList.add("cean-combox-selected"):i.classList.remove("cean-combox-selected")})}openDropdown(){this.dropdownList.style.display="block",this.updateSelectedHighlight(),this.filterItems()}closeDropdown(){this.dropdownList.style.display="none"}filterItems(){if(!this.filter)return;let e=this.searchInput.value.toLowerCase();this.dropdownList.querySelectorAll(".cean-combox-item").forEach(i=>{let a=i;a.textContent?.toLowerCase().includes(e)?a.style.display="block":a.style.display="none"})}selectChoice(e){this.searchInput.value=e.text,this._value!==e.key&&(this._value=e.key,this.updated()),this.searchInput.blur()}selectFromSearch(){let e=this.searchInput.value;if(e===""){this._value!==null&&(this._value=null,this.updated());return}let n=this.findChoice(e,!0);if(n){this.selectChoice(n);return}this.allowArbitrary?(this._value!==e&&(this._value=e,this.updated()),this.searchInput.blur()):(this._value!==null&&(this._value=null,this.updated()),this.updateDisplay())}findChoice(e,n=!1){let i=this.choices.find(a=>a.key===e);return i||(n?this.choices.find(a=>a.text===e)??null:null)}showPlaceholder(){this.displayElement.textContent=this.allowArbitrary?"Search\u2026":"Select\u2026"}};var C=class extends l{constructor(t){let e=document.createElement("div");e.classList.add("cean-datetime-input");let n=h("input");n.classList.add("cean-input"),n.type="date";let i=h("input");i.classList.add("cean-input"),i.type="time",i.step="1",e.appendChild(n),e.appendChild(i);let a=()=>this.updated();n.addEventListener("blur",a,!0),i.addEventListener("blur",a,!0),n.addEventListener("keydown",r=>{r.key==="Enter"&&a()}),i.addEventListener("keydown",r=>{r.key==="Enter"&&a()}),super(t,e),this.dateElement=n,this.timeElement=i}get value(){let t=this.dateElement.value;if(t==="")return null;let e=this.timeElement.value||"00:00:00";return new Date(`${t}T${e}`)}set value(t){if(!t){this.dateElement.value="",this.timeElement.value="";return}let n=new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString();this.dateElement.value=n.slice(0,10),this.timeElement.value=n.slice(11,19)}get id(){return this.dateElement.id}};var M=class extends l{constructor(t,e){let n=h("select");n.classList.add("cean-dropdown","cean-input"),n.addEventListener("blur",()=>this.updated(),!0),n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}),super(t,n),this.buildOptions(e)}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement(),n=t??"";Array.from(e.options).some(a=>a.value===n)?e.value=n:e.value=""}set options(t){this.inputElement().replaceChildren(),this.buildOptions(t)}disable(){this.container.setAttribute("disabled","true")}enable(){this.container.removeAttribute("disabled")}buildOptions(t){let e=this.inputElement();t.forEach(n=>{let i=document.createElement("option");i.value=n,i.textContent=n,e.appendChild(i)})}};function z(s,t,e){let n=ce(t,e??s);return n.textContent=s,n}function G(s,t,e){let n=document.createElement("i");n.className=`fa fa-${s}`;let i=ce(t,e);return i.classList.add("cean-icon-button"),i.appendChild(n),i}function E(s){let t=G("trash",s,"Remove item");return t.classList.add("cean-button-remove"),t.setAttribute("tabindex","-1"),t}function ce(s,t){let e=document.createElement("button");return e.classList.add("cean-button"),t!==void 0&&(e.title=t),e.addEventListener("click",s),e}var m=class extends l{constructor(t,e={}){let n=Pe(e.multiLine??!1);super(t,n,e.required,e.validator),n.addEventListener("blur",()=>this.updated(),!0),n.tagName.toLowerCase()==="input"?n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}):n.addEventListener("keydown",i=>{i.key==="Enter"&&i.stopPropagation()})}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement();e.value=t??""}set placeholder(t){let e=this.inputElement();e.placeholder=t??""}};function Pe(s){if(s)return h("textarea");{let t=h("input");return t.type="text",t}}var Ie=Ae(we());function xe(s){return(0,Ie.default)(s)?null:"Invalid email address"}function j(s){return mt(s)}var ye="orcid.org";function pt(s){let t=s.match(/^((https?:\/\/)?(.*)\/)?([^/]+)$/);return t===null?{error:"Invalid ORCID ID structure"}:[t[3]??null,t[4]]}function mt(s){s.match(/^((https?:\/\/)?(.*))?\/.[^/]$/);let t=pt(s);if(typeof t=="object"&&"error"in t)return t.error;let[e,n]=t;return e!==null&&e!==ye?`Invalid ORCID host, must be '${ye}' or empty.`:ht(n)??ft(n)}function ht(s){let t=s.split("-");if(t.length!==4)return"Invalid ORCID ID: expected 4 groups separated by dashes.";for(let e of t)if(e.length!==4)return"Invalid ORCID ID: expected 4 digits per group.";return null}function ft(s){let t=0;for(let i=0;i<s.length-1;i++){let a=s[i];if(a==="-")continue;let r=parseInt(a);if(isNaN(r))return`Invalid ORCID ID: expected a digit, got '${a}'.`;t=(t+r)*2}let e=(12-t%11)%11;return(e===10?"X":e.toString())!==s[s.length-1]?"Invalid ORCID ID checksum":null}var I=class extends l{constructor(t,e,n){let[i,a]=gt(t,e,n),r=()=>this.updated();i.addEventListener("blur",r,!0),i.addEventListener("keydown",o=>{o.key==="Enter"&&r()}),super(t,i),i.classList.remove("cean-input"),this.widgets=a}get value(){let t=this.widgets.name?.value,e=this.widgets.email?.value,n=this.widgets.orcid?.value??null;if(t===null&&e===null&&n===null)return null;let i={name:t??"",email:e??""};return n!==null&&n!==""&&(i.orcid=n),i}set value(t){t?(this.widgets.name.value=t.name??"",this.widgets.email.value=t.email??"",this.widgets.orcid&&(this.widgets.orcid.value=t.orcid??"")):(this.widgets.name.value="",this.widgets.email.value="",this.widgets.orcid&&(this.widgets.orcid.value=""))}disable(){this.widgets.name.container.setAttribute("disabled","true"),this.widgets.email.container.setAttribute("disabled","true"),this.widgets.orcid?.container.setAttribute("disabled","true")}enable(){this.widgets.name.container.removeAttribute("disabled"),this.widgets.email.container.removeAttribute("disabled"),this.widgets.orcid?.container.removeAttribute("disabled")}};function gt(s,t,e){let n=document.createElement("div");n.classList.add("cean-person-widget");let[i,a]=f(`${s}_name`,m,[{required:!0}],"Name");n.appendChild(i),n.appendChild(a.container);let[r,o]=f(`${s}_email`,m,[{validator:xe,required:e}],"Email");n.appendChild(r),n.appendChild(o.container);let d={name:a,email:o};if(t){let[u,p]=f(`${s}_orcid`,m,[{validator:j}],"ORCID");n.appendChild(u),n.appendChild(p.container),d.orcid=p}return[n,d]}var P=class extends l{constructor(t){let e=new Map,n=vt(e),i=()=>this.updated();n.addEventListener("blur",i,!0),n.addEventListener("keydown",a=>{a.key==="Enter"&&i()}),super(t,n),n.classList.remove("cean-input"),this.ownerWidgets=e}get value(){let t=[];return this.ownerWidgets.forEach(e=>{let n=e.value;n!==null&&t.push(n)}),t.length>0?t:null}set value(t){if(!t)return;this.clearOwners();let e=this.container.querySelector(".cean-owners-container");t.forEach(n=>{let i=q(this.ownerWidgets,e);i.value=n}),t.length===0&&q(this.ownerWidgets,e),this.updated()}clearOwners(){this.ownerWidgets.clear(),this.container.querySelector(".cean-owners-container")?.replaceChildren()}};function vt(s){let t=h("div"),e=document.createElement("div");return e.classList.add("cean-owners-container"),t.appendChild(e),t.addEventListener("owner-removed",n=>{let i=n;s.delete(i.detail.ownerId)},!1),q(s,e),t.appendChild(z("Add owner",()=>{q(s,e)})),t}function q(s,t){let e=crypto.randomUUID(),n=Et(t,e,s);return s.set(e,n),n}function Et(s,t,e){let n=document.createElement("div");n.classList.add("cean-single-owner");let i=new I(t,!0,!1);return n.appendChild(i.container),n.appendChild(E(()=>{n.dispatchEvent(new CustomEvent("owner-removed",{bubbles:!0,detail:{ownerId:t}})),s.removeChild(n),e.size===0&&q(e,s)})),s.appendChild(n),i}var O=class extends l{constructor(t,e){let n=document.createElement("div");super(t,n),n.classList.remove("cean-input");let[i,a,r,o]=this.createPiWidget();n.replaceChildren(i,a.container),this.ownersInput=e;let d=()=>this.updated();n.addEventListener("blur",d,!0),n.addEventListener("keydown",u=>{u.key==="Enter"&&d()}),this.personWidget=a,this.sameAsCheckbox=r,this.sameAsDropdown=o,this.updateDropdown(),this.ownersInput.container.addEventListener("input-updated",()=>{this.updateDropdown()})}updateDropdown(){let t=this.ownersInput.value||[];this.sameAsDropdown.options=t.map(e=>e.name).filter(e=>!!e),this.sameAsCheckbox.value&&this.updateFromDropdown()}updateFromDropdown(){let t=this.sameAsDropdown.value,n=(this.ownersInput.value||[]).find(i=>i.name===t);n&&(this.personWidget.value=n)}get value(){return this.personWidget.value}set value(t){this.personWidget.value=t}createPiWidget(){let[t,e]=f(`${this.key}_same_as_checkbox`,y);t.textContent="same as";let n=new M(`${this.key}_same_as`,[]),i=document.createElement("div");i.classList.add("cean-same-as-container"),i.appendChild(e.container),i.appendChild(t),i.appendChild(n.container);let a=new I(`${this.key}_person`,!1,!0);return e.container.addEventListener("change",r=>{r.target.checked?(a.disable(),n.enable(),this.updateFromDropdown()):(a.enable(),n.disable())}),n.disable(),n.container.addEventListener("change",()=>{e.value&&this.updateFromDropdown()}),[i,a,e,n]}};var bt=[{key:"input",text:"input",data:{}}],B=class extends l{constructor(e){let n=document.createElement("div");super(e,n);this.relationshipWidgets=[];n.classList.remove("cean-input"),this.wrapElement=n,this.container.classList.add("cean-relationships");let i=document.createElement("div");i.textContent="Relationships",this.wrapElement.prepend(i),this.addRelationshipWidget()}get value(){let e=[];for(let n of this.relationshipWidgets){let i=n.value;i!==null&&e.push(i)}return e.length>0?e:null}set value(e){if(this.clearRelationships(),e&&e.length>0)for(let n of e){let i=this.addRelationshipWidget();i.value=n}this.addRelationshipWidget()}clearRelationships(){for(let e of this.relationshipWidgets)e.remove();this.relationshipWidgets=[]}addRelationshipWidget(){let e=new oe(()=>this.onWidgetChange(e),()=>this.removeRelationshipWidget(e));return this.wrapElement.appendChild(e.element),this.relationshipWidgets.push(e),e}onWidgetChange(e){e===this.relationshipWidgets[this.relationshipWidgets.length-1]&&e.value!==null&&this.addRelationshipWidget(),this.updated()}removeRelationshipWidget(e){let n=this.relationshipWidgets.indexOf(e),i=n===this.relationshipWidgets.length-1&&this.relationshipWidgets[this.relationshipWidgets.length-1].value===null;n!==-1&&this.relationshipWidgets.splice(n,1),e.remove(),(this.relationshipWidgets.length===0||i)&&this.addRelationshipWidget(),this.updated()}},oe=class{constructor(t,e){this.key=crypto.randomUUID(),this.element=document.createElement("div"),this.element.id=this.key,this.element.classList.add("cean-single-relationship-widget","cean-input-grid");let[n,i]=f(`${this.key}_relationship`,g,[{choices:bt,renderChoice:o=>{let d=document.createElement("div");return d.textContent=o.text,d},allowArbitrary:!0,filter:!0,required:!1}],"Relationship");this.relationshipInput=i,this.relationshipInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(n),this.element.appendChild(i.container),this.element.appendChild(E(()=>{e()}));let[a,r]=f(`${this.key}_relationship`,m,[],"Dataset");this.datasetInput=r,this.datasetInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(a),this.element.appendChild(r.container)}get value(){let t=this.relationshipInput.value?.trim(),e=this.datasetInput.value?.trim();return t&&e?{relationship:t,dataset:e}:null}set value(t){t?(this.relationshipInput.value=t.relationship,this.datasetInput.value=t.dataset):(this.relationshipInput.value=null,this.datasetInput.value=null)}remove(){this.element.remove()}};var $=class extends l{constructor(e){let n=h("div");n.classList.add("cean-scientific-metadata-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let i=document.createElement("table");i.classList.add("cean-scientific-metadata-table");let a=document.createElement("thead"),r=document.createElement("tr");["Name","Value","Unit",""].forEach(o=>{let d=document.createElement("th");d.textContent=o,r.appendChild(d)}),a.appendChild(r),i.appendChild(a),this.tableBody=document.createElement("tbody"),i.appendChild(this.tableBody),n.appendChild(i),n.appendChild(z("Add item",()=>{this.addNewRow()})),this.addNewRow()}addNewRow(e){let n=e??{name:"",value:"",unit:""};this.items.push(n),this.tableBody.appendChild(this.createRow(n,this.items.length-1))}removeItem(e){this.items.splice(e,1),this.items.length===0?(this.tableBody.replaceChildren(),this.addNewRow()):this.renderRows(),this.updated()}renderRows(){this.tableBody.replaceChildren(...this.items.map((e,n)=>this.createRow(e,n)))}createRow(e,n){let i=document.createElement("tr");["name","value","unit"].forEach(o=>{let d=document.createElement("td"),u=document.createElement("input");u.type="text",u.value=e[o]??"",u.addEventListener("input",()=>{e[o]=u.value,this.checkAutoAdd(n),this.updated()}),d.appendChild(u),i.appendChild(d)});let r=document.createElement("td");return r.appendChild(E(()=>this.removeItem(n))),i.appendChild(r),i}checkAutoAdd(e){if(e===this.items.length-1){let n=this.items[e];(n.name.trim()!==""||n.value.trim()!==""||n.unit&&n.unit.trim()!=="")&&this.addNewRow()}}get value(){let e=[];for(let n of this.items){let i=n.name.trim(),a=n.value.trim();i!==""&&a!==""&&e.push({name:i,value:a,unit:n.unit?.trim()||void 0})}return e.length>0?e:null}set value(e){this.items=e||[],this.renderRows()}};var x=class extends l{constructor(e){let n=document.createElement("div");n.classList.add("cean-string-list-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let i=document.createElement("div");i.classList.add("cean-string-list-input-row"),this.input=document.createElement("input"),this.input.id=crypto.randomUUID(),this.input.type="text",this.input.classList.add("cean-input"),this.input.placeholder="Add new item...",this.input.addEventListener("keydown",r=>{r.key==="Enter"&&(r.preventDefault(),this.addItem())});let a=G("plus",()=>this.addItem());a.title="Add item",a.setAttribute("tabindex","-1"),i.appendChild(this.input),i.appendChild(a),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-string-list-items"),n.appendChild(i),n.appendChild(this.itemsContainer),this.updateItems()}addItem(){let e=this.input.value.trim();e&&(this.items.push(e),this.input.value="",this.updateItems(),this.updated())}removeItem(e){this.items.splice(e,1),this.updateItems(),this.updated()}updateItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let i=document.createElement("div");i.classList.add("cean-string-list-item");let a=document.createElement("span");return a.textContent=e,i.appendChild(a),i.appendChild(E(()=>this.removeItem(n))),i}get value(){return this.items.length>0?this.items:null}set value(e){this.items=e??[],this.updateItems()}get id(){return this.input.id}};var U=class extends l{constructor(e,n){let i=document.createElement("div");i.classList.add("cean-techniques-widget");super(e,i);this.items=[];i.classList.remove("cean-input"),this.idPrefix=n.prefix,this.choices=n.techniques.map(r=>({key:r.id,text:r.name,data:{}})).sort((r,o)=>r.key.localeCompare(o.key));let a=`${this.key}_choices`;this.combobox=new g(a,{choices:this.choices,renderChoice:wt,filter:!0,allowArbitrary:!1,required:!1}),this.combobox.container.addEventListener("input-updated",r=>{let o=r;o.key===a&&o.value!==null&&this.addItem()}),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-techniques-items"),i.appendChild(this.combobox.container),i.appendChild(this.itemsContainer),this.renderItems()}addItem(){let e=this.combobox.value;e&&!this.items.includes(e)&&(this.items.push(e),this.combobox.value=null,this.itemsContainer.appendChild(this.createItemBox(e,this.items.length-1)),this.updated())}removeItem(e){this.items.splice(e,1),this.renderItems(),this.updated()}renderItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let i=document.createElement("div");i.classList.add("cean-techniques-item");let a=this.choices.find(d=>d.key===e)||{key:e,text:e,data:{}},r=yt(a,this.idPrefix);r.classList.add("cean-techniques-item-content"),i.appendChild(r);let o=E(()=>this.removeItem(n));return i.appendChild(o),i}get value(){let e=this.items.map(n=>`${this.idPrefix}/${n}`);return e.length>0?e:null}set value(e){this.items=e??[],this.renderItems()}};function wt(s){let t=document.createElement("div"),e=document.createElement("span");e.textContent=s.key,e.classList.add("cean-item-id"),t.appendChild(e);let n=document.createElement("span");return n.textContent=s.text,t.appendChild(n),t}function yt(s,t){let e=document.createElement("div");e.classList.add("cean-techniques-selected-item");let n=document.createElement("div");n.textContent=s.text,e.appendChild(n);let i=document.createElement("div"),a=document.createElement("a");return a.text=s.key,a.href=`${t}/${s.key}`,a.target="_blank",a.classList.add("cean-item-id"),i.appendChild(a),e.appendChild(i),e}var Le=class{constructor(t,e,n,i){j("");let a=document.createElement("div");a.classList.add("cean-ds"),this.inputWidgets=new Map,a.appendChild(It(this.inputWidgets,t,e)),a.appendChild(xt(this.inputWidgets,n)),a.appendChild(_t(this.inputWidgets,i)),a.appendChild(Tt(this.inputWidgets)),this.element=a}gatherData(){let t={};return this.inputWidgets.forEach((e,n)=>{let i=e.value;i!==null&&(t[n]=i)}),{validationErrors:!1,data:t}}setValue(t,e){let n=this.inputWidgets.get(t);n!==void 0&&(n.value=e)}};function It(s,t,e){let n=v.bind(null,s),i=document.createElement("section");i.classList.add("cean-ds-general-info","cean-input-panel"),n(i,"datasetName",m,[{required:!0}]).container.classList.add("cean-span-3"),n(i,"description",m,[{multiLine:!0}]).container.classList.add("cean-span-3"),Wt(s,i,t).container.classList.add("cean-span-3"),Mt(s,i,e),n(i,"creationLocation",m,[{required:!0}]).listenToWidget("instrumentId",(N,V)=>{let L=e.find(Ce=>Ce.id==V);L?N.value=`ESS:${L.name}`:N.value=""});let u=document.createElement("div");u.classList.add("cean-run-row"),u.classList.add("cean-span-3");let[p,T]=f("runNumber",m,[]);return s.set("runNumber",T),u.appendChild(T.container),n(u,"startTime",C),n(u,"endTime",C),i.appendChild(p),i.appendChild(u),i}function xt(s,t){let e=document.createElement("section");return e.classList.add("cean-ds-owner-columns"),e.appendChild(Lt(s)),e.appendChild(Ct(s,t)),e}function Lt(s){let t=document.createElement("div");t.classList.add("cean-ds-human-owners","cean-input-panel");let e=v(s,t,"owners",P);return v(s,t,"principalInvestigator",O,[e]),t}function Ct(s,t){let e=document.createElement("div");e.classList.add("cean-ds-technical-owners","cean-input-panel");let n=v.bind(null,s,e);return kt(s,e,t),n("accessGroups",x),n("license",m),n("isPublished",y),e}function _t(s,t){let e=document.createElement("section");e.classList.add("cean-ds-misc-columns");let n=document.createElement("div");n.classList.add("cean-ds-misc-left","cean-input-panel");let i=document.createElement("div");i.classList.add("cean-ds-misc-right","cean-input-panel");let a=v.bind(null,s,n);a("techniques",U,[t]),a("usedSoftware",x),a("sampleId",m);let r=v.bind(null,s,i);Dt(s,i),r("keywords",x);let o=new B("relationships");return s.set("relationships",o),i.appendChild(o.container),e.appendChild(n),e.appendChild(i),e}function Tt(s){let t=document.createElement("section");return t.classList.add("cean-ds-scientific-metadata","cean-input-panel"),v(s,t,"scientificMetadata",$),t}function Mt(s,t,e){let n=e.map(i=>({key:i.id,text:i.uniqueName,data:{}})).sort((i,a)=>i.text.localeCompare(a.text));v(s,t,"instrumentId",g,[{choices:n,renderChoice:i=>{let a=document.createElement("div");return a.textContent=i.text,a},allowArbitrary:!1}])}function Wt(s,t,e){let n=e.map(i=>({key:i.id,text:i.title,data:{}})).sort((i,a)=>i.text.localeCompare(a.text));return v(s,t,"proposalId",g,[{choices:n,renderChoice:i=>{let a=document.createElement("div"),r=document.createElement("span");r.textContent=i.key,r.classList.add("cean-item-id"),a.appendChild(r);let o=document.createElement("span");return o.textContent=i.text,a.appendChild(o),a}}])}function kt(s,t,e){let n=e.sort().map(i=>({key:i,text:i,data:{}}));return v(s,t,"ownerGroup",g,[{choices:n,renderChoice:i=>{let a=document.createElement("div");return a.textContent=i.text,a},required:!0}])}function Dt(s,t){let n=v(s,t,"type",g,[{choices:[{key:"derived",text:"derived",data:{}},{key:"raw",text:"raw",data:{}}],renderChoice:i=>{let a=document.createElement("div");return a.textContent=i.text,a},filter:!1}]);return n.value="derived",n}function v(s,t,e,n,i=[]){let[a,r]=f(e,n,i);return t.appendChild(a),t.appendChild(r.container),s.set(e,r),r}export{Le as DatasetWidget};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=class{constructor(e,t,n=!1,i){this.key=e,this.required=n,this.inputElement_=t,this.inputElement_.id=crypto.randomUUID(),t.addEventListener("input",()=>this.rawUpdate()),[this.container_,this.statusElement]=W(t),this.validator=k(n,i)}inputElement(){return this.inputElement_}get container(){return this.container_}get id(){return this.inputElement_.id}updated(){this.validate()&&this.container.dispatchEvent(new f(this.key,this.value,{bubbles:!0}))}rawUpdate(){this.validate()}validate(){let e=this.validator(this.value);return e!==null?(this.statusElement.textContent=e,this.inputElement_.dataset.valid="false",!1):(this.inputElement_.dataset.valid="true",!0)}listenToWidget(e,t,n=document){let i=this.inputUpdatedListener(e,t);n.addEventListener("input-updated",i),n.addEventListener("input-updated",this.inputUpdatedListener(this.key,()=>n.removeEventListener("input-updated",i)))}inputUpdatedListener(e,t){return n=>{let i=n;i.key===e&&t(this,i.value_as())}}};function W(s){s.classList.add("cean-input");let e=document.createElement("div");e.classList.add("cean-input-status");let t=document.createElement("div");return t.classList.add("cean-input-container"),t.replaceChildren(s,e),[t,e]}var f=class extends Event{#e;#t;constructor(e,t,n){super("input-updated",n),this.#e=e,this.#t=t}get key(){return this.#e}get value(){return this.#t}value_as(){return this.value}};function k(s,e){let t="Required";return s&&e?n=>n==null?t:e(n):e?n=>n==null?null:e(n):s?n=>n==null?t:null:()=>null}var w={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function y(s){return w[s]??null}function d(s){let e=document.createElement(s);return e.id=crypto.randomUUID(),e}function D(s,e){let t=document.createElement("label");return t.textContent=e,t.setAttribute("for",s),t}function c(s,e,t,n){let i=new e(s,...t??[]),r=y(s),o=D(i.id,n??(r===null?s:r.label));return o.title=r?.description??"",i.required&&o.classList.add("cean-required"),[o,i]}var h=class extends a{constructor(e,t){let n=d("select");n.classList.add("cean-dropdown","cean-input"),n.addEventListener("blur",()=>this.updated(),!0),n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}),super(e,n),this.buildOptions(t)}get value(){let e=this.inputElement();return e.value===""?null:e.value}set value(e){let t=this.inputElement(),n=e??"";Array.from(t.options).some(r=>r.value===n)?t.value=n:t.value=""}set options(e){this.inputElement().replaceChildren(),this.buildOptions(e)}disable(){this.container.setAttribute("disabled","true")}enable(){this.container.removeAttribute("disabled")}buildOptions(e){let t=this.inputElement();e.forEach(n=>{let i=document.createElement("option");i.value=n,i.textContent=n,t.appendChild(i)})}};function m(s){let e=document.createElement("span");if(s===null)e.innerText="ERROR";else{let t=s==0?0:Math.floor(Math.log(s)/Math.log(1024)),n=(s/Math.pow(1024,t)).toFixed(2),i=["B","kiB","MiB","GiB","TiB"][t];e.innerText=`${n} ${i}`}return e}function E(s,e,t){let n=document.createElement("i");n.className=`fa fa-${s}`;let i=S(e,t);return i.classList.add("cean-icon-button"),i.appendChild(n),i}function p(s){let e=E("trash",s,"Remove item");return e.classList.add("cean-button-remove"),e.setAttribute("tabindex","-1"),e}function L(s,e,t,n){let i=E(s,t,n??e),r=document.createElement("span");return r.textContent=e,i.appendChild(r),i}function S(s,e){let t=document.createElement("button");return t.classList.add("cean-button"),e!==void 0&&(t.title=e),t.addEventListener("click",s),t}var l=class extends a{constructor(e,t={}){let n=H(t.multiLine??!1);super(e,n,t.required,t.validator),n.addEventListener("blur",()=>this.updated(),!0),n.tagName.toLowerCase()==="input"?n.addEventListener("keydown",i=>{i.key==="Enter"&&this.updated()}):n.addEventListener("keydown",i=>{i.key==="Enter"&&i.stopPropagation()})}get value(){let e=this.inputElement();return e.value===""?null:e.value}set value(e){let t=this.inputElement();t.value=e??""}set placeholder(e){let t=this.inputElement();t.placeholder=e??""}};function H(s){if(s)return d("textarea");{let e=d("input");return e.type="text",e}}var v=class extends a{constructor(t,n){let i=document.createElement("div");i.classList.add("cean-file-input");let r=new l(`${t}_string`,{validator:u=>this.checkValidation(u)});r.container.addEventListener("input",()=>{this.callDebouncedAfter(()=>{this.inspectFile()},500)}),i.appendChild(r.container);let o=L("folder-open","Browse",()=>{n.sendReqBrowseFiles(t,{})},"Browse files");o.classList.add("cean-browse-files-button"),i.appendChild(o),n.onResInspectFile(t,u=>{this.applyInspectionResult(u)}),n.onResBrowseFiles(t,u=>{this.applySelectedFile(u)});super(t,i);this.debounceTimer=null;this.previousValue=null;this.validationResult=null;this.size_=null;this.creationTime_=null;this.stringInput=r,this.comm=n,i.classList.remove("cean-input")}destroy(){this.comm.offResInspectFile(this.key),this.comm.offResBrowseFiles(this.key)}get value(){return this.stringInput.value}set value(t){this.stringInput.value=t}get size(){return this.size_}get creationTime(){return this.creationTime_}checkValidation(t){return this.validationResult}updated_(){this.stringInput.updated(),this.updated()}inspectFile(){let t=this.value;t===null?(this.previousValue=null,this.validationResult=null,this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren(),this.updated_()):t!==this.previousValue&&this.comm.sendReqInspectFile(this.key,{filename:t})}applyInspectionResult(t){this.validationResult=t.error??null,this.previousValue=this.value,t.success?(this.size_=t.size??null,this.creationTime_=new Date(t.creationTime??""),A(this.statusElement,this.size_,this.creationTime_)):(this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren()),this.updated_(),this.container.dispatchEvent(new CustomEvent("file-inspected",{bubbles:!1,detail:{payload:t}}))}applySelectedFile(t){this.value=t.selected,this.inspectFile()}callDebouncedAfter(t,n){this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{t(),this.debounceTimer=null},n)}};function A(s,e,t){let n=m(e),i=t!==null?t.toLocaleString():"ERROR";s.innerHTML=`<span>Size:</span>${n.outerHTML}<span>Creation time:</span><span>${i}</span>`}var T=class{constructor(e,t){this.fileWidgets=[];this.comm=e,this.nFilesTabElement=t;let n=document.createElement("div");n.classList.add("cean-files-widget"),n.appendChild(this.createSummary());let[i,r,o]=F();this.sourceFolderInput=r,this.algInput=o,n.appendChild(i),n.appendChild(this.createFileWidgets()),this.element=n}gatherData(){return{validationErrors:!1,data:{sourceFolder:this.sourceFolderInput.value,checksumAlgorithm:this.algInput.value,files:this.fileWidgets.filter(t=>t.fileExists()).map(t=>({localPath:t.localPath,remotePath:t.remotePath})).filter(t=>t.localPath)}}}updateSummary(){let e=this.fileWidgets.filter(n=>n.size!==null).length.toString();this.nFilesElement.textContent=e,this.nFilesTabElement.textContent=`(${e})`;let t=0;for(let n of this.fileWidgets)t+=n.size??0;this.totalSizeElement.replaceChildren(m(t))}createSummary(){let e=document.createElement("section");e.classList.add("cean-files-summary"),this.nFilesElement=document.createElement("span"),this.nFilesElement.textContent="0",e.appendChild(this.nFilesElement);let t=document.createElement("span");t.textContent="Files",e.appendChild(t);let n=document.createElement("span");return n.textContent="Total Size:",e.appendChild(n),this.totalSizeElement=document.createElement("span"),this.totalSizeElement.replaceChildren(m(0)),e.appendChild(this.totalSizeElement),e}createFileWidgets(){this.widgetsContainer=document.createElement("section"),this.widgetsContainer.classList.add("cean-files-container","cean-input-panel");let e=document.createElement("div");return e.textContent="Files",this.widgetsContainer.appendChild(e),this.addFileWidget(),this.widgetsContainer}addFileWidget(){let e=new b(this.comm,()=>{this.updateSummary(),e===this.fileWidgets[this.fileWidgets.length-1]&&e.localPath!==null&&this.addFileWidget()},()=>this.removeFileWidget(e));this.widgetsContainer.appendChild(e.element),this.fileWidgets.push(e),this.updateRemoveButtonsState()}removeFileWidget(e){let t=this.fileWidgets.indexOf(e);t!==-1&&this.fileWidgets.splice(t,1),this.updateSummary(),this.updateRemoveButtonsState()}updateRemoveButtonsState(){this.fileWidgets.forEach((e,t)=>{let n=t===this.fileWidgets.length-1;e.setRemoveDisabled(n)})}},b=class{constructor(e,t,n){this.key=crypto.randomUUID(),this.element=document.createElement("div"),this.element.id=this.key,this.element.classList.add("cean-single-file-widget","cean-input-grid");let[i,r]=c(`${this.key}_localPath`,v,[e],"Path");this.localPathInput=r,this.localPathInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(i),this.element.appendChild(this.localPathInput.container),this.removeButton=p(()=>{this.remove(),n()}),this.removeButton.setAttribute("disabled","true"),this.element.appendChild(this.removeButton);let[o,u]=c(`${this.key}_remotePath`,l,[],"Remote path");this.remotePathInput=u,this.element.appendChild(o),this.element.appendChild(u.container),this.localPathInput.container.addEventListener("file-inspected",g=>{let I=g.detail.payload;I.success?this.remotePathInput.placeholder=I.remotePath:this.remotePathInput.placeholder=null}),this.localPathInput.container.addEventListener("input",g=>{g.target.value||(this.remotePathInput.placeholder=null)})}get localPath(){return this.localPathInput.value?.trim()??null}get remotePath(){return this.remotePathInput.value?.trim()??null}get size(){return this.localPathInput.size}fileExists(){return this.size!==null}setRemoveDisabled(e){e?this.removeButton.setAttribute("disabled","true"):this.removeButton.removeAttribute("disabled")}remove(){this.element.remove(),this.localPathInput.destroy()}};function F(){let s=document.createElement("section");s.style.gridTemplateColumns="max-content 1fr",s.classList.add("cean-input-grid","cean-input-panel");let[e,t]=c("sourceFolder",l,[{required:!0}]);s.appendChild(e),s.appendChild(t.container);let[n,i]=c("checksumAlgorithm",h,[_]);return i.container.classList.add("cean-chk-alg"),s.appendChild(n),s.appendChild(i.container),[s,t,i]}var _=["blake2b","sha256","md5"];export{T as FilesWidget};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function r(e){return s[e]??null}function m(e){let t=document.createElement(e);return t.id=crypto.randomUUID(),t}function c(e,t){let a=document.createElement("label");return a.textContent=t,a.setAttribute("for",e),a}function b(e,t,a,l){let i=new t(e,...a??[]),o=r(e),n=c(i.id,l??(o===null?e:o.label));return n.title=o?.description??"",i.required&&n.classList.add("cean-required"),[n,i]}export{m as createFormElement,b as createInputWithLabel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _e=Object.create;var ae=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var E=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var We=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ke(t))!De.call(i,s)&&s!==e&&ae(i,s,{get:()=>t[s],enumerable:!(n=Te(t,s))||n.enumerable});return i};var Fe=(i,t,e)=>(e=i!=null?_e(Me(i)):{},We(t||!i||!i.__esModule?ae(e,"default",{value:i,enumerable:!0}):e,i));var C=E((L,B)=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.default=Be;function Be(i){if(i==null)throw new TypeError("Expected a string but received a ".concat(i));if(i.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(i.constructor.name))}B.exports=L.default;B.exports.default=L.default});var pe=E((_,O)=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.default=$e;function Oe(i){return Object.prototype.toString.call(i)==="[object RegExp]"}function $e(i,t){for(var e=0;e<t.length;e++){var n=t[e];if(i===n||Oe(n)&&n.test(i))return!0}return!1}O.exports=_.default;O.exports.default=_.default});var he=E((T,U)=>{"use strict";Object.defineProperty(T,"__esModule",{value:!0});T.default=Ve;var Ue=Ne(C());function Ne(i){return i&&i.__esModule?i:{default:i}}function $(i){"@babel/helpers - typeof";return $=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$(i)}function Ve(i,t){(0,Ue.default)(i);var e,n;$(t)==="object"?(e=t.min||0,n=t.max):(e=arguments[1],n=arguments[2]);var s=encodeURI(i).split(/%..|./).length-1;return s>=e&&(typeof n>"u"||s<=n)}U.exports=T.default;U.exports.default=T.default});var V=E((k,N)=>{"use strict";Object.defineProperty(k,"__esModule",{value:!0});k.default=ze;function ze(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var e in t)typeof i[e]>"u"&&(i[e]=t[e]);return i}N.exports=k.default;N.exports.default=k.default});var fe=E((M,z)=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.default=Qe;var je=me(C()),Ke=me(V());function me(i){return i&&i.__esModule?i:{default:i}}var Ge={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function Qe(i,t){(0,je.default)(i),t=(0,Ke.default)(t,Ge),t.allow_trailing_dot&&i[i.length-1]==="."&&(i=i.substring(0,i.length-1)),t.allow_wildcard===!0&&i.indexOf("*.")===0&&(i=i.substring(2));var e=i.split("."),n=e[e.length-1];return t.require_tld&&(e.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(n)||/\s/.test(n))||!t.allow_numeric_tld&&/^\d+$/.test(n)?!1:e.every(function(s){return!(s.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(s)||/[\uff01-\uff5e]/.test(s)||/^-|-$/.test(s)||!t.allow_underscores&&/_/.test(s))})}z.exports=M.default;z.exports.default=M.default});var ge=E((D,G)=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.default=K;var Xe=Ze(C());function Ze(i){return i&&i.__esModule?i:{default:i}}function j(i){"@babel/helpers - typeof";return j=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},j(i)}var ve="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",g="(".concat(ve,"[.]){3}").concat(ve),Je=new RegExp("^".concat(g,"$")),u="(?:[0-9a-fA-F]{1,4})",Ye=new RegExp("^("+"(?:".concat(u,":){7}(?:").concat(u,"|:)|")+"(?:".concat(u,":){6}(?:").concat(g,"|:").concat(u,"|:)|")+"(?:".concat(u,":){5}(?::").concat(g,"|(:").concat(u,"){1,2}|:)|")+"(?:".concat(u,":){4}(?:(:").concat(u,"){0,1}:").concat(g,"|(:").concat(u,"){1,3}|:)|")+"(?:".concat(u,":){3}(?:(:").concat(u,"){0,2}:").concat(g,"|(:").concat(u,"){1,4}|:)|")+"(?:".concat(u,":){2}(?:(:").concat(u,"){0,3}:").concat(g,"|(:").concat(u,"){1,5}|:)|")+"(?:".concat(u,":){1}(?:(:").concat(u,"){0,4}:").concat(g,"|(:").concat(u,"){1,6}|:)|")+"(?::((?::".concat(u,"){0,5}:").concat(g,"|(?::").concat(u,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function K(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,Xe.default)(i);var e=(j(t)==="object"?t.version:arguments[1])||"";return e?e.toString()==="4"?Je.test(i):e.toString()==="6"?Ye.test(i):!1:K(i,{version:4})||K(i,{version:6})}G.exports=D.default;G.exports.default=D.default});var we=E((W,X)=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.default=pt;var et=y(C()),Ee=y(pe()),Q=y(he()),tt=y(fe()),be=y(ge()),nt=y(V());function y(i){return i&&i.__esModule?i:{default:i}}var it={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},st=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,rt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,at=/^[a-z\d]+$/,ot=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,lt=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,dt=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,ut=254;function ct(i){var t=i.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var e=/[\.";<>]/.test(t);if(e){if(t===i)return!1;var n=t.split('"').length===t.split('\\"').length;if(!n)return!1}return!0}function pt(i,t){if((0,et.default)(i),t=(0,nt.default)(t,it),t.require_display_name||t.allow_display_name){var e=i.match(st);if(e){var n=e[1];if(i=i.replace(n,"").replace(/(^<|>$)/g,""),n.endsWith(" ")&&(n=n.slice(0,-1)),!ct(n))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&i.length>ut)return!1;var s=i.split("@"),r=s.pop(),a=r.toLowerCase();if(t.host_blacklist.length>0&&(0,Ee.default)(a,t.host_blacklist)||t.host_whitelist.length>0&&!(0,Ee.default)(a,t.host_whitelist))return!1;var o=s.join("@");if(t.domain_specific_validation&&(a==="gmail.com"||a==="googlemail.com")){o=o.toLowerCase();var d=o.split("+")[0];if(!(0,Q.default)(d.replace(/\./g,""),{min:6,max:30}))return!1;for(var c=d.split("."),p=0;p<c.length;p++)if(!at.test(c[p]))return!1}if(t.ignore_max_length===!1&&(!(0,Q.default)(o,{max:64})||!(0,Q.default)(r,{max:254})))return!1;if(!(0,tt.default)(r,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,be.default)(r)){if(!r.startsWith("[")||!r.endsWith("]"))return!1;var se=r.slice(1,-1);if(se.length===0||!(0,be.default)(se))return!1}}if(t.blacklisted_chars&&o.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1;if(o[0]==='"'&&o[o.length-1]==='"')return o=o.slice(1,o.length-1),t.allow_utf8_local_part?dt.test(o):ot.test(o);for(var Ce=t.allow_utf8_local_part?lt:rt,re=o.split("."),R=0;R<re.length;R++)if(!Ce.test(re[R]))return!1;return!0}X.exports=W.default;X.exports.default=W.default});var l=class{constructor(t,e,n=!1,s){this.key=t,this.required=n,this.inputElement_=e,this.inputElement_.id=crypto.randomUUID(),e.addEventListener("input",()=>this.rawUpdate()),[this.container_,this.statusElement]=Ae(e),this.validator=Se(n,s)}inputElement(){return this.inputElement_}get container(){return this.container_}get id(){return this.inputElement_.id}updated(){this.validate()&&this.container.dispatchEvent(new H(this.key,this.value,{bubbles:!0}))}rawUpdate(){this.validate()}validate(){let t=this.validator(this.value);return t!==null?(this.statusElement.textContent=t,this.inputElement_.dataset.valid="false",!1):(this.inputElement_.dataset.valid="true",!0)}listenToWidget(t,e,n=document){let s=this.inputUpdatedListener(t,e);n.addEventListener("input-updated",s),n.addEventListener("input-updated",this.inputUpdatedListener(this.key,()=>n.removeEventListener("input-updated",s)))}inputUpdatedListener(t,e){return n=>{let s=n;s.key===t&&e(this,s.value_as())}}};function Ae(i){i.classList.add("cean-input");let t=document.createElement("div");t.classList.add("cean-input-status");let e=document.createElement("div");return e.classList.add("cean-input-container"),e.replaceChildren(i,t),[e,t]}var H=class extends Event{#e;#t;constructor(t,e,n){super("input-updated",n),this.#e=t,this.#t=e}get key(){return this.#e}get value(){return this.#t}value_as(){return this.value}};function Se(i,t){let e="Required";return i&&t?n=>n==null?e:t(n):t?n=>n==null?null:t(n):i?n=>n==null?e:null:()=>null}var oe={accessGroups:{label:"Access groups",description:"Groups with access to the dataset."},checksumAlgorithm:{label:"Checksum algorithm",description:"Algorithm for computing checksums of files. The default is a good choice for most cases."},creationLocation:{label:"Creation location",description:"Identifier for the place where data was taken, usually of the form 'site:facility:instrument'."},datasetName:{label:"Name",description:"The name of the dataset."},description:{label:"Description",description:"Free text explanation of the contents of the dataset."},endTime:{label:"End",description:"End time of data acquisition for the dataset."},instrumentId:{label:"Instrument",description:"The instrument where the data was taken."},isPublished:{label:"Published",description:"Check to make the dataset publicly available immediately."},keywords:{label:"Keywords",description:"Tags associated with the dataset for search and categorization. Values should ideally come from defined vocabularies, taxonomies, ontologies or knowledge graphs."},license:{label:"License",description:"Name of the license under which the data can be used."},owners:{label:"Owners",description:"People who own the dataset and its data. The owners typically have full access to the data and decide who can use it and how."},ownerGroup:{label:"Owner group",description:"The group that owns the dataset in SciCat and the data on disk. As uploader, you need to be a member of this group."},principalInvestigator:{label:"PI",description:"Principal investigator and contact person for the dataset."},proposalId:{label:"Proposal",description:"The proposal, if any, under which this data was recorded or computed."},relationships:{label:"Relationships",description:"Relationships with other datasets. In particular the 'input' relationship indicates datasets that were processed to obtain the dataset you are uploading."},runNumber:{label:"Run number",description:"Facility or instrument run number that this data belongs to."},sampleId:{label:"Sample ID",description:"SciCat identifier for the sample that was used to record the data."},scientificMetadata:{label:"Scientific metadata",description:"Arbitrary metadata describing the dataset. Choose what to include based on how you want to search for and identify the dataset later. The unit can be omitted if it does not apply."},sourceFolder:{label:"Source folder",description:"Absolute file path on the file server for a folder where the data files will be uploaded."},startTime:{label:"Start",description:"Start time of data acquisition for the dataset."},techniques:{label:"Techniques",description:"Techniques (experimental, analysis) used to produce the dataset."},type:{label:"Type",description:"Characterize the type of the dataset."},usedSoftware:{label:"Used software",description:"Software used to produce the dataset."}};function le(i){return oe[i]??null}function h(i){let t=document.createElement(i);return t.id=crypto.randomUUID(),t}function He(i,t){let e=document.createElement("label");return e.textContent=t,e.setAttribute("for",i),e}function v(i,t,e,n){let s=new t(i,...e??[]),r=le(i),a=He(s.id,n??(r===null?i:r.label));return a.title=r?.description??"",s.required&&a.classList.add("cean-required"),[a,s]}var x=class extends l{constructor(t){let e=h("input");e.type="checkbox",e.addEventListener("blur",()=>this.updated(),!0),e.addEventListener("keydown",n=>{n.key==="Enter"&&this.updated()}),super(t,e)}get value(){return this.inputElement().checked}set value(t){this.inputElement().checked=!!t}};var b=class extends l{constructor(e,{choices:n,renderChoice:s,allowArbitrary:r=!0,filter:a=!0,required:o=!1}){let d=document.createElement("div");d.classList.add("cean-combox-dropdown");super(e,d,o);this._value=null;this.isFocused=!1;this.isMouseDownInside=!1;this.choices=n,this.renderChoice=s,this.allowArbitrary=r,this.filter=a,this.searchInput=document.createElement("input"),this.searchInput.id=crypto.randomUUID(),this.searchInput.type="text",this.searchInput.placeholder="Search...",this.searchInput.classList.add("cean-combox-search","cean-input"),this.searchInput.style.display="none",d.appendChild(this.searchInput),this.displayElement=document.createElement("div"),this.displayElement.classList.add("cean-combox-display","cean-input"),d.appendChild(this.displayElement),this.showPlaceholder();let c=document.createElement("i");c.className="fa fa-chevron-down cean-combox-arrow",d.appendChild(c),c.addEventListener("click",p=>{p.stopPropagation(),this.enterEditMode()}),this.dropdownList=document.createElement("div"),this.dropdownList.classList.add("cean-combox-list"),this.dropdownList.style.display="none",d.appendChild(this.dropdownList),this.renderChoices(),this.container.addEventListener("mousedown",()=>{this.isMouseDownInside=!0}),document.addEventListener("mouseup",()=>{this.isMouseDownInside=!1}),this.displayElement.addEventListener("click",()=>{this.enterEditMode()}),this.searchInput.addEventListener("focus",()=>{this.isFocused=!0,this.openDropdown(),this.searchInput.select()}),this.searchInput.addEventListener("input",()=>{this.filterItems(),this.openDropdown()}),this.searchInput.addEventListener("keydown",p=>{p.key==="Enter"?(p.preventDefault(),this.selectFromSearch(),this.closeDropdown()):p.key=="Escape"&&(p.preventDefault(),this.closeDropdown())}),this.searchInput.addEventListener("blur",()=>{if(this.isFocused=!1,this.isMouseDownInside){this.searchInput.focus();return}this.selectFromSearch(),this.closeDropdown(),this.updateDisplay()}),document.addEventListener("click",p=>{this.container.contains(p.target)||this.closeDropdown()})}get value(){return this._value}set value(e){if(this._value!==e){if(this._value=e,e===null)this.searchInput.value="";else{let n=this.findChoice(e);n?this.searchInput.value=n.text:this.searchInput.value=e}this.updateDisplay()}}get id(){return this.searchInput.id}enterEditMode(){this.isFocused=!0,this.updateDisplay(),this.searchInput.focus()}updateDisplay(){if(this.isFocused||this._value===null&&this.allowArbitrary)this.searchInput.style.display="block",this.displayElement.style.display="none";else{if(this.searchInput.style.display="none",this.displayElement.style.display="block",this.displayElement.innerHTML="",this._value===null){this.showPlaceholder();return}let e=this.findChoice(this._value);e||(e={key:this._value,text:this._value,data:{}}),this.displayElement.appendChild(this.renderChoice(e))}}renderChoices(){this.dropdownList.innerHTML="";for(let e of this.choices){let n=document.createElement("div");n.classList.add("cean-combox-item"),n.dataset.key=e.key,e.key===this._value&&n.classList.add("cean-combox-selected");let s=this.renderChoice(e);n.appendChild(s),n.addEventListener("mousedown",r=>{r.preventDefault(),this.selectChoice(e),this.closeDropdown()}),this.dropdownList.appendChild(n)}}updateSelectedHighlight(){this.dropdownList.querySelectorAll(".cean-combox-item").forEach(n=>{let s=n;s.dataset.key===this._value?s.classList.add("cean-combox-selected"):s.classList.remove("cean-combox-selected")})}openDropdown(){this.dropdownList.style.display="block",this.updateSelectedHighlight(),this.filterItems()}closeDropdown(){this.dropdownList.style.display="none"}filterItems(){if(!this.filter)return;let e=this.searchInput.value.toLowerCase();this.dropdownList.querySelectorAll(".cean-combox-item").forEach(s=>{let r=s;r.textContent?.toLowerCase().includes(e)?r.style.display="block":r.style.display="none"})}selectChoice(e){this.searchInput.value=e.text,this._value!==e.key&&(this._value=e.key,this.updated()),this.searchInput.blur()}selectFromSearch(){let e=this.searchInput.value;if(e===""){this._value!==null&&(this._value=null,this.updated());return}let n=this.findChoice(e,!0);if(n){this.selectChoice(n);return}this.allowArbitrary?(this._value!==e&&(this._value=e,this.updated()),this.searchInput.blur()):(this._value!==null&&(this._value=null,this.updated()),this.updateDisplay())}findChoice(e,n=!1){let s=this.choices.find(r=>r.key===e);return s||(n?this.choices.find(r=>r.text===e)??null:null)}showPlaceholder(){this.displayElement.textContent=this.allowArbitrary?"Search\u2026":"Select\u2026"}};var P=class extends l{constructor(t){let e=document.createElement("div");e.classList.add("cean-datetime-input");let n=h("input");n.classList.add("cean-input"),n.type="date";let s=h("input");s.classList.add("cean-input"),s.type="time",s.step="1",e.appendChild(n),e.appendChild(s);let r=()=>this.updated();n.addEventListener("blur",r,!0),s.addEventListener("blur",r,!0),n.addEventListener("keydown",a=>{a.key==="Enter"&&r()}),s.addEventListener("keydown",a=>{a.key==="Enter"&&r()}),super(t,e),this.dateElement=n,this.timeElement=s}get value(){let t=this.dateElement.value;if(t==="")return null;let e=this.timeElement.value||"00:00:00";return new Date(`${t}T${e}`)}set value(t){if(!t){this.dateElement.value="",this.timeElement.value="";return}let n=new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString();this.dateElement.value=n.slice(0,10),this.timeElement.value=n.slice(11,19)}get id(){return this.dateElement.id}};var I=class extends l{constructor(t,e){let n=h("select");n.classList.add("cean-dropdown","cean-input"),n.addEventListener("blur",()=>this.updated(),!0),n.addEventListener("keydown",s=>{s.key==="Enter"&&this.updated()}),super(t,n),this.buildOptions(e)}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement(),n=t??"";Array.from(e.options).some(r=>r.value===n)?e.value=n:e.value=""}set options(t){this.inputElement().replaceChildren(),this.buildOptions(t)}disable(){this.container.setAttribute("disabled","true")}enable(){this.container.removeAttribute("disabled")}buildOptions(t){let e=this.inputElement();t.forEach(n=>{let s=document.createElement("option");s.value=n,s.textContent=n,e.appendChild(s)})}};function de(i){let t=document.createElement("span");if(i===null)t.innerText="ERROR";else{let e=i==0?0:Math.floor(Math.log(i)/Math.log(1024)),n=(i/Math.pow(1024,e)).toFixed(2),s=["B","kiB","MiB","GiB","TiB"][e];t.innerText=`${n} ${s}`}return t}function A(i,t,e){let n=ce(t,e??i);return n.textContent=i,n}function S(i,t,e){let n=document.createElement("i");n.className=`fa fa-${i}`;let s=ce(t,e);return s.classList.add("cean-icon-button"),s.appendChild(n),s}function f(i){let t=S("trash",i,"Remove item");return t.classList.add("cean-button-remove"),t.setAttribute("tabindex","-1"),t}function ue(i,t,e,n){let s=S(i,e,n??t),r=document.createElement("span");return r.textContent=t,s.appendChild(r),s}function ce(i,t){let e=document.createElement("button");return e.classList.add("cean-button"),t!==void 0&&(e.title=t),e.addEventListener("click",i),e}var m=class extends l{constructor(t,e={}){let n=Pe(e.multiLine??!1);super(t,n,e.required,e.validator),n.addEventListener("blur",()=>this.updated(),!0),n.tagName.toLowerCase()==="input"?n.addEventListener("keydown",s=>{s.key==="Enter"&&this.updated()}):n.addEventListener("keydown",s=>{s.key==="Enter"&&s.stopPropagation()})}get value(){let t=this.inputElement();return t.value===""?null:t.value}set value(t){let e=this.inputElement();e.value=t??""}set placeholder(t){let e=this.inputElement();e.placeholder=t??""}};function Pe(i){if(i)return h("textarea");{let t=h("input");return t.type="text",t}}var q=class extends l{constructor(e,n){let s=document.createElement("div");s.classList.add("cean-file-input");let r=new m(`${e}_string`,{validator:o=>this.checkValidation(o)});r.container.addEventListener("input",()=>{this.callDebouncedAfter(()=>{this.inspectFile()},500)}),s.appendChild(r.container);let a=ue("folder-open","Browse",()=>{n.sendReqBrowseFiles(e,{})},"Browse files");a.classList.add("cean-browse-files-button"),s.appendChild(a),n.onResInspectFile(e,o=>{this.applyInspectionResult(o)}),n.onResBrowseFiles(e,o=>{this.applySelectedFile(o)});super(e,s);this.debounceTimer=null;this.previousValue=null;this.validationResult=null;this.size_=null;this.creationTime_=null;this.stringInput=r,this.comm=n,s.classList.remove("cean-input")}destroy(){this.comm.offResInspectFile(this.key),this.comm.offResBrowseFiles(this.key)}get value(){return this.stringInput.value}set value(e){this.stringInput.value=e}get size(){return this.size_}get creationTime(){return this.creationTime_}checkValidation(e){return this.validationResult}updated_(){this.stringInput.updated(),this.updated()}inspectFile(){let e=this.value;e===null?(this.previousValue=null,this.validationResult=null,this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren(),this.updated_()):e!==this.previousValue&&this.comm.sendReqInspectFile(this.key,{filename:e})}applyInspectionResult(e){this.validationResult=e.error??null,this.previousValue=this.value,e.success?(this.size_=e.size??null,this.creationTime_=new Date(e.creationTime??""),qe(this.statusElement,this.size_,this.creationTime_)):(this.size_=null,this.creationTime_=null,this.statusElement.replaceChildren()),this.updated_(),this.container.dispatchEvent(new CustomEvent("file-inspected",{bubbles:!1,detail:{payload:e}}))}applySelectedFile(e){this.value=e.selected,this.inspectFile()}callDebouncedAfter(e,n){this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=window.setTimeout(()=>{e(),this.debounceTimer=null},n)}};function qe(i,t,e){let n=de(t),s=e!==null?e.toLocaleString():"ERROR";i.innerHTML=`<span>Size:</span>${n.outerHTML}<span>Creation time:</span><span>${s}</span>`}var xe=Fe(we());function Ie(i){return(0,xe.default)(i)?null:"Invalid email address"}function Le(i){return mt(i)}var ye="orcid.org";function ht(i){let t=i.match(/^((https?:\/\/)?(.*)\/)?([^/]+)$/);return t===null?{error:"Invalid ORCID ID structure"}:[t[3]??null,t[4]]}function mt(i){i.match(/^((https?:\/\/)?(.*))?\/.[^/]$/);let t=ht(i);if(typeof t=="object"&&"error"in t)return t.error;let[e,n]=t;return e!==null&&e!==ye?`Invalid ORCID host, must be '${ye}' or empty.`:ft(n)??vt(n)}function ft(i){let t=i.split("-");if(t.length!==4)return"Invalid ORCID ID: expected 4 groups separated by dashes.";for(let e of t)if(e.length!==4)return"Invalid ORCID ID: expected 4 digits per group.";return null}function vt(i){let t=0;for(let s=0;s<i.length-1;s++){let r=i[s];if(r==="-")continue;let a=parseInt(r);if(isNaN(a))return`Invalid ORCID ID: expected a digit, got '${r}'.`;t=(t+a)*2}let e=(12-t%11)%11;return(e===10?"X":e.toString())!==i[i.length-1]?"Invalid ORCID ID checksum":null}var w=class extends l{constructor(t,e,n){let[s,r]=gt(t,e,n),a=()=>this.updated();s.addEventListener("blur",a,!0),s.addEventListener("keydown",o=>{o.key==="Enter"&&a()}),super(t,s),s.classList.remove("cean-input"),this.widgets=r}get value(){let t=this.widgets.name?.value,e=this.widgets.email?.value,n=this.widgets.orcid?.value??null;if(t===null&&e===null&&n===null)return null;let s={name:t??"",email:e??""};return n!==null&&n!==""&&(s.orcid=n),s}set value(t){t?(this.widgets.name.value=t.name??"",this.widgets.email.value=t.email??"",this.widgets.orcid&&(this.widgets.orcid.value=t.orcid??"")):(this.widgets.name.value="",this.widgets.email.value="",this.widgets.orcid&&(this.widgets.orcid.value=""))}disable(){this.widgets.name.container.setAttribute("disabled","true"),this.widgets.email.container.setAttribute("disabled","true"),this.widgets.orcid?.container.setAttribute("disabled","true")}enable(){this.widgets.name.container.removeAttribute("disabled"),this.widgets.email.container.removeAttribute("disabled"),this.widgets.orcid?.container.removeAttribute("disabled")}};function gt(i,t,e){let n=document.createElement("div");n.classList.add("cean-person-widget");let[s,r]=v(`${i}_name`,m,[{required:!0}],"Name");n.appendChild(s),n.appendChild(r.container);let[a,o]=v(`${i}_email`,m,[{validator:Ie,required:e}],"Email");n.appendChild(a),n.appendChild(o.container);let d={name:r,email:o};if(t){let[c,p]=v(`${i}_orcid`,m,[{validator:Le}],"ORCID");n.appendChild(c),n.appendChild(p.container),d.orcid=p}return[n,d]}var Z=class extends l{constructor(t){let e=new Map,n=Et(e),s=()=>this.updated();n.addEventListener("blur",s,!0),n.addEventListener("keydown",r=>{r.key==="Enter"&&s()}),super(t,n),n.classList.remove("cean-input"),this.ownerWidgets=e}get value(){let t=[];return this.ownerWidgets.forEach(e=>{let n=e.value;n!==null&&t.push(n)}),t.length>0?t:null}set value(t){if(!t)return;this.clearOwners();let e=this.container.querySelector(".cean-owners-container");t.forEach(n=>{let s=F(this.ownerWidgets,e);s.value=n}),t.length===0&&F(this.ownerWidgets,e),this.updated()}clearOwners(){this.ownerWidgets.clear(),this.container.querySelector(".cean-owners-container")?.replaceChildren()}};function Et(i){let t=h("div"),e=document.createElement("div");return e.classList.add("cean-owners-container"),t.appendChild(e),t.addEventListener("owner-removed",n=>{let s=n;i.delete(s.detail.ownerId)},!1),F(i,e),t.appendChild(A("Add owner",()=>{F(i,e)})),t}function F(i,t){let e=crypto.randomUUID(),n=bt(t,e,i);return i.set(e,n),n}function bt(i,t,e){let n=document.createElement("div");n.classList.add("cean-single-owner");let s=new w(t,!0,!1);return n.appendChild(s.container),n.appendChild(f(()=>{n.dispatchEvent(new CustomEvent("owner-removed",{bubbles:!0,detail:{ownerId:t}})),i.removeChild(n),e.size===0&&F(e,i)})),i.appendChild(n),s}var J=class extends l{constructor(t,e){let n=document.createElement("div");super(t,n),n.classList.remove("cean-input");let[s,r,a,o]=this.createPiWidget();n.replaceChildren(s,r.container),this.ownersInput=e;let d=()=>this.updated();n.addEventListener("blur",d,!0),n.addEventListener("keydown",c=>{c.key==="Enter"&&d()}),this.personWidget=r,this.sameAsCheckbox=a,this.sameAsDropdown=o,this.updateDropdown(),this.ownersInput.container.addEventListener("input-updated",()=>{this.updateDropdown()})}updateDropdown(){let t=this.ownersInput.value||[];this.sameAsDropdown.options=t.map(e=>e.name).filter(e=>!!e),this.sameAsCheckbox.value&&this.updateFromDropdown()}updateFromDropdown(){let t=this.sameAsDropdown.value,n=(this.ownersInput.value||[]).find(s=>s.name===t);n&&(this.personWidget.value=n)}get value(){return this.personWidget.value}set value(t){this.personWidget.value=t}createPiWidget(){let[t,e]=v(`${this.key}_same_as_checkbox`,x);t.textContent="same as";let n=new I(`${this.key}_same_as`,[]),s=document.createElement("div");s.classList.add("cean-same-as-container"),s.appendChild(e.container),s.appendChild(t),s.appendChild(n.container);let r=new w(`${this.key}_person`,!1,!0);return e.container.addEventListener("change",a=>{a.target.checked?(r.disable(),n.enable(),this.updateFromDropdown()):(r.enable(),n.disable())}),n.disable(),n.container.addEventListener("change",()=>{e.value&&this.updateFromDropdown()}),[s,r,e,n]}};var wt=[{key:"input",text:"input",data:{}}],Y=class extends l{constructor(e){let n=document.createElement("div");super(e,n);this.relationshipWidgets=[];n.classList.remove("cean-input"),this.wrapElement=n,this.container.classList.add("cean-relationships");let s=document.createElement("div");s.textContent="Relationships",this.wrapElement.prepend(s),this.addRelationshipWidget()}get value(){let e=[];for(let n of this.relationshipWidgets){let s=n.value;s!==null&&e.push(s)}return e.length>0?e:null}set value(e){if(this.clearRelationships(),e&&e.length>0)for(let n of e){let s=this.addRelationshipWidget();s.value=n}this.addRelationshipWidget()}clearRelationships(){for(let e of this.relationshipWidgets)e.remove();this.relationshipWidgets=[]}addRelationshipWidget(){let e=new ee(()=>this.onWidgetChange(e),()=>this.removeRelationshipWidget(e));return this.wrapElement.appendChild(e.element),this.relationshipWidgets.push(e),e}onWidgetChange(e){e===this.relationshipWidgets[this.relationshipWidgets.length-1]&&e.value!==null&&this.addRelationshipWidget(),this.updated()}removeRelationshipWidget(e){let n=this.relationshipWidgets.indexOf(e),s=n===this.relationshipWidgets.length-1&&this.relationshipWidgets[this.relationshipWidgets.length-1].value===null;n!==-1&&this.relationshipWidgets.splice(n,1),e.remove(),(this.relationshipWidgets.length===0||s)&&this.addRelationshipWidget(),this.updated()}},ee=class{constructor(t,e){this.key=crypto.randomUUID(),this.element=document.createElement("div"),this.element.id=this.key,this.element.classList.add("cean-single-relationship-widget","cean-input-grid");let[n,s]=v(`${this.key}_relationship`,b,[{choices:wt,renderChoice:o=>{let d=document.createElement("div");return d.textContent=o.text,d},allowArbitrary:!0,filter:!0,required:!1}],"Relationship");this.relationshipInput=s,this.relationshipInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(n),this.element.appendChild(s.container),this.element.appendChild(f(()=>{e()}));let[r,a]=v(`${this.key}_relationship`,m,[],"Dataset");this.datasetInput=a,this.datasetInput.container.addEventListener("input-updated",()=>{t()}),this.element.appendChild(r),this.element.appendChild(a.container)}get value(){let t=this.relationshipInput.value?.trim(),e=this.datasetInput.value?.trim();return t&&e?{relationship:t,dataset:e}:null}set value(t){t?(this.relationshipInput.value=t.relationship,this.datasetInput.value=t.dataset):(this.relationshipInput.value=null,this.datasetInput.value=null)}remove(){this.element.remove()}};var te=class extends l{constructor(e){let n=h("div");n.classList.add("cean-scientific-metadata-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let s=document.createElement("table");s.classList.add("cean-scientific-metadata-table");let r=document.createElement("thead"),a=document.createElement("tr");["Name","Value","Unit",""].forEach(o=>{let d=document.createElement("th");d.textContent=o,a.appendChild(d)}),r.appendChild(a),s.appendChild(r),this.tableBody=document.createElement("tbody"),s.appendChild(this.tableBody),n.appendChild(s),n.appendChild(A("Add item",()=>{this.addNewRow()})),this.addNewRow()}addNewRow(e){let n=e??{name:"",value:"",unit:""};this.items.push(n),this.tableBody.appendChild(this.createRow(n,this.items.length-1))}removeItem(e){this.items.splice(e,1),this.items.length===0?(this.tableBody.replaceChildren(),this.addNewRow()):this.renderRows(),this.updated()}renderRows(){this.tableBody.replaceChildren(...this.items.map((e,n)=>this.createRow(e,n)))}createRow(e,n){let s=document.createElement("tr");["name","value","unit"].forEach(o=>{let d=document.createElement("td"),c=document.createElement("input");c.type="text",c.value=e[o]??"",c.addEventListener("input",()=>{e[o]=c.value,this.checkAutoAdd(n),this.updated()}),d.appendChild(c),s.appendChild(d)});let a=document.createElement("td");return a.appendChild(f(()=>this.removeItem(n))),s.appendChild(a),s}checkAutoAdd(e){if(e===this.items.length-1){let n=this.items[e];(n.name.trim()!==""||n.value.trim()!==""||n.unit&&n.unit.trim()!=="")&&this.addNewRow()}}get value(){let e=[];for(let n of this.items){let s=n.name.trim(),r=n.value.trim();s!==""&&r!==""&&e.push({name:s,value:r,unit:n.unit?.trim()||void 0})}return e.length>0?e:null}set value(e){this.items=e||[],this.renderRows()}};var ne=class extends l{constructor(e){let n=document.createElement("div");n.classList.add("cean-string-list-widget");super(e,n);this.items=[];n.classList.remove("cean-input");let s=document.createElement("div");s.classList.add("cean-string-list-input-row"),this.input=document.createElement("input"),this.input.id=crypto.randomUUID(),this.input.type="text",this.input.classList.add("cean-input"),this.input.placeholder="Add new item...",this.input.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),this.addItem())});let r=S("plus",()=>this.addItem());r.title="Add item",r.setAttribute("tabindex","-1"),s.appendChild(this.input),s.appendChild(r),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-string-list-items"),n.appendChild(s),n.appendChild(this.itemsContainer),this.updateItems()}addItem(){let e=this.input.value.trim();e&&(this.items.push(e),this.input.value="",this.updateItems(),this.updated())}removeItem(e){this.items.splice(e,1),this.updateItems(),this.updated()}updateItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let s=document.createElement("div");s.classList.add("cean-string-list-item");let r=document.createElement("span");return r.textContent=e,s.appendChild(r),s.appendChild(f(()=>this.removeItem(n))),s}get value(){return this.items.length>0?this.items:null}set value(e){this.items=e??[],this.updateItems()}get id(){return this.input.id}};var ie=class extends l{constructor(e,n){let s=document.createElement("div");s.classList.add("cean-techniques-widget");super(e,s);this.items=[];s.classList.remove("cean-input"),this.idPrefix=n.prefix,this.choices=n.techniques.map(a=>({key:a.id,text:a.name,data:{}})).sort((a,o)=>a.key.localeCompare(o.key));let r=`${this.key}_choices`;this.combobox=new b(r,{choices:this.choices,renderChoice:yt,filter:!0,allowArbitrary:!1,required:!1}),this.combobox.container.addEventListener("input-updated",a=>{let o=a;o.key===r&&o.value!==null&&this.addItem()}),this.itemsContainer=document.createElement("div"),this.itemsContainer.classList.add("cean-techniques-items"),s.appendChild(this.combobox.container),s.appendChild(this.itemsContainer),this.renderItems()}addItem(){let e=this.combobox.value;e&&!this.items.includes(e)&&(this.items.push(e),this.combobox.value=null,this.itemsContainer.appendChild(this.createItemBox(e,this.items.length-1)),this.updated())}removeItem(e){this.items.splice(e,1),this.renderItems(),this.updated()}renderItems(){this.itemsContainer.replaceChildren(...this.items.map((e,n)=>this.createItemBox(e,n)))}createItemBox(e,n){let s=document.createElement("div");s.classList.add("cean-techniques-item");let r=this.choices.find(d=>d.key===e)||{key:e,text:e,data:{}},a=xt(r,this.idPrefix);a.classList.add("cean-techniques-item-content"),s.appendChild(a);let o=f(()=>this.removeItem(n));return s.appendChild(o),s}get value(){let e=this.items.map(n=>`${this.idPrefix}/${n}`);return e.length>0?e:null}set value(e){this.items=e??[],this.renderItems()}};function yt(i){let t=document.createElement("div"),e=document.createElement("span");e.textContent=i.key,e.classList.add("cean-item-id"),t.appendChild(e);let n=document.createElement("span");return n.textContent=i.text,t.appendChild(n),t}function xt(i,t){let e=document.createElement("div");e.classList.add("cean-techniques-selected-item");let n=document.createElement("div");n.textContent=i.text,e.appendChild(n);let s=document.createElement("div"),r=document.createElement("a");return r.text=i.key,r.href=`${t}/${i.key}`,r.target="_blank",r.classList.add("cean-item-id"),s.appendChild(r),e.appendChild(s),e}export{x as CheckboxInputWidget,b as ComboboxInputWidget,P as DatetimeInputWidget,I as DropdownInputWidget,q as FileInputWidget,l as InputWidget,Z as OwnersInputWidget,w as PersonInputWidget,J as PrincipalInvestigatorInputWidget,Y as RelationshipsInputWidget,te as ScientificMetadataInputWidget,m as StringInputWidget,ne as StringListInputWidget,ie as TechniquesInputWidget};
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var r=`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
3
|
+
<svg width="800" height="800" viewBox="0 0 211.66666 211.66666" version="1.1" id="svg1192" inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)" sodipodi:docname="SciCat_logo_icon.svg" inkscape:export-filename="/home/nitrosx/repos/scicat-branding/logo/png/SciCat_logo_icon.png" inkscape:export-xdpi="96" inkscape:export-ydpi="96" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
|
4
|
+
<sodipodi:namedview id="namedview1194" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:document-units="mm" showgrid="false" inkscape:zoom="0.77504209" inkscape:cx="403.84903" inkscape:cy="561.25984" inkscape:window-width="2560" inkscape:window-height="1408" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="g1565" units="px" width="800px"/>
|
|
5
|
+
<defs id="defs1189">
|
|
6
|
+
<clipPath id="SVGID_2_">
|
|
7
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102" x="0" y="0" width="100%" height="100%"/>
|
|
8
|
+
</clipPath>
|
|
9
|
+
<circle id="SVGID_1_" cx="153.5" cy="124.2" r="77.5"/>
|
|
10
|
+
<clipPath id="SVGID_2_-8">
|
|
11
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102-5" x="0" y="0" width="100%" height="100%"/>
|
|
12
|
+
</clipPath>
|
|
13
|
+
<clipPath id="SVGID_2_-4">
|
|
14
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible" id="use102-8" x="0" y="0" width="100%" height="100%"/>
|
|
15
|
+
</clipPath>
|
|
16
|
+
</defs>
|
|
17
|
+
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1">
|
|
18
|
+
<g id="g1565" transform="matrix(0.26458333,0,0,0.26458333,92.68376,105.28284)">
|
|
19
|
+
<polygon class="st0" points="101.7,191.2 89.6,179.5 80.1,189.3 75,188.9 28.9,236.4 46.6,253.6 92.8,206.1 92.1,201.1 " id="polygon7-4" style="fill:#27aae1" transform="matrix(3.6727096,0,0,3.6727096,-430.85069,-550.13486)"/>
|
|
20
|
+
<use xlink:href="#SVGID_1_" style="overflow:visible;fill:#27aae1" id="use100-4" x="0" y="0" width="100%" height="100%" transform="matrix(3.6727096,0,0,3.6727096,-430.85069,-550.13486)"/>
|
|
21
|
+
<path class="st4" d="m 182.85908,-158.25675 h 53.62156 m -52.88702,73.821464 -0.36727,-73.821464 -21.66898,-21.66898 v -21.30172 h 128.9121 v 21.66899 l -21.66898,21.66898 v 279.4932 c 0,17.99628 -14.32357,32.31984 -32.31985,32.31984 h -21.66899 c -17.629,0 -32.31984,-14.32356 -32.31984,-32.31984 V 99.93473" id="path105-4" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10"/>
|
|
22
|
+
<path class="st5" d="m 75.615962,-277.25254 v -10.65086 c 0,-40.03253 36.359828,-64.63968 76.392358,-64.63968 h -0.36727 c 40.03253,0 74.556,35.25801 74.556,75.29054 v 42.9707" id="path107-4" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-miterlimit:10"/>
|
|
23
|
+
<path class="st4" d="m 21.627132,-244.19815 v 21.66898 l 21.668986,21.66899 v 78.96326 c -61.70152,14.69083 -107.61039,69.781478 -107.61039,135.89025 0,77.126901 62.4360625,139.93023 139.930234,139.93023 77.126898,0 139.930238,-62.436058 139.930238,-139.93023 0,-66.108772 -45.90887,-121.19942 -107.61039,-135.89025 v -79.33053 l 21.66898,-21.66899 v -21.66898 H 21.627132 Z m 53.98883,42.9707 H 43.296118" id="path109-7" style="fill:#27aae1;stroke:#ffffff;stroke-width:15.6164;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10"/>
|
|
24
|
+
</g>
|
|
25
|
+
</g>
|
|
26
|
+
</svg>
|
|
27
|
+
`;var p=class{constructor(e,o,n){let[t,l,c,a]=h(e,i=>this.selectTab(i),n);this.element=t,this.tabButtonsContainer=l,this.tabs=c.map((i,d)=>({label:e[d].label,element:i})),b(a,o),this.selectTab(0)}selectTab(e){this.tabButtonsContainer.querySelectorAll(".cean-tab-button").forEach((n,t)=>{t===e?n.classList.add("cean-tab-button-active"):n.classList.remove("cean-tab-button-active")}),this.tabs.forEach((n,t)=>{t===e?n.element.style.visibility="visible":n.element.style.visibility="hidden"})}};function h(s,e,o){let n=document.createElement("div");n.classList.add("cean-tabs");let t=document.createElement("div");t.classList.add("cean-tab-buttons"),n.appendChild(t);let l=document.createElement("div");l.classList.add("cean-tab-buttons-left"),l.appendChild(u(o)),t.appendChild(l);let c=document.createElement("div");c.classList.add("cean-tab-buttons-middle"),t.appendChild(c);let a=document.createElement("div");a.classList.add("cean-tab-buttons-right"),t.appendChild(a);let i=document.createElement("div");i.classList.add("cean-tab-content"),n.appendChild(i);let d=f(c,i,s,e);return[n,t,d,a]}function f(s,e,o,n){let t=[];return o.forEach((l,c)=>{let a=document.createElement("button");a.appendChild(l.label),a.classList.add("cean-tab-button"),a.addEventListener("click",()=>n(c)),s.appendChild(a);let i=document.createElement("div");i.classList.add("cean-tab-pane"),i.appendChild(l.element),t.push(i),e.appendChild(i)}),t}function b(s,e){e.forEach(o=>s.appendChild(o))}function u(s){let e=document.createElement("a");return e.href=s,e.target="_blank",e.innerHTML=r,e}export{p as Tabs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var J=Object.create;var U=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var re=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of Y(t))!te.call(e,l)&&l!==r&&U(e,l,{get:()=>t[l],enumerable:!(a=K(t,l))||a.enumerable});return e};var ae=(e,t,r)=>(r=e!=null?J(ee(e)):{},re(t||!e||!e.__esModule?U(r,"default",{value:e,enumerable:!0}):r,e));var g=c((d,y)=>{"use strict";Object.defineProperty(d,"__esModule",{value:!0});d.default=le;function le(e){if(e==null)throw new TypeError("Expected a string but received a ".concat(e));if(e.constructor.name!=="String")throw new TypeError("Expected a string but received a ".concat(e.constructor.name))}y.exports=d.default;y.exports.default=d.default});var z=c((_,w)=>{"use strict";Object.defineProperty(_,"__esModule",{value:!0});_.default=ue;function ne(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ue(e,t){for(var r=0;r<t.length;r++){var a=t[r];if(e===a||ne(a)&&a.test(e))return!0}return!1}w.exports=_.default;w.exports.default=_.default});var N=c((x,D)=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.default=se;var ie=fe(g());function fe(e){return e&&e.__esModule?e:{default:e}}function I(e){"@babel/helpers - typeof";return I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(e)}function se(e,t){(0,ie.default)(e);var r,a;I(t)==="object"?(r=t.min||0,a=t.max):(r=arguments[1],a=arguments[2]);var l=encodeURI(e).split(/%..|./).length-1;return l>=r&&(typeof a>"u"||l<=a)}D.exports=x.default;D.exports.default=x.default});var S=c((v,q)=>{"use strict";Object.defineProperty(v,"__esModule",{value:!0});v.default=ce;function ce(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;for(var r in t)typeof e[r]>"u"&&(e[r]=t[r]);return e}q.exports=v.default;q.exports.default=v.default});var T=c((m,O)=>{"use strict";Object.defineProperty(m,"__esModule",{value:!0});m.default=_e;var oe=L(g()),de=L(S());function L(e){return e&&e.__esModule?e:{default:e}}var ge={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function _e(e,t){(0,oe.default)(e),t=(0,de.default)(t,ge),t.allow_trailing_dot&&e[e.length-1]==="."&&(e=e.substring(0,e.length-1)),t.allow_wildcard===!0&&e.indexOf("*.")===0&&(e=e.substring(2));var r=e.split("."),a=r[r.length-1];return t.require_tld&&(r.length<2||!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(a)||/\s/.test(a))||!t.allow_numeric_tld&&/^\d+$/.test(a)?!1:r.every(function(l){return!(l.length>63&&!t.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(l)||/[\uff01-\uff5e]/.test(l)||/^-|-$/.test(l)||!t.allow_underscores&&/_/.test(l))})}O.exports=m.default;O.exports.default=m.default});var W=c((h,R)=>{"use strict";Object.defineProperty(h,"__esModule",{value:!0});h.default=$;var xe=ve(g());function ve(e){return e&&e.__esModule?e:{default:e}}function E(e){"@babel/helpers - typeof";return E=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(e)}var H="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",f="(".concat(H,"[.]){3}").concat(H),me=new RegExp("^".concat(f,"$")),n="(?:[0-9a-fA-F]{1,4})",he=new RegExp("^("+"(?:".concat(n,":){7}(?:").concat(n,"|:)|")+"(?:".concat(n,":){6}(?:").concat(f,"|:").concat(n,"|:)|")+"(?:".concat(n,":){5}(?::").concat(f,"|(:").concat(n,"){1,2}|:)|")+"(?:".concat(n,":){4}(?:(:").concat(n,"){0,1}:").concat(f,"|(:").concat(n,"){1,3}|:)|")+"(?:".concat(n,":){3}(?:(:").concat(n,"){0,2}:").concat(f,"|(:").concat(n,"){1,4}|:)|")+"(?:".concat(n,":){2}(?:(:").concat(n,"){0,3}:").concat(f,"|(:").concat(n,"){1,5}|:)|")+"(?:".concat(n,":){1}(?:(:").concat(n,"){0,4}:").concat(f,"|(:").concat(n,"){1,6}|:)|")+"(?::((?::".concat(n,"){0,5}:").concat(f,"|(?::").concat(n,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function $(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,xe.default)(e);var r=(E(t)==="object"?t.version:arguments[1])||"";return r?r.toString()==="4"?me.test(e):r.toString()==="6"?he.test(e):!1:$(e,{version:4})||$(e,{version:6})}R.exports=h.default;R.exports.default=h.default});var B=c((p,j)=>{"use strict";Object.defineProperty(p,"__esModule",{value:!0});p.default=Re;var pe=o(g()),Q=o(z()),P=o(N()),be=o(T()),X=o(W()),Fe=o(S());function o(e){return e&&e.__esModule?e:{default:e}}var ye={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},we=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,Ie=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,De=/^[a-z\d]+$/,qe=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,Se=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,Oe=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,Ee=254;function $e(e){var t=e.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var r=/[\.";<>]/.test(t);if(r){if(t===e)return!1;var a=t.split('"').length===t.split('\\"').length;if(!a)return!1}return!0}function Re(e,t){if((0,pe.default)(e),t=(0,Fe.default)(t,ye),t.require_display_name||t.allow_display_name){var r=e.match(we);if(r){var a=r[1];if(e=e.replace(a,"").replace(/(^<|>$)/g,""),a.endsWith(" ")&&(a=a.slice(0,-1)),!$e(a))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&e.length>Ee)return!1;var l=e.split("@"),i=l.pop(),s=i.toLowerCase();if(t.host_blacklist.length>0&&(0,Q.default)(s,t.host_blacklist)||t.host_whitelist.length>0&&!(0,Q.default)(s,t.host_whitelist))return!1;var u=l.join("@");if(t.domain_specific_validation&&(s==="gmail.com"||s==="googlemail.com")){u=u.toLowerCase();var C=u.split("+")[0];if(!(0,P.default)(C.replace(/\./g,""),{min:6,max:30}))return!1;for(var k=C.split("."),b=0;b<k.length;b++)if(!De.test(k[b]))return!1}if(t.ignore_max_length===!1&&(!(0,P.default)(u,{max:64})||!(0,P.default)(i,{max:254})))return!1;if(!(0,be.default)(i,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,X.default)(i)){if(!i.startsWith("[")||!i.endsWith("]"))return!1;var M=i.slice(1,-1);if(M.length===0||!(0,X.default)(M))return!1}}if(t.blacklisted_chars&&u.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1;if(u[0]==='"'&&u[u.length-1]==='"')return u=u.slice(1,u.length-1),t.allow_utf8_local_part?Oe.test(u):qe.test(u);for(var G=t.allow_utf8_local_part?Se:Ie,A=u.split("."),F=0;F<A.length;F++)if(!G.test(A[F]))return!1;return!0}j.exports=p.default;j.exports.default=p.default});var Z=ae(B());function Ae(e){return(0,Z.default)(e)?null:"Invalid email address"}function Ue(e){return je(e)}var V="orcid.org";function Pe(e){let t=e.match(/^((https?:\/\/)?(.*)\/)?([^/]+)$/);return t===null?{error:"Invalid ORCID ID structure"}:[t[3]??null,t[4]]}function je(e){e.match(/^((https?:\/\/)?(.*))?\/.[^/]$/);let t=Pe(e);if(typeof t=="object"&&"error"in t)return t.error;let[r,a]=t;return r!==null&&r!==V?`Invalid ORCID host, must be '${V}' or empty.`:Ce(a)??ke(a)}function Ce(e){let t=e.split("-");if(t.length!==4)return"Invalid ORCID ID: expected 4 groups separated by dashes.";for(let r of t)if(r.length!==4)return"Invalid ORCID ID: expected 4 digits per group.";return null}function ke(e){let t=0;for(let l=0;l<e.length-1;l++){let i=e[l];if(i==="-")continue;let s=parseInt(i);if(isNaN(s))return`Invalid ORCID ID: expected a digit, got '${i}'.`;t=(t+s)*2}let r=(12-t%11)%11;return(r===10?"X":r.toString())!==e[e.length-1]?"Invalid ORCID ID checksum":null}export{Ae as validateEmail,Ue as validateOrcid};
|
scicat_widget/_upload.py
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ValidationError
|
|
6
|
+
from scitacean import PID, Client, Dataset, File, model
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def upload_dataset(
|
|
10
|
+
client: Client, widget_data: dict[str, object]
|
|
11
|
+
) -> Dataset | UploadError:
|
|
12
|
+
dataset = make_dataset_from_widget_data(widget_data)
|
|
13
|
+
try:
|
|
14
|
+
return client.upload_new_dataset_now(dataset)
|
|
15
|
+
except ValidationError as error:
|
|
16
|
+
return UploadError(
|
|
17
|
+
errors=[
|
|
18
|
+
FieldError(field=str(err["loc"][0]), error=err["msg"])
|
|
19
|
+
for err in error.errors()
|
|
20
|
+
]
|
|
21
|
+
)
|
|
22
|
+
except ValueError as error:
|
|
23
|
+
if "cannot determine source_folder" in error.args[0].lower():
|
|
24
|
+
return UploadError(
|
|
25
|
+
errors=[FieldError(field="sourceFolder", error="Field required")]
|
|
26
|
+
)
|
|
27
|
+
raise
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class FieldError(BaseModel, extra="forbid"):
|
|
31
|
+
field: str
|
|
32
|
+
error: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class UploadError(BaseModel, extra="forbid"):
|
|
36
|
+
errors: list[FieldError]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def make_dataset_from_widget_data(data: dict[str, Any]) -> Dataset:
|
|
40
|
+
"""Construct a Scitacean dataset from widget data."""
|
|
41
|
+
converted = _convert_field_names(data)
|
|
42
|
+
|
|
43
|
+
converted.update(_convert_owners(data.get("owners", [])))
|
|
44
|
+
converted.update(_convert_pi(data.get("principalInvestigator", {})))
|
|
45
|
+
converted.update(_convert_relationships(converted.pop("relationships", None)))
|
|
46
|
+
converted.update(_convert_scientific_metadata(data.get("scientificMetadata", [])))
|
|
47
|
+
|
|
48
|
+
[file_meta, files] = _convert_files(data.get("files", {}))
|
|
49
|
+
converted.update(file_meta)
|
|
50
|
+
|
|
51
|
+
# TODO
|
|
52
|
+
_attachments = _convert_attachments(data.get("attachments", []))
|
|
53
|
+
|
|
54
|
+
dataset = Dataset(**converted)
|
|
55
|
+
dataset.add_files(*files)
|
|
56
|
+
return dataset
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _convert_owners(owners: list[dict[str, str]] | None) -> dict[str, str]:
|
|
60
|
+
if not owners:
|
|
61
|
+
return {}
|
|
62
|
+
|
|
63
|
+
names = [("name", "owner"), ("email", "owner_email"), ("orcid", "orcid_of_owner")]
|
|
64
|
+
return {
|
|
65
|
+
scicat_name: ";".join(collected)
|
|
66
|
+
for short_name, scicat_name in names
|
|
67
|
+
if any(collected := [owner.get(short_name, "") for owner in owners])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _convert_pi(pi: dict[str, str] | None) -> dict[str, str]:
|
|
72
|
+
if not pi:
|
|
73
|
+
return {}
|
|
74
|
+
return {
|
|
75
|
+
"investigator": pi.get("name", ""),
|
|
76
|
+
"contact_email": pi.get("email", ""),
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _convert_relationships(
|
|
81
|
+
relationships: list[dict[str, str]] | None,
|
|
82
|
+
) -> dict[str, Any]:
|
|
83
|
+
if not relationships:
|
|
84
|
+
return {}
|
|
85
|
+
|
|
86
|
+
converted = [
|
|
87
|
+
model.Relationship(
|
|
88
|
+
relationship=rel.get("relationship", ""),
|
|
89
|
+
pid=PID.parse(rel.get("dataset", "")),
|
|
90
|
+
)
|
|
91
|
+
for rel in relationships
|
|
92
|
+
if rel.get("relationship", "") != "input"
|
|
93
|
+
]
|
|
94
|
+
inputs = [
|
|
95
|
+
PID.parse(rel.get("dataset", ""))
|
|
96
|
+
for rel in relationships
|
|
97
|
+
if rel.get("relationship", "") == "input"
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
result: dict[str, Any] = {}
|
|
101
|
+
if inputs:
|
|
102
|
+
result["input_datasets"] = inputs
|
|
103
|
+
if converted:
|
|
104
|
+
result["relationships"] = converted
|
|
105
|
+
return result
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _convert_scientific_metadata(
|
|
109
|
+
meta: list[dict[str, str]],
|
|
110
|
+
) -> dict[str, dict[str, dict[str, str]]]:
|
|
111
|
+
converted = {}
|
|
112
|
+
for field in meta:
|
|
113
|
+
data = {"value": field.get("value", "")}
|
|
114
|
+
if unit := field.get("unit"):
|
|
115
|
+
data["unit"] = unit
|
|
116
|
+
converted[field["name"]] = data
|
|
117
|
+
return {"meta": converted}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _convert_files(files: dict[str, Any]) -> tuple[dict[str, str], list[File]]:
|
|
121
|
+
fields = {
|
|
122
|
+
"source_folder": files.pop("sourceFolder", ""),
|
|
123
|
+
"checksum_algorithm": files.pop("checksumAlgorithm", ""),
|
|
124
|
+
}
|
|
125
|
+
converted_files = [
|
|
126
|
+
File.from_local(spec["localPath"], remote_path=spec.get("remotePath", None))
|
|
127
|
+
for spec in files.get("files", [])
|
|
128
|
+
]
|
|
129
|
+
return fields, converted_files
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _convert_attachments(
|
|
133
|
+
attachments: list[dict[str, str]] | None,
|
|
134
|
+
) -> list[dict[str, Any]]:
|
|
135
|
+
# TODO implement
|
|
136
|
+
return []
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _convert_field_names(widget_data: dict[str, Any]) -> dict[str, Any]:
|
|
140
|
+
converted = {
|
|
141
|
+
field.name: value
|
|
142
|
+
for field in Dataset.fields()
|
|
143
|
+
if (value := widget_data.get(field.scicat_name)) is not None
|
|
144
|
+
}
|
|
145
|
+
# Not handled by Dataset.fields:
|
|
146
|
+
converted["meta"] = widget_data.get("scientificMetadata", {})
|
|
147
|
+
return converted
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# SPDX-License-Identifier: BSD-3-Clause
|
|
2
|
+
# Copyright (c) 2026 SciCat Project (https://github.com/SciCatProject/scitacean)
|
|
3
|
+
|
|
4
|
+
import os
|
|
5
|
+
import pathlib
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
from urllib.parse import quote_plus, urljoin
|
|
9
|
+
|
|
10
|
+
import anywidget
|
|
11
|
+
import IPython.display
|
|
12
|
+
import ipywidgets
|
|
13
|
+
import traitlets
|
|
14
|
+
from jupyter_host_file_picker import HostFilePicker
|
|
15
|
+
from scitacean import Client, Dataset, File, ScicatCommError
|
|
16
|
+
from scitacean.ontology import expands_techniques
|
|
17
|
+
|
|
18
|
+
from ._logging import get_logger
|
|
19
|
+
from ._model import Instrument, ProposalOverview
|
|
20
|
+
from ._scicat_api import get_user_and_scicat_info
|
|
21
|
+
from ._upload import UploadError, upload_dataset
|
|
22
|
+
|
|
23
|
+
_STATIC_PATH = pathlib.Path(__file__).parent / "_static"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DatasetUploadWidget(anywidget.AnyWidget):
|
|
27
|
+
_esm = _STATIC_PATH / "datasetUploadWidget.js"
|
|
28
|
+
_css = _STATIC_PATH / "datasetUploadWidget.css"
|
|
29
|
+
|
|
30
|
+
initial = traitlets.Dict().tag(sync=True)
|
|
31
|
+
instruments = traitlets.List(trait=traitlets.Dict()).tag(sync=True)
|
|
32
|
+
proposals = traitlets.List(trait=traitlets.Dict()).tag(sync=True)
|
|
33
|
+
accessGroups = traitlets.List(trait=traitlets.Unicode()).tag(sync=True)
|
|
34
|
+
techniques = traitlets.Dict(trait=traitlets.Dict()).tag(sync=True)
|
|
35
|
+
scicatUrl = traitlets.Unicode().tag(sync=True)
|
|
36
|
+
skipConfirm = traitlets.Bool().tag(sync=True)
|
|
37
|
+
|
|
38
|
+
def __init__(self, *, client: Client, **kwargs: Any) -> None:
|
|
39
|
+
super().__init__(**kwargs)
|
|
40
|
+
self.client = client
|
|
41
|
+
|
|
42
|
+
# This `Output` is displayed along with `self` so that sub widgets,
|
|
43
|
+
# e.g., a file picker can be attached to it and displayed.
|
|
44
|
+
# We need this because we cannot display widgets in callbacks
|
|
45
|
+
# as those don't have a display context.
|
|
46
|
+
self._aux_output_widget = ipywidgets.Output()
|
|
47
|
+
self._aux_output_widget.add_class("cean-output-anchor")
|
|
48
|
+
self._is_displaying = False
|
|
49
|
+
|
|
50
|
+
def _repr_mimebundle_(
|
|
51
|
+
self, **kwargs: Any
|
|
52
|
+
) -> tuple[dict[Any, Any], dict[Any, Any]] | None:
|
|
53
|
+
# This is a bit hacky, but it allows us to display this DatasetUploadWidget like
|
|
54
|
+
# normal while also placing the aux output widget next to it.
|
|
55
|
+
if self._is_displaying:
|
|
56
|
+
return super()._repr_mimebundle_(**kwargs)
|
|
57
|
+
self._is_displaying = True
|
|
58
|
+
try:
|
|
59
|
+
return ipywidgets.VBox([self, self._aux_output_widget])._repr_mimebundle_( # type: ignore[no-any-return]
|
|
60
|
+
**kwargs
|
|
61
|
+
)
|
|
62
|
+
finally:
|
|
63
|
+
self._is_displaying = False
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def dataset_upload_widget(
|
|
67
|
+
client: Client | None = None, *, skip_confirm: bool = False
|
|
68
|
+
) -> DatasetUploadWidget:
|
|
69
|
+
initial, instruments, proposals, access_groups = _collect_initial_data(client)
|
|
70
|
+
widget = DatasetUploadWidget(
|
|
71
|
+
initial=initial,
|
|
72
|
+
instruments=[_serialize_instrument(instrument) for instrument in instruments],
|
|
73
|
+
proposals=[_serialize_proposal(proposal) for proposal in proposals],
|
|
74
|
+
accessGroups=access_groups,
|
|
75
|
+
techniques=_load_techniques(),
|
|
76
|
+
scicatUrl="https://staging.scicat.ess.eu/", # TODO detect from client
|
|
77
|
+
skipConfirm=skip_confirm,
|
|
78
|
+
client=client, # type: ignore[arg-type] # TODO create client here if not given
|
|
79
|
+
)
|
|
80
|
+
widget.on_msg(_handle_event)
|
|
81
|
+
return widget
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _collect_initial_data(
|
|
85
|
+
client: Client | None = None,
|
|
86
|
+
) -> tuple[dict[str, Any], list[Instrument], list[ProposalOverview], list[str]]:
|
|
87
|
+
if client is None:
|
|
88
|
+
return {}, [], [], []
|
|
89
|
+
data, instruments, proposals, access_groups = _download_scicat_data(client)
|
|
90
|
+
return data, instruments, proposals, access_groups
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _download_scicat_data(
|
|
94
|
+
client: Client,
|
|
95
|
+
) -> tuple[dict[str, Any], list[Instrument], list[ProposalOverview], list[str]]:
|
|
96
|
+
try:
|
|
97
|
+
user_info, instruments = get_user_and_scicat_info(client)
|
|
98
|
+
except (ScicatCommError, ValueError, TypeError, RuntimeError) as error:
|
|
99
|
+
get_logger().warning("Failed to download initial data for user: %s", error)
|
|
100
|
+
return {}, [], [], []
|
|
101
|
+
|
|
102
|
+
proposals = user_info.proposals
|
|
103
|
+
access_groups = user_info.access_groups
|
|
104
|
+
|
|
105
|
+
initial_data = {
|
|
106
|
+
"owners": [
|
|
107
|
+
{
|
|
108
|
+
"name": user_info.display_name,
|
|
109
|
+
"email": user_info.email,
|
|
110
|
+
"orcid": user_info.orcid_id,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
}
|
|
114
|
+
return initial_data, instruments, proposals, access_groups
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _serialize_instrument(instrument: Instrument) -> dict[str, Any]:
|
|
118
|
+
return {
|
|
119
|
+
"id": instrument.pid,
|
|
120
|
+
"name": instrument.name,
|
|
121
|
+
"uniqueName": instrument.unique_name,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _serialize_proposal(proposal: ProposalOverview) -> dict[str, Any]:
|
|
126
|
+
return {
|
|
127
|
+
"id": proposal.id_,
|
|
128
|
+
"title": proposal.title,
|
|
129
|
+
"instrumentIds": proposal.instrument_ids,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _load_techniques() -> dict[str, Any]:
|
|
134
|
+
prefix = next(iter(expands_techniques().keys())).rsplit("/", 1)[0]
|
|
135
|
+
return {
|
|
136
|
+
"prefix": prefix,
|
|
137
|
+
"techniques": [
|
|
138
|
+
{"id": id_.rsplit("/", 1)[-1], "name": names[0]}
|
|
139
|
+
for (id_, names) in expands_techniques().items()
|
|
140
|
+
],
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def _inspect_file(
|
|
145
|
+
widget: DatasetUploadWidget, key: str, input_payload: dict[str, str]
|
|
146
|
+
) -> None:
|
|
147
|
+
try:
|
|
148
|
+
# TODO do not allow folders (probably in scitacean)
|
|
149
|
+
file = File.from_local(input_payload["filename"])
|
|
150
|
+
payload = {
|
|
151
|
+
"success": True,
|
|
152
|
+
"size": file.size,
|
|
153
|
+
"creationTime": file.creation_time,
|
|
154
|
+
"remotePath": file.remote_path.posix,
|
|
155
|
+
}
|
|
156
|
+
except FileNotFoundError:
|
|
157
|
+
payload = {"success": False, "error": "File not found"}
|
|
158
|
+
widget.send(
|
|
159
|
+
{
|
|
160
|
+
"type": "res:inspect-file",
|
|
161
|
+
"key": key,
|
|
162
|
+
"payload": {
|
|
163
|
+
# Echo the input to identify the element that the request came from.
|
|
164
|
+
**input_payload,
|
|
165
|
+
**payload,
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def _browse_files(
|
|
172
|
+
widget: DatasetUploadWidget, key: str, _input_payload: dict[str, str]
|
|
173
|
+
) -> None:
|
|
174
|
+
def send_selected_files(change: dict[str, Any]) -> None:
|
|
175
|
+
selected: list[Path] = change["new"]
|
|
176
|
+
# TODO handle multi select once supported by file picker
|
|
177
|
+
if len(change) > 0:
|
|
178
|
+
widget.send(
|
|
179
|
+
{
|
|
180
|
+
"type": "res:browse-files",
|
|
181
|
+
"key": key,
|
|
182
|
+
"payload": {
|
|
183
|
+
"selected": os.fspath(selected[0]),
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
# Use the output widget's context manager to capture the display call
|
|
189
|
+
with widget._aux_output_widget:
|
|
190
|
+
widget._aux_output_widget.clear_output() # clear previous picker if any
|
|
191
|
+
picker = HostFilePicker()
|
|
192
|
+
picker.observe(send_selected_files, names="selected")
|
|
193
|
+
IPython.display.display(picker) # type: ignore[no-untyped-call]
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def _upload_dataset(
|
|
197
|
+
widget: DatasetUploadWidget, key: str, payload: dict[str, object]
|
|
198
|
+
) -> None:
|
|
199
|
+
match upload_dataset(widget.client, payload):
|
|
200
|
+
case Dataset() as ds:
|
|
201
|
+
widget.send(
|
|
202
|
+
{
|
|
203
|
+
"type": "res:upload-dataset",
|
|
204
|
+
"key": key,
|
|
205
|
+
"payload": {
|
|
206
|
+
"datasetName": ds.name,
|
|
207
|
+
"pid": str(ds.pid),
|
|
208
|
+
"datasetUrl": urljoin(
|
|
209
|
+
widget.scicatUrl, "datasets/" + quote_plus(str(ds.pid))
|
|
210
|
+
),
|
|
211
|
+
},
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
case UploadError() as error:
|
|
215
|
+
widget.send(
|
|
216
|
+
{
|
|
217
|
+
"type": "res:upload-dataset",
|
|
218
|
+
"key": key,
|
|
219
|
+
"payload": error.model_dump(),
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
_EVENT_HANDLERS = {
|
|
225
|
+
"req:inspect-file": _inspect_file,
|
|
226
|
+
"req:browse-files": _browse_files,
|
|
227
|
+
"req:upload-dataset": _upload_dataset,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def _handle_event(
|
|
232
|
+
widget: DatasetUploadWidget, content: dict[str, Any], buffer: object
|
|
233
|
+
) -> None:
|
|
234
|
+
try:
|
|
235
|
+
handler = _EVENT_HANDLERS[content["type"]]
|
|
236
|
+
except KeyError:
|
|
237
|
+
get_logger().warning("Received unknown event from widget: %s", content)
|
|
238
|
+
return
|
|
239
|
+
handler(widget, content["key"], content["payload"]) # type: ignore[operator]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: scicat_widget
|
|
3
|
+
Version: 26.2.0
|
|
4
|
+
Summary: SciCat dataset widget
|
|
5
|
+
Project-URL: Bug Tracker, https://github.com/jl-wynen/scicat_widget/issues
|
|
6
|
+
Project-URL: Source, https://github.com/jl-wynen/scicat_widget
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Framework :: Jupyter
|
|
9
|
+
Classifier: Framework :: Jupyter :: JupyterLab
|
|
10
|
+
Classifier: Framework :: Jupyter :: JupyterLab :: 4
|
|
11
|
+
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
|
|
12
|
+
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: anywidget>=0.9.21
|
|
22
|
+
Requires-Dist: ipykernel>=6.30.1
|
|
23
|
+
Requires-Dist: jupyter-host-file-picker>=26.2.1
|
|
24
|
+
Requires-Dist: pydantic>=2.12
|
|
25
|
+
Requires-Dist: scitacean>=26.2.0
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# widget
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
pip install widget
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
or with [uv](https://github.com/astral-sh/uv):
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
uv add widget
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Development
|
|
43
|
+
|
|
44
|
+
We recommend using [uv](https://github.com/astral-sh/uv) for development.
|
|
45
|
+
It will automatically manage virtual environments and dependencies for you.
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
uv run jupyter lab example.ipynb
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Alternatively, create and manage your own virtual environment:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
python -m venv .venv
|
|
55
|
+
source .venv/bin/activate
|
|
56
|
+
pip install -e ".[dev]"
|
|
57
|
+
jupyter lab example.ipynb
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The widget front-end code bundles it's JavaScript dependencies. After setting up Python,
|
|
61
|
+
make sure to install these dependencies locally:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm install
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
While developing, you can run the following in a separate terminal to automatically
|
|
68
|
+
rebuild JavaScript as you make changes:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
npm run dev
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Open `example.ipynb` in JupyterLab, VS Code, or your favorite editor
|
|
75
|
+
to start developing. Changes made in `js/` will be reflected
|
|
76
|
+
in the notebook.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
scicat_widget/__init__.py,sha256=WlmgkZkM4gZ_YsxNxozR5tkumxxiua02-aYqJEKtBHE,350
|
|
2
|
+
scicat_widget/_logging.py,sha256=LvyTlmCcjvW84qbh1PZ45ffV30puVHj1hMyYxSvPHYE,284
|
|
3
|
+
scicat_widget/_model.py,sha256=n4iRjoqmq9Zn-YQuCHHZWzK8vnia90ydql5UTNw6rOQ,633
|
|
4
|
+
scicat_widget/_scicat_api.py,sha256=4hpxTzpqDZKhNsnlBCzcRRypNsKkNbdkzlx_n9bFNAE,2250
|
|
5
|
+
scicat_widget/_upload.py,sha256=HN94n9MzX2y8cQn9TQveAsqgD-jC-ERi6yf5jVbO_jo,4299
|
|
6
|
+
scicat_widget/_widgets.py,sha256=mMRh96qm9U3WnpXcr1lhsKeLGiaNJuoUvAZJq4P8nSs,8191
|
|
7
|
+
scicat_widget/_static/assets.js,sha256=QZ5rNcN8e97sjgP-wCR1XnFNQa1O7NoM_BdCVnBW9UY,2910
|
|
8
|
+
scicat_widget/_static/comm.js,sha256=6UwxA1ccqPV73B3g9yIrOPoCGjQTKQJv0GDm8BUf3No,984
|
|
9
|
+
scicat_widget/_static/datasetUploadWidget.css,sha256=wYQ1BMHUCBDnlE8CPf1wrshX5COUohNyM_gvpn7A8bw,10099
|
|
10
|
+
scicat_widget/_static/datasetUploadWidget.js,sha256=LJoZABTi0TFQInUUoCxmgUu75h5j_NZr4TOe96ZdUNE,55408
|
|
11
|
+
scicat_widget/_static/datasetWidget.js,sha256=CKhXerCNSD8CfWvUzNJm1Zxz3ywFEmqKezeN7WV-ioU,36606
|
|
12
|
+
scicat_widget/_static/filesWidget.js,sha256=jozL1oNdPBuUZRPUbcej1FLJa0PE6Or3w1Izv3kQkDw,13054
|
|
13
|
+
scicat_widget/_static/forms.js,sha256=MzyszfU67ClsHBG1814HMnlnYwVFsubODKKFTM0F3aU,3297
|
|
14
|
+
scicat_widget/_static/inputWidgets.js,sha256=wDRRdD-D2AWFImZDj9CCcMNVBTBwA9PuuDgT22RDosc,35756
|
|
15
|
+
scicat_widget/_static/models.js,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
scicat_widget/_static/tabs.js,sha256=C7uNTKCRb58vFuFE7oR3AOF3jKFZylza0WsWr0gK_ME,5247
|
|
17
|
+
scicat_widget/_static/validation.js,sha256=dmx1Jjv7mbRADH3ahFNZhgU-jgPDfiNp9lrfooLmUQs,8245
|
|
18
|
+
scicat_widget-26.2.0.dist-info/METADATA,sha256=a566z-BH6PgEll80wAj7ukXSjzj0nQ1t6CmsiVumgII,2027
|
|
19
|
+
scicat_widget-26.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
20
|
+
scicat_widget-26.2.0.dist-info/licenses/LICENSE,sha256=ndDq9N2UaG0rgQ2OEjZeQU0NzuycrQW9is6FqVRSw6s,1522
|
|
21
|
+
scicat_widget-26.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, SciCat Project
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|