@startinblox/core 2.0.6-beta.6 → 2.0.6-beta.8

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.
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-B7CtE5CD.js";
4
+ import { g as getDefaultExportFromCjs, S as StoreService, b as base_context, f as formatAttributesToServerPaginationOptions, m as mergeServerSearchOptions, a as formatAttributesToServerSearchOptions, c as StoreType, d as StoreFactory, h as hasSetLocalData, e as hasQueryIndex, __tla as __tla_0 } from "./store-D6BkvCFg.js";
5
5
  import { d as defineComponent, n as normalizeContext, u as uniqID, f as fuzzyCompare, a as asyncQuerySelector, i as importInlineCSS, b as importCSS, c as doesResourceContainList, e as findClosingBracketMatchIndex, p as parseFieldsString, g as evalTemplateString, h as compare, j as generalComparator, t as transformArrayToContainer, s as setDeepProperty } from "./helpers-vZrb1UDN.js";
6
+ import { __tla as __tla_1 } from "./store-D6BkvCFg.js";
7
+ import { A, D } from "./store-D6BkvCFg.js";
6
8
  import { k } from "./helpers-vZrb1UDN.js";
7
9
  let index$4, BaseWidgetMixin, index$3, CounterMixin, EdcAssetsDisplay, EdcCatalogDisplay, EdcFederatedCatalogDisplay, FederationMixin, FilterMixin, GrouperMixin, HighlighterMixin, ListMixin, NextMixin, PaginateMixin, RequiredMixin, Sib, SolidAcChecker, SolidDelete, SolidDisplay, SolidForm, SolidFormSearch, SolidLang, SolidMemberAdd, SolidMemberDelete, SolidMembership, SolidTable, SolidTemplateElement, SolidWidget, SorterMixin, StoreMixin, index$2, index$1, index, TranslationMixin, ValidationMixin, WidgetMixin, x, o$2, newWidgetFactory, B, o$1, m, widgetFactory;
8
10
  let __tla = Promise.all([
@@ -11,6 +13,12 @@ let __tla = Promise.all([
11
13
  return __tla_0;
12
14
  } catch {
13
15
  }
16
+ })(),
17
+ (() => {
18
+ try {
19
+ return __tla_1;
20
+ } catch {
21
+ }
14
22
  })()
15
23
  ]).then(async () => {
16
24
  var _a2;
@@ -1115,7 +1123,7 @@ Component: ${componentName}
1115
1123
  }, b[d$1("elementProperties")] = /* @__PURE__ */ new Map(), b[d$1("finalized")] = /* @__PURE__ */ new Map(), p$1 == null ? void 0 : p$1({
1116
1124
  ReactiveElement: b
1117
1125
  }), (a$1.reactiveElementVersions ?? (a$1.reactiveElementVersions = [])).push("2.0.4");
1118
- let t$1, i$4, s$2, e$2, h$2, o$3, n$2, r$2, l, c$2, a, u, d, f$2, v, _, m$1, p, g, $, y, T, E, A, C;
1126
+ let t$1, i$4, s$2, e$2, h$2, o$3, n$2, r$2, l, c$2, a, u, d, f$2, v, _, m$1, p, g, $, y, T, E, A2, C;
1119
1127
  t$1 = globalThis;
1120
1128
  i$4 = t$1.trustedTypes;
1121
1129
  s$2 = i$4 ? i$4.createPolicy("lit-html", {
@@ -1147,7 +1155,7 @@ Component: ${componentName}
1147
1155
  x = y(1);
1148
1156
  T = Symbol.for("lit-noChange");
1149
1157
  E = Symbol.for("lit-nothing");
1150
- A = /* @__PURE__ */ new WeakMap();
1158
+ A2 = /* @__PURE__ */ new WeakMap();
1151
1159
  C = r$2.createTreeWalker(r$2, 129);
1152
1160
  function P$1(t2, i2) {
1153
1161
  if (!a(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array");
@@ -1299,8 +1307,8 @@ Component: ${componentName}
1299
1307
  }
1300
1308
  }
1301
1309
  _$AC(t2) {
1302
- let i2 = A.get(t2.strings);
1303
- return void 0 === i2 && A.set(t2.strings, i2 = new N(t2)), i2;
1310
+ let i2 = A2.get(t2.strings);
1311
+ return void 0 === i2 && A2.set(t2.strings, i2 = new N(t2)), i2;
1304
1312
  }
1305
1313
  k(t2) {
1306
1314
  a(this._$AH) || (this._$AH = [], this._$AR());
@@ -2703,6 +2711,46 @@ Component: ${componentName}
2703
2711
  }, "SolidDelete:render")
2704
2712
  };
2705
2713
  Sib.register(SolidDelete);
2714
+ class ProviderRegistry {
2715
+ constructor(initialProviders) {
2716
+ __publicField(this, "providers", /* @__PURE__ */ new Map());
2717
+ if (initialProviders) {
2718
+ for (const provider of initialProviders) {
2719
+ this.addProvider(provider);
2720
+ }
2721
+ }
2722
+ }
2723
+ addProvider(provider) {
2724
+ this.providers.set(provider.protocolAddress, provider);
2725
+ }
2726
+ getProviderByAddress(protocolAddress) {
2727
+ return this.providers.get(protocolAddress);
2728
+ }
2729
+ getProviderByParticipantId(participantId) {
2730
+ return Array.from(this.providers.values()).find((provider) => provider.participantId === participantId);
2731
+ }
2732
+ getAllProviders() {
2733
+ return Array.from(this.providers.values());
2734
+ }
2735
+ removeProvider(protocolAddress) {
2736
+ return this.providers.delete(protocolAddress);
2737
+ }
2738
+ updateProviderStatus(protocolAddress, status) {
2739
+ const provider = this.providers.get(protocolAddress);
2740
+ if (provider) {
2741
+ provider.status = status;
2742
+ provider.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
2743
+ }
2744
+ }
2745
+ static fromConfig(config2) {
2746
+ return new ProviderRegistry(config2.providers);
2747
+ }
2748
+ toConfig() {
2749
+ return {
2750
+ providers: this.getAllProviders()
2751
+ };
2752
+ }
2753
+ }
2706
2754
  const ActionMixin = {
2707
2755
  name: "action-mixin",
2708
2756
  attributes: {
@@ -99792,429 +99840,8 @@ ${escapeText(this.code(index2, length))}
99792
99840
  return field.startsWith("@") ? field.slice(1, field.length) : field;
99793
99841
  }
99794
99842
  };
99795
- EdcAssetsDisplay = {
99796
- name: "edc-assets-display",
99797
- use: [
99798
- WidgetMixin,
99799
- AttributeBinderMixin
99800
- ],
99801
- attributes: {
99802
- connectorUri: {
99803
- type: String,
99804
- default: null,
99805
- callback: function(value) {
99806
- if (value && this.apiKey) {
99807
- this.fetchAssets();
99808
- }
99809
- }
99810
- },
99811
- apiKey: {
99812
- type: String,
99813
- default: null,
99814
- callback: function(value) {
99815
- if (value && this.connectorUri) {
99816
- this.fetchAssets();
99817
- }
99818
- }
99819
- },
99820
- defaultWidget: {
99821
- type: String,
99822
- default: "edc-asset-item"
99823
- }
99824
- },
99825
- initialState: {
99826
- assets: [],
99827
- loading: false,
99828
- error: null
99829
- },
99830
- created() {
99831
- if (this.connectorUri && this.apiKey) {
99832
- this.fetchAssets();
99833
- }
99834
- },
99835
- async fetchAssets() {
99836
- if (!this.connectorUri || !this.apiKey) return;
99837
- this.loading = true;
99838
- this.error = null;
99839
- this.render();
99840
- try {
99841
- const config2 = {
99842
- type: StoreType.DataspaceConnector,
99843
- endpoint: this.connectorUri,
99844
- catalogEndpoint: `${this.connectorUri}/v3/catalog/request`,
99845
- contractNegotiationEndpoint: `${this.connectorUri}/v3/contractnegotiations`,
99846
- transferProcessEndpoint: `${this.connectorUri}/v3/transferprocesses`,
99847
- assetsEndpoint: `${this.connectorUri}/v3/assets/request`,
99848
- authMethod: "edc-api-key",
99849
- edcApiKey: this.apiKey,
99850
- retryAttempts: 3,
99851
- timeout: 3e4
99852
- };
99853
- const store2 = StoreFactory.create(config2);
99854
- const assetsRaw = await store2.getAssets();
99855
- this.assets = Array.isArray(assetsRaw) ? assetsRaw : assetsRaw ? [
99856
- assetsRaw
99857
- ] : [];
99858
- } catch (error2) {
99859
- console.error("Failed to fetch EDC assets:", error2);
99860
- this.error = error2.message;
99861
- this.assets = [];
99862
- } finally {
99863
- this.loading = false;
99864
- this.render();
99865
- }
99866
- },
99867
- render() {
99868
- if (this.loading) {
99869
- B(x`<div class="loading">Loading assets...</div>`, this.element);
99870
- return;
99871
- }
99872
- if (this.error) {
99873
- B(x`<div class="error">Error: ${this.error}</div>`, this.element);
99874
- return;
99875
- }
99876
- if (!this.assets || this.assets.length === 0) {
99877
- B(x`<div class="empty">No assets found</div>`, this.element);
99878
- return;
99879
- }
99880
- const template = x`
99881
- <div class="edc-assets-list">
99882
- ${this.assets.map((asset) => {
99883
- var _a3, _b, _c, _d;
99884
- return x`
99885
- <div class="edc-asset-item" data-asset-id="${asset["@id"]}">
99886
- <h3 class="asset-title">
99887
- ${asset["dcterms:title"] || ((_a3 = asset.properties) == null ? void 0 : _a3.name) || asset["@id"]}
99888
- </h3>
99889
- ${asset["dcterms:description"] || ((_b = asset.properties) == null ? void 0 : _b.description) ? x`<p class="asset-description">
99890
- ${asset["dcterms:description"] || ((_c = asset.properties) == null ? void 0 : _c.description)}
99891
- </p>` : ""}
99892
- <div class="asset-metadata">
99893
- <span class="asset-id">ID: ${asset["@id"]}</span>
99894
- ${((_d = asset.properties) == null ? void 0 : _d["https://w3id.org/edc/v0.0.1/ns/type"]) ? x`<span class="asset-type">
99895
- Type: ${asset.properties["https://w3id.org/edc/v0.0.1/ns/type"]}
99896
- </span>` : ""}
99897
- </div>
99898
- </div>
99899
- `;
99900
- })}
99901
- </div>
99902
- `;
99903
- B(template, this.element);
99904
- }
99905
- };
99906
- Sib.register(EdcAssetsDisplay);
99907
- EdcCatalogDisplay = {
99908
- name: "edc-catalog-display",
99909
- use: [
99910
- WidgetMixin,
99911
- AttributeBinderMixin
99912
- ],
99913
- attributes: {
99914
- connectorUri: {
99915
- type: String,
99916
- default: null,
99917
- callback: function(value) {
99918
- if (value && this.apiKey && this.counterPartyAddress) {
99919
- this.fetchCatalog();
99920
- }
99921
- }
99922
- },
99923
- apiKey: {
99924
- type: String,
99925
- default: null,
99926
- callback: function(value) {
99927
- if (value && this.connectorUri && this.counterPartyAddress) {
99928
- this.fetchCatalog();
99929
- }
99930
- }
99931
- },
99932
- counterPartyAddress: {
99933
- type: String,
99934
- default: null,
99935
- callback: function(value) {
99936
- if (value && this.connectorUri && this.apiKey) {
99937
- this.fetchCatalog();
99938
- }
99939
- }
99940
- },
99941
- defaultWidget: {
99942
- type: String,
99943
- default: "edc-dataset-item"
99944
- }
99945
- },
99946
- initialState: {
99947
- catalog: null,
99948
- datasets: [],
99949
- loading: false,
99950
- error: null,
99951
- negotiations: /* @__PURE__ */ new Map(),
99952
- store: null
99953
- },
99954
- created() {
99955
- if (this.connectorUri && this.apiKey && this.counterPartyAddress) {
99956
- this.fetchCatalog();
99957
- }
99958
- },
99959
- async fetchCatalog() {
99960
- if (!this.connectorUri || !this.apiKey || !this.counterPartyAddress) return;
99961
- this.loading = true;
99962
- this.error = null;
99963
- this.render();
99964
- try {
99965
- const config2 = {
99966
- type: StoreType.DataspaceConnector,
99967
- endpoint: this.connectorUri,
99968
- catalogEndpoint: `${this.connectorUri}/v3/catalog/request`,
99969
- contractNegotiationEndpoint: `${this.connectorUri}/v3/contractnegotiations`,
99970
- transferProcessEndpoint: `${this.connectorUri}/v3/transferprocesses`,
99971
- authMethod: "edc-api-key",
99972
- edcApiKey: this.apiKey,
99973
- retryAttempts: 8,
99974
- timeout: 1e4
99975
- };
99976
- const store2 = StoreFactory.create(config2);
99977
- const catalog = await store2.getCatalog(this.counterPartyAddress);
99978
- this.catalog = catalog;
99979
- this.datasets = (catalog == null ? void 0 : catalog["dcat:dataset"]) || [];
99980
- this.store = store2;
99981
- } catch (error2) {
99982
- console.error("Failed to fetch EDC catalog:", error2);
99983
- this.error = error2.message;
99984
- this.catalog = null;
99985
- this.datasets = [];
99986
- } finally {
99987
- this.loading = false;
99988
- this.render();
99989
- }
99990
- },
99991
- async negotiateAccess(dataset) {
99992
- if (!dataset["odrl:hasPolicy"] || dataset["odrl:hasPolicy"].length === 0) {
99993
- console.error("No policies available for dataset:", dataset["@id"]);
99994
- return;
99995
- }
99996
- try {
99997
- const offer = dataset["odrl:hasPolicy"][0];
99998
- const offerId = offer["@id"];
99999
- const assetId = dataset["@id"];
100000
- this.negotiations.set(assetId, {
100001
- status: "negotiating",
100002
- offerId
100003
- });
100004
- this.render();
100005
- if (!this.store) {
100006
- console.error("Store not available for negotiation");
100007
- return;
100008
- }
100009
- const store2 = this.store;
100010
- const modifiedOffer = {
100011
- ...offer,
100012
- target: assetId
100013
- };
100014
- const negotiationId = await store2.initiateNegotiation(this.counterPartyAddress, assetId, modifiedOffer);
100015
- this.negotiations.set(assetId, {
100016
- status: "pending",
100017
- negotiationId,
100018
- offerId
100019
- });
100020
- this.render();
100021
- this.pollNegotiationStatus(assetId, negotiationId);
100022
- } catch (error2) {
100023
- console.error("Contract negotiation failed:", error2);
100024
- this.negotiations.set(dataset["@id"], {
100025
- status: "failed",
100026
- error: error2.message
100027
- });
100028
- this.render();
100029
- }
100030
- },
100031
- async pollNegotiationStatus(assetId, negotiationId) {
100032
- const maxAttempts = 60;
100033
- const pollInterval = 5e3;
100034
- for (let attempt = 0; attempt < maxAttempts; attempt++) {
100035
- try {
100036
- if (!this.store) {
100037
- console.error("Store not available for polling");
100038
- return;
100039
- }
100040
- const store2 = this.store;
100041
- const status = await store2.getNegotiationStatus(negotiationId);
100042
- this.negotiations.set(assetId, {
100043
- status: "pending",
100044
- negotiationId,
100045
- currentState: status.state,
100046
- attempt: attempt + 1,
100047
- maxAttempts
100048
- });
100049
- this.render();
100050
- if (status.state === "FINALIZED" || status.state === "AGREED") {
100051
- this.negotiations.set(assetId, {
100052
- status: "granted",
100053
- negotiationId,
100054
- contractId: status.contractAgreementId || negotiationId
100055
- });
100056
- this.render();
100057
- return;
100058
- }
100059
- if (status.state === "TERMINATED") {
100060
- this.negotiations.set(assetId, {
100061
- status: "failed",
100062
- error: status.errorDetail || "Negotiation terminated"
100063
- });
100064
- this.render();
100065
- return;
100066
- }
100067
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
100068
- } catch (error2) {
100069
- console.error(`Error polling negotiation status (attempt ${attempt + 1}):`, error2);
100070
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
100071
- }
100072
- }
100073
- this.negotiations.set(assetId, {
100074
- status: "failed",
100075
- error: "Negotiation timeout after 5 minutes - may still be processing on provider side"
100076
- });
100077
- this.render();
100078
- },
100079
- render() {
100080
- if (this.loading) {
100081
- B(x`<div class="loading">Loading catalog...</div>`, this.element);
100082
- return;
100083
- }
100084
- if (this.error) {
100085
- B(x`<div class="error">Error: ${this.error}</div>`, this.element);
100086
- return;
100087
- }
100088
- if (!this.datasets || this.datasets.length === 0) {
100089
- B(x`<div class="empty">No datasets found in catalog</div>`, this.element);
100090
- return;
100091
- }
100092
- const template = x`
100093
- <div class="edc-catalog-info">
100094
- ${this.catalog ? x`
100095
- <div class="catalog-header">
100096
- <h2>Catalog: ${this.catalog["@id"]}</h2>
100097
- <p>Provider: ${this.catalog.participantId}</p>
100098
- <p>Datasets: ${this.datasets.length}</p>
100099
- </div>
100100
- ` : ""}
100101
- </div>
100102
- <div class="edc-datasets-list">
100103
- ${this.datasets.map((dataset) => {
100104
- var _a3, _b, _c, _d, _e;
100105
- return x`
100106
- <div class="edc-dataset-item" data-dataset-id="${dataset["@id"]}">
100107
- <h3 class="dataset-title">
100108
- ${dataset["dcterms:title"] || ((_a3 = dataset.properties) == null ? void 0 : _a3.name) || dataset["@id"]}
100109
- </h3>
100110
- ${dataset["dcterms:description"] || ((_b = dataset.properties) == null ? void 0 : _b.description) ? x`<p class="dataset-description">
100111
- ${dataset["dcterms:description"] || ((_c = dataset.properties) == null ? void 0 : _c.description)}
100112
- </p>` : ""}
100113
- <div class="dataset-metadata">
100114
- <span class="dataset-id">ID: ${dataset["@id"]}</span>
100115
- ${dataset["dcterms:creator"] ? x`<span class="dataset-creator">Creator: ${dataset["dcterms:creator"]}</span>` : ""}
100116
- ${((_d = dataset["dcat:keyword"]) == null ? void 0 : _d.length) > 0 ? x`<span class="dataset-keywords">Keywords: ${dataset["dcat:keyword"].join(", ")}</span>` : ""}
100117
- ${((_e = dataset["odrl:hasPolicy"]) == null ? void 0 : _e.length) > 0 ? x`<span class="dataset-policies">Policies: ${dataset["odrl:hasPolicy"].length}</span>` : ""}
100118
- </div>
100119
- <div class="dataset-actions">
100120
- ${this.renderNegotiationButton(dataset)}
100121
- </div>
100122
- </div>
100123
- `;
100124
- })}
100125
- </div>
100126
- `;
100127
- B(template, this.element);
100128
- },
100129
- renderNegotiationButton(dataset) {
100130
- const assetId = dataset["@id"];
100131
- const negotiation = this.negotiations.get(assetId);
100132
- if (!dataset["odrl:hasPolicy"] || dataset["odrl:hasPolicy"].length === 0) {
100133
- return x`<span class="no-policy">No policies available</span>`;
100134
- }
100135
- if (negotiation) {
100136
- switch (negotiation.status) {
100137
- case "negotiating":
100138
- return x`<button class="negotiate-btn negotiating" disabled>
100139
- Negotiating...
100140
- </button>`;
100141
- case "pending":
100142
- return x`<div class="negotiation-info">
100143
- <span class="negotiation-id">Negotiation: ${negotiation.negotiationId}</span>
100144
- <span class="negotiation-status pending">
100145
- ${negotiation.currentState || "Pending"}
100146
- ${negotiation.attempt ? `(${negotiation.attempt}/${negotiation.maxAttempts})` : ""}
100147
- </span>
100148
- </div>`;
100149
- case "granted":
100150
- return x`<div class="negotiation-success">
100151
- <span class="access-granted">✅ Access Granted</span>
100152
- <span class="contract-id">Contract: ${negotiation.contractId}</span>
100153
- <button class="api-ready-btn" disabled>
100154
- API Ready
100155
- </button>
100156
- </div>`;
100157
- case "failed":
100158
- return x`<div class="negotiation-error">
100159
- <span>Failed: ${negotiation.error}</span>
100160
- <button class="negotiate-btn retry" @click=${() => this.negotiateAccess(dataset)}>
100161
- Retry
100162
- </button>
100163
- </div>`;
100164
- default:
100165
- return x`<button class="negotiate-btn" @click=${() => this.negotiateAccess(dataset)}>
100166
- Negotiate Access
100167
- </button>`;
100168
- }
100169
- }
100170
- return x`<button class="negotiate-btn" @click=${() => this.negotiateAccess(dataset)}>
100171
- Negotiate Access (${dataset["odrl:hasPolicy"].length} ${dataset["odrl:hasPolicy"].length === 1 ? "offer" : "offers"})
100172
- </button>`;
100173
- }
100174
- };
100175
- Sib.register(EdcCatalogDisplay);
100176
- class ProviderRegistry {
100177
- constructor(initialProviders) {
100178
- __publicField(this, "providers", /* @__PURE__ */ new Map());
100179
- if (initialProviders) {
100180
- for (const provider of initialProviders) {
100181
- this.addProvider(provider);
100182
- }
100183
- }
100184
- }
100185
- addProvider(provider) {
100186
- this.providers.set(provider.protocolAddress, provider);
100187
- }
100188
- getProviderByAddress(protocolAddress) {
100189
- return this.providers.get(protocolAddress);
100190
- }
100191
- getProviderByParticipantId(participantId) {
100192
- return Array.from(this.providers.values()).find((provider) => provider.participantId === participantId);
100193
- }
100194
- getAllProviders() {
100195
- return Array.from(this.providers.values());
100196
- }
100197
- removeProvider(protocolAddress) {
100198
- return this.providers.delete(protocolAddress);
100199
- }
100200
- updateProviderStatus(protocolAddress, status) {
100201
- const provider = this.providers.get(protocolAddress);
100202
- if (provider) {
100203
- provider.status = status;
100204
- provider.lastSeen = (/* @__PURE__ */ new Date()).toISOString();
100205
- }
100206
- }
100207
- static fromConfig(config2) {
100208
- return new ProviderRegistry(config2.providers);
100209
- }
100210
- toConfig() {
100211
- return {
100212
- providers: this.getAllProviders()
100213
- };
100214
- }
100215
- }
100216
99843
  EdcFederatedCatalogDisplay = {
100217
- name: "edc-federated-catalog-display",
99844
+ name: "dsp-catalog-display",
100218
99845
  use: [
100219
99846
  WidgetMixin,
100220
99847
  AttributeBinderMixin
@@ -100257,6 +99884,18 @@ ${escapeText(this.code(index2, length))}
100257
99884
  }
100258
99885
  }
100259
99886
  },
99887
+ apiGateway: {
99888
+ type: String,
99889
+ default: null,
99890
+ callback: function(value) {
99891
+ try {
99892
+ this._apiGatewayConfig = value ? JSON.parse(value) : null;
99893
+ } catch (error2) {
99894
+ console.error("Failed to parse api-gateway JSON:", error2);
99895
+ this._apiGatewayConfig = null;
99896
+ }
99897
+ }
99898
+ },
100260
99899
  defaultWidget: {
100261
99900
  type: String,
100262
99901
  default: "edc-federated-dataset-item"
@@ -100278,6 +99917,7 @@ ${escapeText(this.code(index2, length))}
100278
99917
  negotiations: /* @__PURE__ */ new Map(),
100279
99918
  stores: /* @__PURE__ */ new Map(),
100280
99919
  _providersArray: [],
99920
+ _apiGatewayConfig: null,
100281
99921
  providerStats: /* @__PURE__ */ new Map(),
100282
99922
  selectedProviders: /* @__PURE__ */ new Set(),
100283
99923
  searchQuery: "",
@@ -100615,6 +100255,151 @@ ${escapeText(this.code(index2, length))}
100615
100255
  });
100616
100256
  this.render();
100617
100257
  },
100258
+ async getKeycloakAccessToken() {
100259
+ if (!this._apiGatewayConfig) {
100260
+ throw new Error("API Gateway configuration not provided");
100261
+ }
100262
+ const { keycloakUrl, realm, clientId, clientSecret, username, password } = this._apiGatewayConfig;
100263
+ if (!keycloakUrl || !realm || !clientId || !clientSecret || !username || !password) {
100264
+ throw new Error("Incomplete API Gateway configuration");
100265
+ }
100266
+ const tokenUrl = `${keycloakUrl}/realms/${realm}/protocol/openid-connect/token`;
100267
+ const params = new URLSearchParams({
100268
+ grant_type: "password",
100269
+ client_id: clientId,
100270
+ client_secret: clientSecret,
100271
+ scope: "openid",
100272
+ username,
100273
+ password
100274
+ });
100275
+ const response = await fetch(tokenUrl, {
100276
+ method: "POST",
100277
+ headers: {
100278
+ "Content-Type": "application/x-www-form-urlencoded"
100279
+ },
100280
+ body: params.toString()
100281
+ });
100282
+ if (!response.ok) {
100283
+ const errorText = await response.text();
100284
+ throw new Error(`Failed to get Keycloak access token: ${response.status} - ${errorText}`);
100285
+ }
100286
+ const data = await response.json();
100287
+ return data.access_token;
100288
+ },
100289
+ async getApiGatewayToken(accessToken, contractAgreementId) {
100290
+ if (!this._apiGatewayConfig) {
100291
+ throw new Error("API Gateway configuration not provided");
100292
+ }
100293
+ const { apiGatewayBaseUrl } = this._apiGatewayConfig;
100294
+ if (!apiGatewayBaseUrl) {
100295
+ throw new Error("API Gateway base URL not configured");
100296
+ }
100297
+ const tokenUrl = `${apiGatewayBaseUrl}/token`;
100298
+ const response = await fetch(tokenUrl, {
100299
+ method: "POST",
100300
+ headers: {
100301
+ "Content-Type": "application/json",
100302
+ Authorization: `Bearer ${accessToken}`
100303
+ },
100304
+ body: JSON.stringify({
100305
+ agreementId: contractAgreementId
100306
+ })
100307
+ });
100308
+ if (!response.ok) {
100309
+ const errorText = await response.text();
100310
+ throw new Error(`Failed to get API Gateway token: ${response.status} - ${errorText}`);
100311
+ }
100312
+ const data = await response.json();
100313
+ return data.apiGatewayToken || data.token;
100314
+ },
100315
+ async accessDataViaApiGateway(federatedDataset, negotiation) {
100316
+ const { dataset, provider } = federatedDataset;
100317
+ const assetId = dataset["@id"];
100318
+ const negotiationKey = `${assetId}@${provider.address}`;
100319
+ try {
100320
+ this.negotiations.set(negotiationKey, {
100321
+ ...negotiation,
100322
+ status: "getting-api-gateway-token"
100323
+ });
100324
+ this.render();
100325
+ const keycloakAccessToken = await this.getKeycloakAccessToken();
100326
+ const apiGatewayToken = await this.getApiGatewayToken(keycloakAccessToken, negotiation.contractId);
100327
+ this.negotiations.set(negotiationKey, {
100328
+ ...negotiation,
100329
+ status: "granted",
100330
+ apiGatewayToken
100331
+ });
100332
+ this.render();
100333
+ } catch (error2) {
100334
+ console.error("API Gateway token retrieval failed:", error2);
100335
+ this.negotiations.set(negotiationKey, {
100336
+ ...negotiation,
100337
+ status: "granted",
100338
+ apiGatewayError: error2.message
100339
+ });
100340
+ this.render();
100341
+ }
100342
+ },
100343
+ async fetchDataViaApiGateway(federatedDataset, negotiation) {
100344
+ var _a3;
100345
+ const { dataset, provider } = federatedDataset;
100346
+ const assetId = dataset["@id"];
100347
+ const negotiationKey = `${assetId}@${provider.address}`;
100348
+ try {
100349
+ this.negotiations.set(negotiationKey, {
100350
+ ...negotiation,
100351
+ status: "accessing-data-via-gateway"
100352
+ });
100353
+ this.render();
100354
+ if (!negotiation.apiGatewayToken) {
100355
+ throw new Error("API Gateway token not available");
100356
+ }
100357
+ if (!((_a3 = this._apiGatewayConfig) == null ? void 0 : _a3.apiGatewayBaseUrl)) {
100358
+ throw new Error("API Gateway base URL not configured");
100359
+ }
100360
+ const distributionsRaw = dataset["dcat:distribution"] || [];
100361
+ const distributions = Array.isArray(distributionsRaw) ? distributionsRaw : [
100362
+ distributionsRaw
100363
+ ];
100364
+ let endpointUrl = "";
100365
+ if (distributions.length > 0 && distributions[0]["dcat:accessService"]) {
100366
+ endpointUrl = distributions[0]["dcat:accessService"]["dcat:endpointUrl"] || distributions[0]["dcat:accessService"];
100367
+ }
100368
+ if (!endpointUrl) {
100369
+ throw new Error("No endpoint URL found in dataset distribution");
100370
+ }
100371
+ const response = await fetch(endpointUrl, {
100372
+ method: "GET",
100373
+ headers: {
100374
+ "X-API-Gateway-Token": negotiation.apiGatewayToken
100375
+ }
100376
+ });
100377
+ if (!response.ok) {
100378
+ const errorText = await response.text();
100379
+ throw new Error(`Failed to fetch data via API Gateway: ${response.status} - ${errorText}`);
100380
+ }
100381
+ const data = await response.json();
100382
+ const preview = JSON.stringify(data, null, 2).substring(0, 500);
100383
+ alert(`Data retrieved successfully via API Gateway!
100384
+
100385
+ Preview (first 500 chars):
100386
+ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
100387
+ this.negotiations.set(negotiationKey, {
100388
+ ...negotiation,
100389
+ status: "granted"
100390
+ });
100391
+ this.render();
100392
+ } catch (error2) {
100393
+ console.error("Data access via API Gateway failed:", error2);
100394
+ this.negotiations.set(negotiationKey, {
100395
+ ...negotiation,
100396
+ status: "granted",
100397
+ dataAccessError: error2.message
100398
+ });
100399
+ this.render();
100400
+ alert(`Data access failed: ${error2.message}`);
100401
+ }
100402
+ },
100618
100403
  async initiateEDRTransfer(federatedDataset, negotiation) {
100619
100404
  const { dataset, provider } = federatedDataset;
100620
100405
  const assetId = dataset["@id"];
@@ -100889,15 +100674,15 @@ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
100889
100674
  <div class="federated-dataset-item" data-dataset-id="${dataset["@id"]}" data-provider="${provider.address}">
100890
100675
  <div class="dataset-header">
100891
100676
  <h3 class="dataset-title">
100892
- ${dataset["dcterms:title"] || dataset["dct:title"] || ((_a3 = dataset.properties) == null ? void 0 : _a3.name) || dataset["@id"]}
100677
+ ${dataset["dcterms:title"] || dataset["dct:title"] || dataset["dcat:service"]["dct:title"] || ((_a3 = dataset.properties) == null ? void 0 : _a3.name) || dataset["@id"]}
100893
100678
  </h3>
100894
100679
  <div class="provider-badge" style="background-color: ${provider.color || "#1976d2"}">
100895
100680
  ${provider.name}
100896
100681
  </div>
100897
100682
  </div>
100898
100683
 
100899
- ${dataset["rdfs:comment"] || ((_b = dataset.properties) == null ? void 0 : _b.description) ? x`<p class="dataset-description">
100900
- ${dataset["rdfs:comment"] || ((_c = dataset.properties) == null ? void 0 : _c.description)}
100684
+ ${dataset["rdfs:comment"] || dataset["dcat:service"]["rdfs:comment"] || ((_b = dataset.properties) == null ? void 0 : _b.description) ? x`<p class="dataset-description">
100685
+ ${dataset["rdfs:comment"] || dataset["dcat:service"]["rdfs:comment"] || ((_c = dataset.properties) == null ? void 0 : _c.description)}
100901
100686
  </p>` : ""}
100902
100687
 
100903
100688
  <div class="dataset-metadata">
@@ -100972,7 +100757,24 @@ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
100972
100757
  </div>` : ""}
100973
100758
  </div>`;
100974
100759
  }
100975
- case "granted":
100760
+ case "getting-api-gateway-token":
100761
+ return x`<div class="negotiation-info">
100762
+ <span class="negotiation-provider">Provider: ${provider.name}</span>
100763
+ <span class="contract-id">Contract: ${negotiation.contractId}</span>
100764
+ <span class="negotiation-status pending">
100765
+ <span class="spinner">🔑</span> Getting API Gateway Token...
100766
+ </span>
100767
+ </div>`;
100768
+ case "accessing-data-via-gateway":
100769
+ return x`<div class="negotiation-info">
100770
+ <span class="negotiation-provider">Provider: ${provider.name}</span>
100771
+ <span class="contract-id">Contract: ${negotiation.contractId}</span>
100772
+ <span class="negotiation-status pending">
100773
+ <span class="spinner">📡</span> Accessing Data via API Gateway...
100774
+ </span>
100775
+ </div>`;
100776
+ case "granted": {
100777
+ const useApiGateway = !!this._apiGatewayConfig;
100976
100778
  return x`<div class="negotiation-success">
100977
100779
  <span class="access-granted">✅ Access Granted via ${provider.name}</span>
100978
100780
  <span class="contract-id">Contract: ${negotiation.contractId}</span>
@@ -100982,19 +100784,39 @@ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
100982
100784
  🔄 Retry EDR
100983
100785
  </button>
100984
100786
  ` : ""}
100787
+ ${negotiation.apiGatewayError ? x`
100788
+ <span class="transfer-error">⚠️ ${negotiation.apiGatewayError}</span>
100789
+ <button class="negotiate-btn retry" @click=${() => this.accessDataViaApiGateway(item, negotiation)}>
100790
+ 🔄 Retry API Gateway
100791
+ </button>
100792
+ ` : ""}
100985
100793
  <div class="api-access-actions">
100986
- ${!negotiation.edrToken ? x`
100987
- <button class="negotiate-btn" @click=${() => this.initiateEDRTransfer(item, negotiation)}>
100988
- 🚀 Get EDR Token
100989
- </button>
100990
- ` : x`
100991
- <span class="edr-ready">🔑 EDR Token Ready</span>
100992
- <button class="negotiate-btn" @click=${() => this.accessData(item, negotiation)}>
100993
- 📁 Access Data
100994
- </button>
100995
- `}
100794
+ ${useApiGateway ? x`
100795
+ ${!negotiation.apiGatewayToken ? x`
100796
+ <button class="negotiate-btn" @click=${() => this.accessDataViaApiGateway(item, negotiation)}>
100797
+ 🔑 Get API Gateway Token
100798
+ </button>
100799
+ ` : x`
100800
+ <span class="edr-ready">🔑 API Gateway Token Ready</span>
100801
+ <button class="negotiate-btn" @click=${() => this.fetchDataViaApiGateway(item, negotiation)}>
100802
+ 📁 Access Data via API Gateway
100803
+ </button>
100804
+ `}
100805
+ ` : x`
100806
+ ${!negotiation.edrToken ? x`
100807
+ <button class="negotiate-btn" @click=${() => this.initiateEDRTransfer(item, negotiation)}>
100808
+ 🚀 Get EDR Token
100809
+ </button>
100810
+ ` : x`
100811
+ <span class="edr-ready">🔑 EDR Token Ready</span>
100812
+ <button class="negotiate-btn" @click=${() => this.accessData(item, negotiation)}>
100813
+ 📁 Access Data
100814
+ </button>
100815
+ `}
100816
+ `}
100996
100817
  </div>
100997
100818
  </div>`;
100819
+ }
100998
100820
  case "failed":
100999
100821
  return x`<div class="negotiation-error">
101000
100822
  <span>Failed with ${provider.name}: ${negotiation.error}</span>
@@ -101014,6 +100836,387 @@ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
101014
100836
  }
101015
100837
  };
101016
100838
  Sib.register(EdcFederatedCatalogDisplay);
100839
+ EdcAssetsDisplay = {
100840
+ name: "edc-assets-display",
100841
+ use: [
100842
+ WidgetMixin,
100843
+ AttributeBinderMixin
100844
+ ],
100845
+ attributes: {
100846
+ connectorUri: {
100847
+ type: String,
100848
+ default: null,
100849
+ callback: function(value) {
100850
+ if (value && this.apiKey) {
100851
+ this.fetchAssets();
100852
+ }
100853
+ }
100854
+ },
100855
+ apiKey: {
100856
+ type: String,
100857
+ default: null,
100858
+ callback: function(value) {
100859
+ if (value && this.connectorUri) {
100860
+ this.fetchAssets();
100861
+ }
100862
+ }
100863
+ },
100864
+ defaultWidget: {
100865
+ type: String,
100866
+ default: "edc-asset-item"
100867
+ }
100868
+ },
100869
+ initialState: {
100870
+ assets: [],
100871
+ loading: false,
100872
+ error: null
100873
+ },
100874
+ created() {
100875
+ if (this.connectorUri && this.apiKey) {
100876
+ this.fetchAssets();
100877
+ }
100878
+ },
100879
+ async fetchAssets() {
100880
+ if (!this.connectorUri || !this.apiKey) return;
100881
+ this.loading = true;
100882
+ this.error = null;
100883
+ this.render();
100884
+ try {
100885
+ const config2 = {
100886
+ type: StoreType.DataspaceConnector,
100887
+ endpoint: this.connectorUri,
100888
+ catalogEndpoint: `${this.connectorUri}/v3/catalog/request`,
100889
+ contractNegotiationEndpoint: `${this.connectorUri}/v3/contractnegotiations`,
100890
+ transferProcessEndpoint: `${this.connectorUri}/v3/transferprocesses`,
100891
+ assetsEndpoint: `${this.connectorUri}/v3/assets/request`,
100892
+ authMethod: "edc-api-key",
100893
+ edcApiKey: this.apiKey,
100894
+ retryAttempts: 3,
100895
+ timeout: 3e4
100896
+ };
100897
+ const store2 = StoreFactory.create(config2);
100898
+ const assetsRaw = await store2.getAssets();
100899
+ this.assets = Array.isArray(assetsRaw) ? assetsRaw : assetsRaw ? [
100900
+ assetsRaw
100901
+ ] : [];
100902
+ } catch (error2) {
100903
+ console.error("Failed to fetch EDC assets:", error2);
100904
+ this.error = error2.message;
100905
+ this.assets = [];
100906
+ } finally {
100907
+ this.loading = false;
100908
+ this.render();
100909
+ }
100910
+ },
100911
+ render() {
100912
+ if (this.loading) {
100913
+ B(x`<div class="loading">Loading assets...</div>`, this.element);
100914
+ return;
100915
+ }
100916
+ if (this.error) {
100917
+ B(x`<div class="error">Error: ${this.error}</div>`, this.element);
100918
+ return;
100919
+ }
100920
+ if (!this.assets || this.assets.length === 0) {
100921
+ B(x`<div class="empty">No assets found</div>`, this.element);
100922
+ return;
100923
+ }
100924
+ const template = x`
100925
+ <div class="edc-assets-list">
100926
+ ${this.assets.map((asset) => {
100927
+ var _a3, _b, _c, _d;
100928
+ return x`
100929
+ <div class="edc-asset-item" data-asset-id="${asset["@id"]}">
100930
+ <h3 class="asset-title">
100931
+ ${asset["dcterms:title"] || ((_a3 = asset.properties) == null ? void 0 : _a3.name) || asset["@id"]}
100932
+ </h3>
100933
+ ${asset["dcterms:description"] || ((_b = asset.properties) == null ? void 0 : _b.description) ? x`<p class="asset-description">
100934
+ ${asset["dcterms:description"] || ((_c = asset.properties) == null ? void 0 : _c.description)}
100935
+ </p>` : ""}
100936
+ <div class="asset-metadata">
100937
+ <span class="asset-id">ID: ${asset["@id"]}</span>
100938
+ ${((_d = asset.properties) == null ? void 0 : _d["https://w3id.org/edc/v0.0.1/ns/type"]) ? x`<span class="asset-type">
100939
+ Type: ${asset.properties["https://w3id.org/edc/v0.0.1/ns/type"]}
100940
+ </span>` : ""}
100941
+ </div>
100942
+ </div>
100943
+ `;
100944
+ })}
100945
+ </div>
100946
+ `;
100947
+ B(template, this.element);
100948
+ }
100949
+ };
100950
+ Sib.register(EdcAssetsDisplay);
100951
+ EdcCatalogDisplay = {
100952
+ name: "edc-catalog-display",
100953
+ use: [
100954
+ WidgetMixin,
100955
+ AttributeBinderMixin
100956
+ ],
100957
+ attributes: {
100958
+ connectorUri: {
100959
+ type: String,
100960
+ default: null,
100961
+ callback: function(value) {
100962
+ if (value && this.apiKey && this.counterPartyAddress) {
100963
+ this.fetchCatalog();
100964
+ }
100965
+ }
100966
+ },
100967
+ apiKey: {
100968
+ type: String,
100969
+ default: null,
100970
+ callback: function(value) {
100971
+ if (value && this.connectorUri && this.counterPartyAddress) {
100972
+ this.fetchCatalog();
100973
+ }
100974
+ }
100975
+ },
100976
+ counterPartyAddress: {
100977
+ type: String,
100978
+ default: null,
100979
+ callback: function(value) {
100980
+ if (value && this.connectorUri && this.apiKey) {
100981
+ this.fetchCatalog();
100982
+ }
100983
+ }
100984
+ },
100985
+ defaultWidget: {
100986
+ type: String,
100987
+ default: "edc-dataset-item"
100988
+ }
100989
+ },
100990
+ initialState: {
100991
+ catalog: null,
100992
+ datasets: [],
100993
+ loading: false,
100994
+ error: null,
100995
+ negotiations: /* @__PURE__ */ new Map(),
100996
+ store: null
100997
+ },
100998
+ created() {
100999
+ if (this.connectorUri && this.apiKey && this.counterPartyAddress) {
101000
+ this.fetchCatalog();
101001
+ }
101002
+ },
101003
+ async fetchCatalog() {
101004
+ if (!this.connectorUri || !this.apiKey || !this.counterPartyAddress) return;
101005
+ this.loading = true;
101006
+ this.error = null;
101007
+ this.render();
101008
+ try {
101009
+ const config2 = {
101010
+ type: StoreType.DataspaceConnector,
101011
+ endpoint: this.connectorUri,
101012
+ catalogEndpoint: `${this.connectorUri}/v3/catalog/request`,
101013
+ contractNegotiationEndpoint: `${this.connectorUri}/v3/contractnegotiations`,
101014
+ transferProcessEndpoint: `${this.connectorUri}/v3/transferprocesses`,
101015
+ authMethod: "edc-api-key",
101016
+ edcApiKey: this.apiKey,
101017
+ retryAttempts: 8,
101018
+ timeout: 1e4
101019
+ };
101020
+ const store2 = StoreFactory.create(config2);
101021
+ const catalog = await store2.getCatalog(this.counterPartyAddress);
101022
+ this.catalog = catalog;
101023
+ this.datasets = (catalog == null ? void 0 : catalog["dcat:dataset"]) || [];
101024
+ this.store = store2;
101025
+ } catch (error2) {
101026
+ console.error("Failed to fetch EDC catalog:", error2);
101027
+ this.error = error2.message;
101028
+ this.catalog = null;
101029
+ this.datasets = [];
101030
+ } finally {
101031
+ this.loading = false;
101032
+ this.render();
101033
+ }
101034
+ },
101035
+ async negotiateAccess(dataset) {
101036
+ if (!dataset["odrl:hasPolicy"] || dataset["odrl:hasPolicy"].length === 0) {
101037
+ console.error("No policies available for dataset:", dataset["@id"]);
101038
+ return;
101039
+ }
101040
+ try {
101041
+ const offer = dataset["odrl:hasPolicy"][0];
101042
+ const offerId = offer["@id"];
101043
+ const assetId = dataset["@id"];
101044
+ this.negotiations.set(assetId, {
101045
+ status: "negotiating",
101046
+ offerId
101047
+ });
101048
+ this.render();
101049
+ if (!this.store) {
101050
+ console.error("Store not available for negotiation");
101051
+ return;
101052
+ }
101053
+ const store2 = this.store;
101054
+ const modifiedOffer = {
101055
+ ...offer,
101056
+ target: assetId
101057
+ };
101058
+ const negotiationId = await store2.initiateNegotiation(this.counterPartyAddress, assetId, modifiedOffer);
101059
+ this.negotiations.set(assetId, {
101060
+ status: "pending",
101061
+ negotiationId,
101062
+ offerId
101063
+ });
101064
+ this.render();
101065
+ this.pollNegotiationStatus(assetId, negotiationId);
101066
+ } catch (error2) {
101067
+ console.error("Contract negotiation failed:", error2);
101068
+ this.negotiations.set(dataset["@id"], {
101069
+ status: "failed",
101070
+ error: error2.message
101071
+ });
101072
+ this.render();
101073
+ }
101074
+ },
101075
+ async pollNegotiationStatus(assetId, negotiationId) {
101076
+ const maxAttempts = 60;
101077
+ const pollInterval = 5e3;
101078
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
101079
+ try {
101080
+ if (!this.store) {
101081
+ console.error("Store not available for polling");
101082
+ return;
101083
+ }
101084
+ const store2 = this.store;
101085
+ const status = await store2.getNegotiationStatus(negotiationId);
101086
+ this.negotiations.set(assetId, {
101087
+ status: "pending",
101088
+ negotiationId,
101089
+ currentState: status.state,
101090
+ attempt: attempt + 1,
101091
+ maxAttempts
101092
+ });
101093
+ this.render();
101094
+ if (status.state === "FINALIZED" || status.state === "AGREED") {
101095
+ this.negotiations.set(assetId, {
101096
+ status: "granted",
101097
+ negotiationId,
101098
+ contractId: status.contractAgreementId || negotiationId
101099
+ });
101100
+ this.render();
101101
+ return;
101102
+ }
101103
+ if (status.state === "TERMINATED") {
101104
+ this.negotiations.set(assetId, {
101105
+ status: "failed",
101106
+ error: status.errorDetail || "Negotiation terminated"
101107
+ });
101108
+ this.render();
101109
+ return;
101110
+ }
101111
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
101112
+ } catch (error2) {
101113
+ console.error(`Error polling negotiation status (attempt ${attempt + 1}):`, error2);
101114
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
101115
+ }
101116
+ }
101117
+ this.negotiations.set(assetId, {
101118
+ status: "failed",
101119
+ error: "Negotiation timeout after 5 minutes - may still be processing on provider side"
101120
+ });
101121
+ this.render();
101122
+ },
101123
+ render() {
101124
+ if (this.loading) {
101125
+ B(x`<div class="loading">Loading catalog...</div>`, this.element);
101126
+ return;
101127
+ }
101128
+ if (this.error) {
101129
+ B(x`<div class="error">Error: ${this.error}</div>`, this.element);
101130
+ return;
101131
+ }
101132
+ if (!this.datasets || this.datasets.length === 0) {
101133
+ B(x`<div class="empty">No datasets found in catalog</div>`, this.element);
101134
+ return;
101135
+ }
101136
+ const template = x`
101137
+ <div class="edc-catalog-info">
101138
+ ${this.catalog ? x`
101139
+ <div class="catalog-header">
101140
+ <h2>Catalog: ${this.catalog["@id"]}</h2>
101141
+ <p>Provider: ${this.catalog.participantId}</p>
101142
+ <p>Datasets: ${this.datasets.length}</p>
101143
+ </div>
101144
+ ` : ""}
101145
+ </div>
101146
+ <div class="edc-datasets-list">
101147
+ ${this.datasets.map((dataset) => {
101148
+ var _a3, _b, _c, _d, _e;
101149
+ return x`
101150
+ <div class="edc-dataset-item" data-dataset-id="${dataset["@id"]}">
101151
+ <h3 class="dataset-title">
101152
+ ${dataset["dcterms:title"] || ((_a3 = dataset.properties) == null ? void 0 : _a3.name) || dataset["@id"]}
101153
+ </h3>
101154
+ ${dataset["dcterms:description"] || ((_b = dataset.properties) == null ? void 0 : _b.description) ? x`<p class="dataset-description">
101155
+ ${dataset["dcterms:description"] || ((_c = dataset.properties) == null ? void 0 : _c.description)}
101156
+ </p>` : ""}
101157
+ <div class="dataset-metadata">
101158
+ <span class="dataset-id">ID: ${dataset["@id"]}</span>
101159
+ ${dataset["dcterms:creator"] ? x`<span class="dataset-creator">Creator: ${dataset["dcterms:creator"]}</span>` : ""}
101160
+ ${((_d = dataset["dcat:keyword"]) == null ? void 0 : _d.length) > 0 ? x`<span class="dataset-keywords">Keywords: ${dataset["dcat:keyword"].join(", ")}</span>` : ""}
101161
+ ${((_e = dataset["odrl:hasPolicy"]) == null ? void 0 : _e.length) > 0 ? x`<span class="dataset-policies">Policies: ${dataset["odrl:hasPolicy"].length}</span>` : ""}
101162
+ </div>
101163
+ <div class="dataset-actions">
101164
+ ${this.renderNegotiationButton(dataset)}
101165
+ </div>
101166
+ </div>
101167
+ `;
101168
+ })}
101169
+ </div>
101170
+ `;
101171
+ B(template, this.element);
101172
+ },
101173
+ renderNegotiationButton(dataset) {
101174
+ const assetId = dataset["@id"];
101175
+ const negotiation = this.negotiations.get(assetId);
101176
+ if (!dataset["odrl:hasPolicy"] || dataset["odrl:hasPolicy"].length === 0) {
101177
+ return x`<span class="no-policy">No policies available</span>`;
101178
+ }
101179
+ if (negotiation) {
101180
+ switch (negotiation.status) {
101181
+ case "negotiating":
101182
+ return x`<button class="negotiate-btn negotiating" disabled>
101183
+ Negotiating...
101184
+ </button>`;
101185
+ case "pending":
101186
+ return x`<div class="negotiation-info">
101187
+ <span class="negotiation-id">Negotiation: ${negotiation.negotiationId}</span>
101188
+ <span class="negotiation-status pending">
101189
+ ${negotiation.currentState || "Pending"}
101190
+ ${negotiation.attempt ? `(${negotiation.attempt}/${negotiation.maxAttempts})` : ""}
101191
+ </span>
101192
+ </div>`;
101193
+ case "granted":
101194
+ return x`<div class="negotiation-success">
101195
+ <span class="access-granted">✅ Access Granted</span>
101196
+ <span class="contract-id">Contract: ${negotiation.contractId}</span>
101197
+ <button class="api-ready-btn" disabled>
101198
+ API Ready
101199
+ </button>
101200
+ </div>`;
101201
+ case "failed":
101202
+ return x`<div class="negotiation-error">
101203
+ <span>Failed: ${negotiation.error}</span>
101204
+ <button class="negotiate-btn retry" @click=${() => this.negotiateAccess(dataset)}>
101205
+ Retry
101206
+ </button>
101207
+ </div>`;
101208
+ default:
101209
+ return x`<button class="negotiate-btn" @click=${() => this.negotiateAccess(dataset)}>
101210
+ Negotiate Access
101211
+ </button>`;
101212
+ }
101213
+ }
101214
+ return x`<button class="negotiate-btn" @click=${() => this.negotiateAccess(dataset)}>
101215
+ Negotiate Access (${dataset["odrl:hasPolicy"].length} ${dataset["odrl:hasPolicy"].length === 1 ? "offer" : "offers"})
101216
+ </button>`;
101217
+ }
101218
+ };
101219
+ Sib.register(EdcCatalogDisplay);
101017
101220
  CounterMixin = {
101018
101221
  name: "counter-mixin",
101019
101222
  use: [],
@@ -103610,9 +103813,11 @@ ${preview}${JSON.stringify(data).length > 500 ? "..." : ""}`);
103610
103813
  });
103611
103814
  export {
103612
103815
  index$4 as AttributeMixins,
103816
+ A as AuthFetchResolver,
103613
103817
  BaseWidgetMixin,
103614
103818
  index$3 as CallbackMixins,
103615
103819
  CounterMixin,
103820
+ D as DEFAULT_AUTH_SELECTORS,
103616
103821
  EdcAssetsDisplay,
103617
103822
  EdcCatalogDisplay,
103618
103823
  EdcFederatedCatalogDisplay,