@singi-labs/sifa-sdk 0.12.56 → 0.12.57

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.cjs CHANGED
@@ -2378,6 +2378,32 @@ function countryCodeToFlag(code) {
2378
2378
  return String.fromCodePoint(a - 65 + 127462, b - 65 + 127462);
2379
2379
  }
2380
2380
 
2381
+ // src/format/location-segments.ts
2382
+ function clean(value) {
2383
+ const trimmed = value?.trim();
2384
+ return trimmed ? trimmed : null;
2385
+ }
2386
+ function locationSegments(loc, options = {}) {
2387
+ if (!loc) return [];
2388
+ const ordered = [
2389
+ { kind: "locality", value: clean(loc.locality ?? loc.city) },
2390
+ { kind: "region", value: clean(loc.region) },
2391
+ { kind: "country", value: clean(loc.country) }
2392
+ ];
2393
+ const segments = [];
2394
+ for (const { kind, value } of ordered) {
2395
+ if (value === null) continue;
2396
+ const previous = segments[segments.length - 1];
2397
+ if (previous && previous.label.toLowerCase() === value.toLowerCase()) continue;
2398
+ segments.push({
2399
+ kind,
2400
+ label: value,
2401
+ searchHref: kind === "country" && options.searchable !== false ? `/search?${new URLSearchParams({ country: value }).toString()}` : null
2402
+ });
2403
+ }
2404
+ return segments;
2405
+ }
2406
+
2381
2407
  // src/format/pds-utils.ts
2382
2408
  var BSKY_PROFILE_BASE = "https://bsky.app/profile/";
2383
2409
  var PDS_PROVIDERS = [
@@ -2659,27 +2685,27 @@ function meetsContrastAA(foreground, background) {
2659
2685
  }
2660
2686
 
2661
2687
  // src/import/presentation-csv.ts
2662
- function clean(value) {
2688
+ function clean2(value) {
2663
2689
  return (value ?? "").trim();
2664
2690
  }
2665
2691
  function parsePresentationDuration(input) {
2666
- const numbers = (clean(input).match(/\d+/g) ?? []).map((n) => Number.parseInt(n, 10)).filter((n) => Number.isInteger(n) && n > 0);
2692
+ const numbers = (clean2(input).match(/\d+/g) ?? []).map((n) => Number.parseInt(n, 10)).filter((n) => Number.isInteger(n) && n > 0);
2667
2693
  const min = numbers.at(0);
2668
2694
  if (min === void 0) return void 0;
2669
2695
  const max = numbers.at(1);
2670
2696
  return max !== void 0 && max >= min ? { minMinutes: min, maxMinutes: max } : { minMinutes: min };
2671
2697
  }
2672
2698
  function durationFromMinutes(minRaw, maxRaw) {
2673
- const min = Number.parseInt(clean(minRaw), 10);
2699
+ const min = Number.parseInt(clean2(minRaw), 10);
2674
2700
  if (!Number.isInteger(min) || min < 1) return void 0;
2675
- const max = Number.parseInt(clean(maxRaw), 10);
2701
+ const max = Number.parseInt(clean2(maxRaw), 10);
2676
2702
  return Number.isInteger(max) && max >= min ? { minMinutes: min, maxMinutes: max } : { minMinutes: min };
2677
2703
  }
2678
2704
  function parseIntendedAudiences(input, delimiter = ";") {
2679
- return clean(input).split(delimiter).map((s) => s.trim()).filter(Boolean);
2705
+ return clean2(input).split(delimiter).map((s) => s.trim()).filter(Boolean);
2680
2706
  }
2681
2707
  function stripHtmlToText(input) {
2682
- const text = clean(input).replace(/<\s*br\s*\/?>/gi, "\n").replace(/<\/\s*(p|div|li|h[1-6])\s*>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#0*39;|&apos;/gi, "'");
2708
+ const text = clean2(input).replace(/<\s*br\s*\/?>/gi, "\n").replace(/<\/\s*(p|div|li|h[1-6])\s*>/gi, "\n").replace(/<[^>]*>/g, "").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&quot;/gi, '"').replace(/&#0*39;|&apos;/gi, "'");
2683
2709
  return text.replace(/[ \t]+/g, " ").replace(/ *\n */g, "\n").replace(/\n{3,}/g, "\n\n").trim();
2684
2710
  }
2685
2711
  var ROLE_TOKENS = {
@@ -2691,7 +2717,7 @@ var ROLE_TOKENS = {
2691
2717
  host: "id.sifa.defs#host"
2692
2718
  };
2693
2719
  function normalizePresentationRole(value) {
2694
- const v = clean(value).toLowerCase();
2720
+ const v = clean2(value).toLowerCase();
2695
2721
  if (!v) return void 0;
2696
2722
  if (v.startsWith("id.sifa.defs#")) return v;
2697
2723
  const exact = ROLE_TOKENS[v];
@@ -2716,14 +2742,14 @@ var MODE_FRAGMENTS = {
2716
2742
  hybrid: "#hybrid"
2717
2743
  };
2718
2744
  function normalizePresentationMode(value) {
2719
- const v = clean(value).toLowerCase();
2745
+ const v = clean2(value).toLowerCase();
2720
2746
  if (!v) return void 0;
2721
2747
  if (v.startsWith("community.lexicon.calendar.event#")) return v;
2722
2748
  const fragment = MODE_FRAGMENTS[v];
2723
2749
  return fragment ? `community.lexicon.calendar.event${fragment}` : void 0;
2724
2750
  }
2725
2751
  function link(uri, type) {
2726
- const u = clean(uri);
2752
+ const u = clean2(uri);
2727
2753
  return u ? { uri: u, type } : void 0;
2728
2754
  }
2729
2755
  function presentationCsvRowToRecord(row) {
@@ -2735,12 +2761,12 @@ function presentationCsvRowToRecord(row) {
2735
2761
  link(row.recording_url, "id.sifa.defs#linkRecording"),
2736
2762
  link(row.writeup_url, "id.sifa.defs#linkWriteup")
2737
2763
  ].filter((l) => l !== void 0);
2738
- const record = { title: clean(row.title) };
2764
+ const record = { title: clean2(row.title) };
2739
2765
  if (description) record.description = description;
2740
2766
  if (duration) record.duration = duration;
2741
2767
  if (intendedAudiences.length) record.intendedAudiences = intendedAudiences;
2742
2768
  if (links.length) record.links = links;
2743
- return { key: clean(row.presentation_key) || void 0, record };
2769
+ return { key: clean2(row.presentation_key) || void 0, record };
2744
2770
  }
2745
2771
  function presentationDeliveryCsvRowToRecord(row) {
2746
2772
  const links = [
@@ -2748,10 +2774,10 @@ function presentationDeliveryCsvRowToRecord(row) {
2748
2774
  link(row.recording_url, "id.sifa.defs#linkRecording")
2749
2775
  ].filter((l) => l !== void 0);
2750
2776
  const record = {};
2751
- const title = clean(row.title);
2752
- const eventName = clean(row.event_name);
2753
- const date = clean(row.date);
2754
- const location = clean(row.location);
2777
+ const title = clean2(row.title);
2778
+ const eventName = clean2(row.event_name);
2779
+ const date = clean2(row.date);
2780
+ const location = clean2(row.location);
2755
2781
  const role = normalizePresentationRole(row.role);
2756
2782
  const mode = normalizePresentationMode(row.mode);
2757
2783
  if (title) record.title = title;
@@ -2761,7 +2787,7 @@ function presentationDeliveryCsvRowToRecord(row) {
2761
2787
  if (location) record.location = location;
2762
2788
  if (mode) record.mode = mode;
2763
2789
  if (links.length) record.links = links;
2764
- return { presentationKey: clean(row.presentation_key) || void 0, record };
2790
+ return { presentationKey: clean2(row.presentation_key) || void 0, record };
2765
2791
  }
2766
2792
 
2767
2793
  // src/cards/app-url-patterns.ts
@@ -5598,7 +5624,7 @@ function describeSifaRecord(collection, value) {
5598
5624
  }
5599
5625
 
5600
5626
  // src/index.ts
5601
- var SIFA_SDK_VERSION = "0.12.56";
5627
+ var SIFA_SDK_VERSION = "0.12.57";
5602
5628
 
5603
5629
  exports.ACTIVITY_TIERS = ACTIVITY_TIERS;
5604
5630
  exports.ACTIVITY_VERBS = ACTIVITY_VERBS;
@@ -5783,6 +5809,7 @@ exports.isVisibleActivityItem = isVisibleActivityItem;
5783
5809
  exports.languageTagSchema = languageTagSchema;
5784
5810
  exports.lexiconDateExtractor = lexiconDateExtractor;
5785
5811
  exports.limitCombiningMarks = limitCombiningMarks;
5812
+ exports.locationSegments = locationSegments;
5786
5813
  exports.looksLikeDomain = looksLikeDomain;
5787
5814
  exports.makeGraphFollowRecordSchema = makeGraphFollowRecordSchema;
5788
5815
  exports.maxGraphemes = maxGraphemes;