sanity 6.4.0 → 6.4.1-next.2

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.
@@ -1,10 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { c } from "react/compiler-runtime";
3
- import { useRouter, StateLink } from "sanity/router";
3
+ import { useRouter, IntentLink, StateLink } from "sanity/router";
4
4
  import { Autocomplete, Stack, Flex, Box, Text, TextInput, TextArea, useToast, Card, Menu, Badge, Container, rem, Skeleton } from "@sanity/ui";
5
- import { useId, useState, memo, forwardRef } from "react";
6
- import { Button, Dialog, MenuButton, MenuItem } from "./index.js";
7
- import { getVariantId, variantsClient, useClient, VARIANTS_STUDIO_CLIENT_OPTIONS, VARIANT_DOCUMENTS_PATH, useTranslation, variantsLocaleNamespace, useAllVariants, TextWithTone, useBundleDocuments, ContextMenuButton, RelativeTime, useSchema, useReleasesStore, SanityDefaultPreview, getReleaseTitleDetails, getReleaseIdFromReleaseDocumentId, getReleaseTone, decodeVariantIdFromRoute, LoadingBlock, getVariantDescription, getVariantConditionsText, getVariantTitle, filterVariantsForSearch } from "./index2.js";
5
+ import { useId, useState, forwardRef, memo } from "react";
6
+ import { Button, Dialog, MenuButton, MenuItem, Tooltip } from "./index.js";
7
+ import { getVariantId, variantsClient, useClient, VARIANTS_STUDIO_CLIENT_OPTIONS, VARIANT_DOCUMENTS_PATH, useTranslation, variantsLocaleNamespace, useAllVariants, TextWithTone, DOCUMENT_SYSTEM_FIELD, useBundleDocuments, isPublishedBundleId, ContextMenuButton, RelativeTime, isReleaseBundle, getReleaseDocumentIdFromReleaseId, getReleaseIdFromReleaseDocumentId, ReleaseTitle, RELEASES_INTENT, useDocumentPresence, DocumentPreviewPresence, useDocumentPreviewValues, SanityDefaultPreview, useSchema, ToneIcon, useActiveReleases, decodeVariantIdFromRoute, LoadingBlock, getVariantDescription, getVariantConditionsText, getVariantTitle, filterVariantsForSearch } from "./index2.js";
8
8
  import "history";
9
9
  import "sanity/_singletons";
10
10
  import "@sanity/icons/ArrowLeft";
@@ -12,9 +12,9 @@ import "@sanity/icons/Launch";
12
12
  import "styled-components";
13
13
  import "react-i18next";
14
14
  import "rxjs/operators";
15
- import { useObservable } from "react-rx";
15
+ import "react-rx";
16
16
  import "rxjs";
17
- import "@sanity/client/csm";
17
+ import { getPublishedId } from "@sanity/client/csm";
18
18
  import "quick-lru";
19
19
  import "lodash-es/throttle.js";
20
20
  import "lodash-es/isEqual.js";
@@ -59,7 +59,7 @@ import "@sanity/icons/ArrowDown";
59
59
  import "@sanity/icons/ArrowRight";
60
60
  import "@sanity/util/legacyDateFormat";
61
61
  import "@sanity/diff-patch";
62
- import "@sanity/icons/ErrorOutline";
62
+ import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
63
63
  import "@sanity/diff";
64
64
  import "mendoza";
65
65
  import "@sanity/icons/InfoOutline";
@@ -207,7 +207,7 @@ import { isPortableTextBlock, toPlainText } from "@portabletext/toolkit";
207
207
  import { at, set } from "@sanity/mutate";
208
208
  import { applyPatches } from "@sanity/mutate/_unstable_apply";
209
209
  import { DiamondIcon } from "@sanity/icons/Diamond";
210
- import { Table, Headers } from "./Table.js";
210
+ import { Headers, Table, searchDocumentRelease } from "./searchDocumentRelease.js";
211
211
  function createVariantOperationsStore(options) {
212
212
  const client = variantsClient(options.client);
213
213
  return {
@@ -685,22 +685,93 @@ function EditVariantDialog(props) {
685
685
  let t5;
686
686
  return $[11] !== handleSubmit || $[12] !== initialValue || $[13] !== onCancel || $[14] !== t2 || $[15] !== t3 || $[16] !== t4 ? (t5 = /* @__PURE__ */ jsx(VariantDialog, { confirmDataTestId: "save-variant-button", confirmText: t2, errorTitle: t3, header: t4, id: "edit-variant-dialog", initialValue, onCancel, onSubmit: handleSubmit, renderCancelButton: !0 }), $[11] = handleSubmit, $[12] = initialValue, $[13] = onCancel, $[14] = t2, $[15] = t3, $[16] = t4, $[17] = t5) : t5 = $[17], t5;
687
687
  }
688
- function useVariantDocuments(variantDocumentId) {
689
- const $ = c(7);
690
- let t0;
691
- $[0] !== variantDocumentId ? (t0 = getVariantId(variantDocumentId), $[0] = variantDocumentId, $[1] = t0) : t0 = $[1];
692
- const variantId = t0;
688
+ function toVariantDocumentVersion(document) {
689
+ const system = document[DOCUMENT_SYSTEM_FIELD];
690
+ return system?.group?._ref ? {
691
+ documentId: document._id,
692
+ bundleId: system.bundleId ?? void 0,
693
+ releaseRef: system.release?._ref ?? null,
694
+ updatedAt: document._updatedAt ?? ""
695
+ } : null;
696
+ }
697
+ function useVariantDocuments(variantId) {
698
+ const $ = c(13), enabled = !!variantId, t0 = variantId ?? "";
693
699
  let t1;
694
- $[2] !== variantId ? (t1 = {
695
- variantId
696
- }, $[2] = variantId, $[3] = t1) : t1 = $[3];
697
- const params = t1, t2 = `variant-${variantId}`;
700
+ $[0] !== t0 ? (t1 = {
701
+ variantId: t0
702
+ }, $[0] = t0, $[1] = t1) : t1 = $[1];
703
+ const params = t1, t2 = enabled ? `variant-${variantId}` : "variant-disabled";
698
704
  let t3;
699
- return $[4] !== params || $[5] !== t2 ? (t3 = {
705
+ $[2] !== enabled || $[3] !== params || $[4] !== t2 ? (t3 = {
700
706
  groqFilter: "sanity::partOfVariant($variantId)",
701
707
  params,
702
- cacheKey: t2
703
- }, $[4] = params, $[5] = t2, $[6] = t3) : t3 = $[6], useBundleDocuments(t3);
708
+ cacheKey: t2,
709
+ enabled
710
+ }, $[2] = enabled, $[3] = params, $[4] = t2, $[5] = t3) : t3 = $[5];
711
+ const {
712
+ loading,
713
+ results,
714
+ error
715
+ } = useBundleDocuments(t3);
716
+ let t4;
717
+ $[6] !== enabled || $[7] !== results ? (t4 = enabled ? toDocumentInVariants(results) : [], $[6] = enabled, $[7] = results, $[8] = t4) : t4 = $[8];
718
+ const variantResults = t4, t5 = enabled && loading, t6 = enabled ? error : null;
719
+ let t7;
720
+ return $[9] !== t5 || $[10] !== t6 || $[11] !== variantResults ? (t7 = {
721
+ loading: t5,
722
+ results: variantResults,
723
+ error: t6
724
+ }, $[9] = t5, $[10] = t6, $[11] = variantResults, $[12] = t7) : t7 = $[12], t7;
725
+ }
726
+ function toDocumentInVariants(results) {
727
+ return results.flatMap((result) => {
728
+ const version = toVariantDocumentVersion(result.document);
729
+ return version ? [{
730
+ ...result,
731
+ version
732
+ }] : [];
733
+ });
734
+ }
735
+ function getBundleSortOrder(bundleId) {
736
+ return isPublishedBundleId(bundleId) ? 0 : bundleId === "drafts" ? 1 : 2;
737
+ }
738
+ function compareVariantDocumentVersions(left, right) {
739
+ const leftOrder = getBundleSortOrder(left.bundleId), rightOrder = getBundleSortOrder(right.bundleId);
740
+ return leftOrder !== rightOrder ? leftOrder - rightOrder : left.documentId.localeCompare(right.documentId);
741
+ }
742
+ function pickRepresentativeDocument(documents) {
743
+ return documents.reduce((latest, current) => {
744
+ const latestUpdatedAt = latest.document._updatedAt ?? "";
745
+ return (current.document._updatedAt ?? "") > latestUpdatedAt ? current : latest;
746
+ });
747
+ }
748
+ function aggregateValidation(documents) {
749
+ const representative = pickRepresentativeDocument(documents);
750
+ return {
751
+ isValidating: documents.some((document) => document.validation.isValidating),
752
+ validation: documents.flatMap((document) => document.validation.validation),
753
+ revision: representative.validation.revision,
754
+ hasError: documents.some((document) => document.validation.hasError)
755
+ };
756
+ }
757
+ function groupVariantDocumentsByGroup(documents) {
758
+ const groups = /* @__PURE__ */ new Map();
759
+ for (const document of documents) {
760
+ const groupId = document.document._system?.group?._ref;
761
+ if (!groupId)
762
+ continue;
763
+ const existingGroup = groups.get(groupId);
764
+ existingGroup ? existingGroup.push(document) : groups.set(groupId, [document]);
765
+ }
766
+ return Array.from(groups.entries()).map(([groupId, groupDocuments]) => {
767
+ const representative = pickRepresentativeDocument(groupDocuments), versions = groupDocuments.map((item) => item.version).toSorted(compareVariantDocumentVersions);
768
+ return {
769
+ ...representative,
770
+ groupId,
771
+ versions,
772
+ validation: aggregateValidation(groupDocuments)
773
+ };
774
+ });
704
775
  }
705
776
  function VariantDetailMenuButton(t0) {
706
777
  const $ = c(21), {
@@ -777,45 +848,156 @@ function VariantDetailFooter(t0) {
777
848
  ] })
778
849
  ] }), $[11] = t5, $[12] = t6, $[13] = t7) : t7 = $[13], t7;
779
850
  }
780
- function getVariantDocumentVersion({
781
- document,
782
- releasesById,
783
- t
784
- }) {
785
- const system = document._system, releaseRef = system?.release?._ref;
786
- if (releaseRef) {
787
- const release = releasesById?.get(releaseRef);
788
- if (release) {
789
- const {
790
- displayTitle
791
- } = getReleaseTitleDetails(release.metadata?.title, getReleaseIdFromReleaseDocumentId(release._id));
792
- return {
793
- label: displayTitle,
794
- tone: getReleaseTone(release)
795
- };
796
- }
797
- return {
798
- label: getReleaseIdFromReleaseDocumentId(releaseRef),
799
- tone: "default"
800
- };
851
+ function getDocumentPreviewTitle(document) {
852
+ const title = document.title || document.name;
853
+ return typeof title == "string" && title.trim() ? title : document._id;
854
+ }
855
+ function getReleaseDocumentForVersion(version, releasesById) {
856
+ if (version.releaseRef)
857
+ return releasesById.get(version.releaseRef);
858
+ if (isReleaseBundle(version.bundleId)) {
859
+ const releaseDocumentId = getReleaseDocumentIdFromReleaseId(version.bundleId);
860
+ return releasesById.get(releaseDocumentId);
801
861
  }
802
- return system?.bundleId === "drafts" ? {
803
- label: t("detail.documents.table.version.drafts"),
804
- tone: getReleaseTone("drafts")
862
+ }
863
+ function ReleaseBundleChip(t0) {
864
+ const $ = c(10), {
865
+ release
866
+ } = t0, {
867
+ t
868
+ } = useTranslation();
869
+ let t1;
870
+ $[0] !== release._id ? (t1 = getReleaseIdFromReleaseDocumentId(release._id), $[0] = release._id, $[1] = t1) : t1 = $[1];
871
+ const releaseId = t1, t2 = release.metadata?.title;
872
+ let t3;
873
+ $[2] !== t ? (t3 = t("release.placeholder-untitled-release"), $[2] = t, $[3] = t3) : t3 = $[3];
874
+ let t4;
875
+ $[4] !== releaseId ? (t4 = (t52) => {
876
+ const {
877
+ displayTitle
878
+ } = t52;
879
+ return /* @__PURE__ */ jsx(IntentLink, { intent: RELEASES_INTENT, params: {
880
+ id: releaseId
881
+ }, children: /* @__PURE__ */ jsx(Badge, { radius: 2, tone: "primary", children: displayTitle }) });
882
+ }, $[4] = releaseId, $[5] = t4) : t4 = $[5];
883
+ let t5;
884
+ return $[6] !== t2 || $[7] !== t3 || $[8] !== t4 ? (t5 = /* @__PURE__ */ jsx(ReleaseTitle, { title: t2, fallback: t3, children: t4 }), $[6] = t2, $[7] = t3, $[8] = t4, $[9] = t5) : t5 = $[9], t5;
885
+ }
886
+ function StaticBundleChip(t0) {
887
+ const $ = c(3), {
888
+ label,
889
+ tone
890
+ } = t0;
891
+ let t1;
892
+ return $[0] !== label || $[1] !== tone ? (t1 = /* @__PURE__ */ jsx(Badge, { radius: 2, tone, children: label }), $[0] = label, $[1] = tone, $[2] = t1) : t1 = $[2], t1;
893
+ }
894
+ function VariantDocumentBundleChips(t0) {
895
+ const $ = c(11), {
896
+ versions,
897
+ releasesById
898
+ } = t0, {
899
+ t
900
+ } = useTranslation();
901
+ let t1;
902
+ $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t1 = {
903
+ minWidth: 0,
904
+ width: "100%",
905
+ overflowX: "auto",
906
+ overflowY: "hidden"
907
+ }, $[0] = t1) : t1 = $[0];
908
+ let t2;
909
+ $[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t2 = {
910
+ width: "max-content"
911
+ }, $[1] = t2) : t2 = $[1];
912
+ let t3;
913
+ if ($[2] !== releasesById || $[3] !== t || $[4] !== versions) {
914
+ let t42;
915
+ $[6] !== releasesById || $[7] !== t ? (t42 = (version) => {
916
+ if (isPublishedBundleId(version.bundleId))
917
+ return /* @__PURE__ */ jsx(StaticBundleChip, { label: t("release.chip.published"), tone: "positive" }, version.documentId);
918
+ if (version.bundleId === "drafts")
919
+ return /* @__PURE__ */ jsx(StaticBundleChip, { label: t("release.chip.draft"), tone: "default" }, version.documentId);
920
+ const release = getReleaseDocumentForVersion(version, releasesById);
921
+ return release ? /* @__PURE__ */ jsx(ReleaseBundleChip, { release }, version.documentId) : /* @__PURE__ */ jsx(StaticBundleChip, { label: t("release.placeholder-untitled-release"), tone: "default" }, version.documentId);
922
+ }, $[6] = releasesById, $[7] = t, $[8] = t42) : t42 = $[8], t3 = versions.map(t42), $[2] = releasesById, $[3] = t, $[4] = versions, $[5] = t3;
923
+ } else
924
+ t3 = $[5];
925
+ let t4;
926
+ return $[9] !== t3 ? (t4 = /* @__PURE__ */ jsx(Box, { style: t1, children: /* @__PURE__ */ jsx(Flex, { align: "center", gap: 1, wrap: "nowrap", style: t2, children: t3 }) }), $[9] = t3, $[10] = t4) : t4 = $[10], t4;
927
+ }
928
+ const VariantDocumentPreviewLink = forwardRef(function(t0, ref) {
929
+ const $ = c(13);
930
+ let documentType, linkProps, publishedId, searchParams;
931
+ $[0] !== t0 ? ({
932
+ publishedId,
933
+ documentType,
934
+ searchParams,
935
+ ...linkProps
936
+ } = t0, $[0] = t0, $[1] = documentType, $[2] = linkProps, $[3] = publishedId, $[4] = searchParams) : (documentType = $[1], linkProps = $[2], publishedId = $[3], searchParams = $[4]);
937
+ let t1;
938
+ $[5] !== documentType || $[6] !== publishedId ? (t1 = {
939
+ id: publishedId,
940
+ type: documentType
941
+ }, $[5] = documentType, $[6] = publishedId, $[7] = t1) : t1 = $[7];
942
+ let t2;
943
+ return $[8] !== linkProps || $[9] !== ref || $[10] !== searchParams || $[11] !== t1 ? (t2 = /* @__PURE__ */ jsx(IntentLink, { ...linkProps, intent: "edit", params: t1, searchParams, ref }), $[8] = linkProps, $[9] = ref, $[10] = searchParams, $[11] = t1, $[12] = t2) : t2 = $[12], t2;
944
+ });
945
+ function getVersionPerspectiveNavigation(bundleId, variantId) {
946
+ const searchParams = variantId ? [["variant", variantId]] : [];
947
+ return isPublishedBundleId(bundleId) ? {
948
+ perspectiveStack: ["published"],
949
+ searchParams: [...searchParams, ["perspective", "published"]]
950
+ } : bundleId === "drafts" ? {
951
+ perspectiveStack: ["drafts"],
952
+ searchParams: searchParams.length > 0 ? searchParams : void 0
805
953
  } : {
806
- label: t("detail.documents.table.version.published"),
807
- tone: getReleaseTone("published")
954
+ perspectiveStack: [bundleId ?? "", "drafts"],
955
+ searchParams: [...searchParams, ["perspective", bundleId ?? ""]]
808
956
  };
809
957
  }
810
- const TABLE_CARD_STYLE = {
811
- height: "100%",
812
- overflow: "auto"
813
- };
814
- function getDocumentPreviewTitle(document) {
815
- const title = document.title || document.name;
816
- return typeof title == "string" && title.trim() ? title : document._id;
958
+ function VariantDocumentPreview(t0) {
959
+ const $ = c(23), {
960
+ row,
961
+ layout,
962
+ variantId
963
+ } = t0;
964
+ let t1;
965
+ $[0] !== row.groupId ? (t1 = getPublishedId(row.groupId), $[0] = row.groupId, $[1] = t1) : t1 = $[1];
966
+ const publishedId = t1, documentPresence = useDocumentPresence(row.document._id);
967
+ let t2;
968
+ $[2] !== row.version.bundleId || $[3] !== variantId ? (t2 = getVersionPerspectiveNavigation(row.version.bundleId, variantId), $[2] = row.version.bundleId, $[3] = variantId, $[4] = t2) : t2 = $[4];
969
+ const {
970
+ perspectiveStack,
971
+ searchParams
972
+ } = t2;
973
+ let t3;
974
+ $[5] !== documentPresence ? (t3 = documentPresence?.length > 0 && /* @__PURE__ */ jsx(DocumentPreviewPresence, { presence: documentPresence }), $[5] = documentPresence, $[6] = t3) : t3 = $[6];
975
+ const previewPresence = t3;
976
+ let t4;
977
+ $[7] !== perspectiveStack || $[8] !== row.document._id || $[9] !== row.document._type ? (t4 = {
978
+ documentId: row.document._id,
979
+ documentType: row.document._type,
980
+ perspectiveStack
981
+ }, $[7] = perspectiveStack, $[8] = row.document._id, $[9] = row.document._type, $[10] = t4) : t4 = $[10];
982
+ const {
983
+ isLoading: previewLoading,
984
+ value: resolvedPreview
985
+ } = useDocumentPreviewValues(t4);
986
+ let t5;
987
+ $[11] !== resolvedPreview ? (t5 = resolvedPreview || {}, $[11] = resolvedPreview, $[12] = t5) : t5 = $[12];
988
+ let t6;
989
+ $[13] !== layout || $[14] !== previewLoading || $[15] !== previewPresence || $[16] !== t5 ? (t6 = /* @__PURE__ */ jsx(SanityDefaultPreview, { ...t5, status: previewPresence, isPlaceholder: previewLoading, layout }), $[13] = layout, $[14] = previewLoading, $[15] = previewPresence, $[16] = t5, $[17] = t6) : t6 = $[17];
990
+ let t7;
991
+ return $[18] !== publishedId || $[19] !== row.document._type || $[20] !== searchParams || $[21] !== t6 ? (t7 = /* @__PURE__ */ jsx(Card, { tone: "inherit", as: VariantDocumentPreviewLink, publishedId, documentType: row.document._type, searchParams, radius: 2, "data-as": "a", children: t6 }), $[18] = publishedId, $[19] = row.document._type, $[20] = searchParams, $[21] = t6, $[22] = t7) : t7 = $[22], t7;
817
992
  }
818
- const MemoDocumentType = memo(function(t0) {
993
+ const MemoVariantDocumentPreview = memo(function(t0) {
994
+ const $ = c(3), {
995
+ row,
996
+ variantId
997
+ } = t0;
998
+ let t1;
999
+ return $[0] !== row || $[1] !== variantId ? (t1 = /* @__PURE__ */ jsx(VariantDocumentPreview, { row, variantId }), $[0] = row, $[1] = variantId, $[2] = t1) : t1 = $[2], t1;
1000
+ }, (prev, next) => prev.row.memoKey === next.row.memoKey && prev.variantId === next.variantId), MemoDocumentType = memo(function(t0) {
819
1001
  const $ = c(5), {
820
1002
  type
821
1003
  } = t0, schema = useSchema();
@@ -824,149 +1006,160 @@ const MemoDocumentType = memo(function(t0) {
824
1006
  const t2 = t1?.title || type;
825
1007
  let t3;
826
1008
  return $[3] !== t2 ? (t3 = /* @__PURE__ */ jsx(Text, { size: 1, children: t2 }), $[3] = t2, $[4] = t3) : t3 = $[4], t3;
827
- }, (prev, next) => prev.type === next.type);
828
- function getVariantDocumentVersionSortRank(document) {
829
- const system = document._system;
830
- return system?.release?._ref ? 2 : system?.bundleId === "drafts" ? 1 : 0;
831
- }
832
- function getVariantDocumentGroupSortKey({
833
- document,
834
- version
835
- }) {
836
- const groupRef = document._system?.group._ref ?? document._id, versionRank = getVariantDocumentVersionSortRank(document);
837
- return `${groupRef}\0${versionRank}\0${version.label}\0${document._id}`;
838
- }
839
- function getVariantDocumentColumnDefs(t) {
840
- return [{
841
- id: "documentGroup",
842
- hidden: !0,
843
- width: null,
844
- sorting: !0,
845
- sortTransform: getVariantDocumentGroupSortKey
846
- }, {
847
- id: "version",
848
- width: null,
849
- style: {
850
- minWidth: 100
851
- },
852
- sorting: !1,
853
- header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.BasicHeader, { text: t("detail.documents.table.version") }) }),
854
- cell: ({
855
- cellProps,
856
- datum
857
- }) => /* @__PURE__ */ jsx(Flex, { align: "center", ...cellProps, children: /* @__PURE__ */ jsx(Box, { paddingX: 2, children: !datum.isLoading && datum.version && /* @__PURE__ */ jsx(Badge, { fontSize: 1, mode: "outline", radius: 2, tone: datum.version.tone, children: datum.version.label }) }) })
858
- }, {
859
- id: "document._type",
860
- width: null,
861
- style: {
862
- minWidth: 100
863
- },
864
- sorting: !0,
865
- header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.SortHeaderButton, { text: t("detail.documents.table.type"), ...props }) }),
866
- cell: ({
867
- cellProps,
868
- datum
869
- }) => /* @__PURE__ */ jsx(Flex, { align: "center", ...cellProps, children: /* @__PURE__ */ jsx(Box, { paddingX: 2, children: !datum.isLoading && /* @__PURE__ */ jsx(MemoDocumentType, { type: datum.document._type }) }) })
870
- }, {
871
- id: "search",
872
- width: null,
873
- style: {
874
- minWidth: "min(50%, calc(100vw - 80px))",
875
- maxWidth: "min(50%, calc(100vw - 80px))"
876
- },
877
- sortTransform: ({
878
- document
879
- }) => getDocumentPreviewTitle(document).toLowerCase(),
880
- header: (props) => /* @__PURE__ */ jsx(Headers.TableHeaderSearch, { ...props, placeholder: t("detail.documents.table.search-placeholder") }),
881
- cell: ({
882
- cellProps,
883
- datum
884
- }) => /* @__PURE__ */ jsx(Box, { ...cellProps, flex: 1, padding: 1, paddingRight: 2, sizing: "border", children: datum.isLoading ? /* @__PURE__ */ jsx(SanityDefaultPreview, { isPlaceholder: !0 }) : /* @__PURE__ */ jsx(SanityDefaultPreview, { title: getDocumentPreviewTitle(datum.document), subtitle: datum.document._id }) })
885
- }, {
886
- id: "document._updatedAt",
887
- sorting: !0,
888
- width: 130,
889
- header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.SortHeaderButton, { text: t("detail.documents.table.edited"), ...props }) }),
890
- cell: ({
891
- cellProps,
892
- datum
893
- }) => /* @__PURE__ */ jsx(Flex, { ...cellProps, align: "center", paddingX: 2, paddingY: 3, style: {
894
- minWidth: 130
895
- }, children: !datum.isLoading && datum.document._updatedAt && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(RelativeTime, { time: datum.document._updatedAt, useTemporalPhrase: !0, minimal: !0 }) }) })
896
- }];
897
- }
1009
+ }, (prev, next) => prev.type === next.type), getVariantDocumentTableColumnDefs = (t, variantId, releasesById) => [{
1010
+ id: "documentGroup",
1011
+ hidden: !0,
1012
+ width: null,
1013
+ sorting: !0,
1014
+ sortTransform: (row) => row.groupId
1015
+ }, {
1016
+ id: "bundle",
1017
+ width: 140,
1018
+ style: {
1019
+ minWidth: 100,
1020
+ maxWidth: 140
1021
+ },
1022
+ sorting: !1,
1023
+ header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.BasicHeader, { text: t("detail.documents.table.bundle") }) }),
1024
+ cell: ({
1025
+ cellProps,
1026
+ datum
1027
+ }) => /* @__PURE__ */ jsx(Flex, { align: "center", ...cellProps, style: {
1028
+ ...cellProps.style,
1029
+ flex: "0 1 auto",
1030
+ minWidth: 0,
1031
+ overflow: "hidden"
1032
+ }, children: /* @__PURE__ */ jsx(Box, { flex: 1, paddingX: 2, style: {
1033
+ minWidth: 0,
1034
+ overflow: "hidden"
1035
+ }, children: !datum.isLoading && /* @__PURE__ */ jsx(VariantDocumentBundleChips, { versions: datum.versions, releasesById }) }) })
1036
+ }, {
1037
+ id: "document._type",
1038
+ width: null,
1039
+ style: {
1040
+ minWidth: 100
1041
+ },
1042
+ sorting: !0,
1043
+ header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.SortHeaderButton, { text: t("detail.documents.table.type"), ...props }) }),
1044
+ cell: ({
1045
+ cellProps,
1046
+ datum
1047
+ }) => /* @__PURE__ */ jsx(Flex, { align: "center", ...cellProps, children: /* @__PURE__ */ jsx(Box, { paddingX: 2, children: !datum.isLoading && /* @__PURE__ */ jsx(MemoDocumentType, { type: datum.document._type }) }) })
1048
+ }, {
1049
+ id: "search",
1050
+ width: null,
1051
+ style: {
1052
+ minWidth: "min(50%, calc(100vw - 80px))",
1053
+ maxWidth: "min(50%, calc(100vw - 80px))"
1054
+ },
1055
+ sortTransform: ({
1056
+ document
1057
+ }) => getDocumentPreviewTitle(document).toLowerCase(),
1058
+ header: (props) => /* @__PURE__ */ jsx(Headers.TableHeaderSearch, { ...props, placeholder: t("detail.documents.table.search-placeholder") }),
1059
+ cell: ({
1060
+ cellProps,
1061
+ datum
1062
+ }) => /* @__PURE__ */ jsx(Box, { ...cellProps, flex: 1, padding: 1, paddingRight: 2, sizing: "border", children: datum.isLoading ? /* @__PURE__ */ jsx(SanityDefaultPreview, { isPlaceholder: !0 }) : /* @__PURE__ */ jsx(MemoVariantDocumentPreview, { row: datum, variantId }) })
1063
+ }, {
1064
+ id: "document._updatedAt",
1065
+ sorting: !0,
1066
+ width: 130,
1067
+ header: (props) => /* @__PURE__ */ jsx(Flex, { ...props.headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.SortHeaderButton, { text: t("detail.documents.table.edited"), ...props }) }),
1068
+ cell: ({
1069
+ cellProps,
1070
+ datum
1071
+ }) => /* @__PURE__ */ jsx(Flex, { ...cellProps, align: "center", paddingX: 2, paddingY: 3, style: {
1072
+ minWidth: 130
1073
+ }, children: !datum.isLoading && datum.document._updatedAt && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(RelativeTime, { time: datum.document._updatedAt, useTemporalPhrase: !0, minimal: !0 }) }) })
1074
+ }, {
1075
+ id: "validation",
1076
+ sorting: !1,
1077
+ width: 50,
1078
+ header: ({
1079
+ headerProps
1080
+ }) => /* @__PURE__ */ jsx(Flex, { ...headerProps, paddingY: 3, sizing: "border", children: /* @__PURE__ */ jsx(Headers.BasicHeader, { text: "" }) }),
1081
+ cell: ({
1082
+ cellProps,
1083
+ datum
1084
+ }) => {
1085
+ if (datum.isLoading) return null;
1086
+ const validationErrorCount = datum.validation.validation.filter((validation) => validation.level === "error").length;
1087
+ return /* @__PURE__ */ jsx(Flex, { ...cellProps, flex: 1, padding: 1, justify: "center", align: "center", sizing: "border", children: datum.validation.hasError && /* @__PURE__ */ jsx(Tooltip, { portal: !0, placement: "bottom-end", content: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 3, padding: 1, children: [
1088
+ /* @__PURE__ */ jsx(ToneIcon, { icon: ErrorOutlineIcon, tone: "critical" }),
1089
+ t(validationErrorCount === 1 ? "detail.documents.table.validation.error_one" : "detail.documents.table.validation.error_other", {
1090
+ count: validationErrorCount
1091
+ })
1092
+ ] }) }), children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(ToneIcon, { icon: ErrorOutlineIcon, tone: "critical" }) }) }) });
1093
+ }
1094
+ }], TABLE_CARD_STYLE = {
1095
+ height: "100%",
1096
+ overflow: "auto"
1097
+ };
898
1098
  function filterDocuments(rows, searchTerm) {
899
- const normalizedSearchTerm = searchTerm.trim().toLowerCase();
900
- return normalizedSearchTerm ? rows.filter(({
1099
+ return searchTerm.trim() ? rows.filter(({
901
1100
  document
902
- }) => [getDocumentPreviewTitle(document), document._id, document._type].some((value) => value.toLowerCase().includes(normalizedSearchTerm))) : rows;
1101
+ }) => searchDocumentRelease(document, searchTerm)) : rows;
903
1102
  }
904
1103
  function VariantDocumentsTable(t0) {
905
- const $ = c(18), {
906
- documents,
907
- loading: t1
1104
+ const $ = c(15), {
1105
+ rows,
1106
+ loading: t1,
1107
+ variantId
908
1108
  } = t0, loading = t1 === void 0 ? !1 : t1, {
909
1109
  t
910
1110
  } = useTranslation(variantsLocaleNamespace), [scrollContainerRef, setScrollContainerRef] = useState(null), {
911
- state$
912
- } = useReleasesStore(), releasesById = useObservable(state$)?.releases;
1111
+ data: releases
1112
+ } = useActiveReleases();
913
1113
  let t2;
914
- $[0] !== t ? (t2 = getVariantDocumentColumnDefs(t), $[0] = t, $[1] = t2) : t2 = $[1];
915
- const columnDefs = t2;
1114
+ $[0] !== releases ? (t2 = new Map(releases.map(_temp$2)), $[0] = releases, $[1] = t2) : t2 = $[1];
1115
+ const releasesById = t2;
916
1116
  let t3;
917
- if ($[2] !== documents || $[3] !== releasesById || $[4] !== t) {
918
- let t42;
919
- $[6] !== releasesById || $[7] !== t ? (t42 = (document) => ({
920
- document,
921
- version: getVariantDocumentVersion({
922
- document,
923
- releasesById,
924
- t
925
- })
926
- }), $[6] = releasesById, $[7] = t, $[8] = t42) : t42 = $[8], t3 = documents.map(t42), $[2] = documents, $[3] = releasesById, $[4] = t, $[5] = t3;
927
- } else
928
- t3 = $[5];
929
- const rows = t3;
1117
+ $[2] !== releasesById || $[3] !== t || $[4] !== variantId ? (t3 = getVariantDocumentTableColumnDefs(t, variantId, releasesById), $[2] = releasesById, $[3] = t, $[4] = variantId, $[5] = t3) : t3 = $[5];
1118
+ const columnDefs = t3;
930
1119
  let t4;
931
- $[9] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
1120
+ $[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
932
1121
  column: "documentGroup",
933
1122
  direction: "asc"
934
- }, $[9] = t4) : t4 = $[9];
1123
+ }, $[6] = t4) : t4 = $[6];
935
1124
  let t5;
936
- $[10] !== t ? (t5 = t("detail.documents.no-documents"), $[10] = t, $[11] = t5) : t5 = $[11];
1125
+ $[7] !== t ? (t5 = t("detail.documents.no-documents"), $[7] = t, $[8] = t5) : t5 = $[8];
937
1126
  let t6;
938
- return $[12] !== columnDefs || $[13] !== loading || $[14] !== rows || $[15] !== scrollContainerRef || $[16] !== t5 ? (t6 = /* @__PURE__ */ jsx(Card, { flex: 1, ref: setScrollContainerRef, style: TABLE_CARD_STYLE, children: /* @__PURE__ */ jsx(Table, { columnDefs, data: rows, defaultSort: t4, emptyState: t5, loading, rowId: "document._id", scrollContainerRef, searchFilter: filterDocuments }) }), $[12] = columnDefs, $[13] = loading, $[14] = rows, $[15] = scrollContainerRef, $[16] = t5, $[17] = t6) : t6 = $[17], t6;
1127
+ return $[9] !== columnDefs || $[10] !== loading || $[11] !== rows || $[12] !== scrollContainerRef || $[13] !== t5 ? (t6 = /* @__PURE__ */ jsx(Card, { flex: 1, ref: setScrollContainerRef, style: TABLE_CARD_STYLE, children: /* @__PURE__ */ jsx(Table, { columnDefs, data: rows, defaultSort: t4, emptyState: t5, loading, rowId: "groupId", scrollContainerRef, searchFilter: filterDocuments }) }), $[9] = columnDefs, $[10] = loading, $[11] = rows, $[12] = scrollContainerRef, $[13] = t5, $[14] = t6) : t6 = $[14], t6;
1128
+ }
1129
+ function _temp$2(release) {
1130
+ return [release._id, release];
939
1131
  }
940
1132
  function VariantDetail() {
941
- const $ = c(98), router = useRouter(), {
1133
+ const $ = c(54), router = useRouter(), {
942
1134
  t
943
1135
  } = useTranslation(variantsLocaleNamespace), [editDialogOpen, setEditDialogOpen] = useState(!1), variantIdRaw = typeof router.state.variantId == "string" ? router.state.variantId : void 0, variantId = decodeVariantIdFromRoute(variantIdRaw), {
944
1136
  byId,
945
1137
  loading
946
1138
  } = useAllVariants(), variant = variantId ? byId.get(variantId) : void 0, {
1139
+ loading: documentsLoading,
947
1140
  results: variantDocuments,
948
- loading: documentsLoading
949
- } = useVariantDocuments(variantId ?? "");
1141
+ error: variantDocumentsError
1142
+ } = useVariantDocuments(variant?._id);
950
1143
  let t0;
951
- $[0] !== variantDocuments ? (t0 = variantDocuments.map(_temp$2), $[0] = variantDocuments, $[1] = t0) : t0 = $[1];
952
- const documents = t0;
1144
+ $[0] !== variantDocuments ? (t0 = groupVariantDocumentsByGroup(variantDocuments), $[0] = variantDocuments, $[1] = t0) : t0 = $[1];
1145
+ const tableRows = t0;
953
1146
  if (loading) {
954
- let t110;
955
- $[2] !== t ? (t110 = t("detail.loading"), $[2] = t, $[3] = t110) : t110 = $[3];
956
- let t210;
957
- return $[4] !== t110 ? (t210 = /* @__PURE__ */ jsx(LoadingBlock, { fill: !0, title: t110 }), $[4] = t110, $[5] = t210) : t210 = $[5], t210;
1147
+ let t18;
1148
+ $[2] !== t ? (t18 = t("detail.loading"), $[2] = t, $[3] = t18) : t18 = $[3];
1149
+ let t22;
1150
+ return $[4] !== t18 ? (t22 = /* @__PURE__ */ jsx(LoadingBlock, { fill: !0, title: t18 }), $[4] = t18, $[5] = t22) : t22 = $[5], t22;
958
1151
  }
959
1152
  if (!variant) {
960
- let t110;
961
- $[6] !== router ? (t110 = () => router.navigate({}), $[6] = router, $[7] = t110) : t110 = $[7];
962
- let t210;
963
- $[8] !== t ? (t210 = t("detail.back"), $[8] = t, $[9] = t210) : t210 = $[9];
964
- let t310;
965
- $[10] !== t110 || $[11] !== t210 ? (t310 = /* @__PURE__ */ jsx(Card, { borderBottom: !0, flex: "none", padding: 3, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", onClick: t110, text: t210 }) }), $[10] = t110, $[11] = t210, $[12] = t310) : t310 = $[12];
966
- let t48;
967
- $[13] !== t ? (t48 = t("detail.not-found.title"), $[13] = t, $[14] = t48) : t48 = $[14];
1153
+ let t18;
1154
+ $[6] !== router ? (t18 = () => router.navigate({}), $[6] = router, $[7] = t18) : t18 = $[7];
1155
+ let t22;
1156
+ $[8] !== t ? (t22 = t("detail.back"), $[8] = t, $[9] = t22) : t22 = $[9];
1157
+ let t32;
1158
+ $[10] !== t18 || $[11] !== t22 ? (t32 = /* @__PURE__ */ jsx(Card, { borderBottom: !0, flex: "none", padding: 3, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", onClick: t18, text: t22 }) }), $[10] = t18, $[11] = t22, $[12] = t32) : t32 = $[12];
1159
+ let t42;
1160
+ $[13] !== t ? (t42 = t("detail.not-found.title"), $[13] = t, $[14] = t42) : t42 = $[14];
968
1161
  let t52;
969
- $[15] !== t48 ? (t52 = /* @__PURE__ */ jsx(Text, { size: 2, weight: "semibold", children: t48 }), $[15] = t48, $[16] = t52) : t52 = $[16];
1162
+ $[15] !== t42 ? (t52 = /* @__PURE__ */ jsx(Text, { size: 2, weight: "semibold", children: t42 }), $[15] = t42, $[16] = t52) : t52 = $[16];
970
1163
  let t62;
971
1164
  $[17] !== t ? (t62 = t("detail.not-found.description"), $[17] = t, $[18] = t62) : t62 = $[18];
972
1165
  let t72;
@@ -977,93 +1170,64 @@ function VariantDetail() {
977
1170
  t72
978
1171
  ] }) }) }), $[21] = t52, $[22] = t72, $[23] = t82) : t82 = $[23];
979
1172
  let t92;
980
- return $[24] !== t310 || $[25] !== t82 ? (t92 = /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", children: [
981
- t310,
1173
+ return $[24] !== t32 || $[25] !== t82 ? (t92 = /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", children: [
1174
+ t32,
982
1175
  t82
983
- ] }), $[24] = t310, $[25] = t82, $[26] = t92) : t92 = $[26], t92;
1176
+ ] }), $[24] = t32, $[25] = t82, $[26] = t92) : t92 = $[26], t92;
984
1177
  }
985
- const description = getVariantDescription(variant), conditionsText = getVariantConditionsText(variant.conditions), T0 = Flex, t1 = "column", t2 = 1, t3 = "fill", t4 = "hidden";
1178
+ const description = getVariantDescription(variant), conditionsText = getVariantConditionsText(variant.conditions);
1179
+ let t1;
1180
+ $[27] !== router ? (t1 = () => router.navigate({}), $[27] = router, $[28] = t1) : t1 = $[28];
1181
+ let t2;
1182
+ $[29] !== t ? (t2 = t("detail.back"), $[29] = t, $[30] = t2) : t2 = $[30];
1183
+ let t3;
1184
+ $[31] !== t1 || $[32] !== t2 ? (t3 = /* @__PURE__ */ jsx(Card, { borderBottom: !0, flex: "none", padding: 3, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", onClick: t1, text: t2 }) }), $[31] = t1, $[32] = t2, $[33] = t3) : t3 = $[33];
1185
+ let t4;
1186
+ $[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
1187
+ minHeight: 0
1188
+ }, $[34] = t4) : t4 = $[34];
986
1189
  let t5;
987
- $[27] !== router ? (t5 = () => router.navigate({}), $[27] = router, $[28] = t5) : t5 = $[28];
1190
+ $[35] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t5 = () => setEditDialogOpen(!0), $[35] = t5) : t5 = $[35];
988
1191
  let t6;
989
- $[29] !== t ? (t6 = t("detail.back"), $[29] = t, $[30] = t6) : t6 = $[30];
1192
+ $[36] !== t ? (t6 = t("detail.action.edit-variant"), $[36] = t, $[37] = t6) : t6 = $[37];
990
1193
  let t7;
991
- $[31] !== t5 || $[32] !== t6 ? (t7 = /* @__PURE__ */ jsx(Card, { borderBottom: !0, flex: "none", padding: 3, children: /* @__PURE__ */ jsx(Button, { mode: "bleed", onClick: t5, text: t6 }) }), $[31] = t5, $[32] = t6, $[33] = t7) : t7 = $[33];
992
- const T1 = Flex, t8 = "column", t9 = 1, t10 = "fill", t11 = "hidden";
993
- let t12;
994
- $[34] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t12 = {
995
- minHeight: 0
996
- }, $[34] = t12) : t12 = $[34];
997
- const T2 = Container, t13 = "none", t14 = 3, T3 = Flex, t15 = "column", t16 = 3, T4 = Card, t17 = 5, T5 = Flex, t18 = "flex-start", t19 = 4, t20 = "space-between", T6 = Stack, t21 = 3, T7 = Text, t22 = "h1", t23 = 4, t24 = "bold", t25 = getVariantTitle(variant);
998
- let t26;
999
- $[35] !== T7 || $[36] !== t25 ? (t26 = /* @__PURE__ */ jsx(T7, { as: t22, size: t23, weight: t24, children: t25 }), $[35] = T7, $[36] = t25, $[37] = t26) : t26 = $[37];
1000
- let t27;
1001
- $[38] !== description || $[39] !== t ? (t27 = description || t("detail.no-description"), $[38] = description, $[39] = t, $[40] = t27) : t27 = $[40];
1002
- let t28;
1003
- $[41] !== t27 ? (t28 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t27 }), $[41] = t27, $[42] = t28) : t28 = $[42];
1004
- let t29;
1005
- $[43] !== T6 || $[44] !== t26 || $[45] !== t28 ? (t29 = /* @__PURE__ */ jsxs(T6, { space: t21, children: [
1006
- t26,
1007
- t28
1008
- ] }), $[43] = T6, $[44] = t26, $[45] = t28, $[46] = t29) : t29 = $[46];
1009
- let t30;
1010
- $[47] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t30 = () => setEditDialogOpen(!0), $[47] = t30) : t30 = $[47];
1011
- let t31;
1012
- $[48] !== t ? (t31 = t("detail.action.edit-variant"), $[48] = t, $[49] = t31) : t31 = $[49];
1013
- let t32;
1014
- $[50] !== t31 ? (t32 = /* @__PURE__ */ jsx(Button, { onClick: t30, text: t31 }), $[50] = t31, $[51] = t32) : t32 = $[51];
1015
- let t33;
1016
- $[52] !== T5 || $[53] !== t29 || $[54] !== t32 ? (t33 = /* @__PURE__ */ jsxs(T5, { align: t18, gap: t19, justify: t20, children: [
1017
- t29,
1018
- t32
1019
- ] }), $[52] = T5, $[53] = t29, $[54] = t32, $[55] = t33) : t33 = $[55];
1020
- let t34;
1021
- $[56] !== t ? (t34 = t("dialog.create.conditions.title"), $[56] = t, $[57] = t34) : t34 = $[57];
1022
- let t35;
1023
- $[58] !== t34 ? (t35 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t34 }), $[58] = t34, $[59] = t35) : t35 = $[59];
1024
- let t36;
1025
- $[60] !== conditionsText || $[61] !== t ? (t36 = conditionsText || t("overview.table.no-conditions"), $[60] = conditionsText, $[61] = t, $[62] = t36) : t36 = $[62];
1026
- let t37;
1027
- $[63] !== t36 ? (t37 = /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t36 }), $[63] = t36, $[64] = t37) : t37 = $[64];
1028
- let t38;
1029
- $[65] !== t35 || $[66] !== t37 ? (t38 = /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
1030
- t35,
1031
- t37
1032
- ] }) }), $[65] = t35, $[66] = t37, $[67] = t38) : t38 = $[67];
1033
- let t39;
1034
- $[68] !== T4 || $[69] !== t33 || $[70] !== t38 ? (t39 = /* @__PURE__ */ jsxs(T4, { paddingY: t17, children: [
1035
- t33,
1036
- t38
1037
- ] }), $[68] = T4, $[69] = t33, $[70] = t38, $[71] = t39) : t39 = $[71];
1038
- let t40;
1039
- $[72] !== T3 || $[73] !== t39 ? (t40 = /* @__PURE__ */ jsx(T3, { direction: t15, paddingX: t16, children: t39 }), $[72] = T3, $[73] = t39, $[74] = t40) : t40 = $[74];
1040
- let t41;
1041
- $[75] !== T2 || $[76] !== t40 ? (t41 = /* @__PURE__ */ jsx(T2, { flex: t13, width: t14, children: t40 }), $[75] = T2, $[76] = t40, $[77] = t41) : t41 = $[77];
1042
- let t42;
1043
- $[78] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t42 = {
1194
+ $[38] !== t6 ? (t7 = /* @__PURE__ */ jsx(Button, { onClick: t5, text: t6 }), $[38] = t6, $[39] = t7) : t7 = $[39];
1195
+ let t8;
1196
+ $[40] !== t ? (t8 = t("dialog.create.conditions.title"), $[40] = t, $[41] = t8) : t8 = $[41];
1197
+ let t9;
1198
+ $[42] !== t8 ? (t9 = /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: t8 }), $[42] = t8, $[43] = t9) : t9 = $[43];
1199
+ const T0 = Flex, t10 = "column", t11 = 1, t12 = "hidden";
1200
+ let t13;
1201
+ $[44] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t13 = {
1044
1202
  minHeight: 0
1045
- }, $[78] = t42) : t42 = $[78];
1046
- let t43;
1047
- $[79] !== documents || $[80] !== documentsLoading ? (t43 = /* @__PURE__ */ jsx(Flex, { direction: "column", flex: 1, overflow: "hidden", style: t42, children: /* @__PURE__ */ jsx(VariantDocumentsTable, { documents, loading: documentsLoading }) }), $[79] = documents, $[80] = documentsLoading, $[81] = t43) : t43 = $[81];
1048
- let t44;
1049
- $[82] !== T1 || $[83] !== t12 || $[84] !== t41 || $[85] !== t43 ? (t44 = /* @__PURE__ */ jsxs(T1, { direction: t8, flex: t9, height: t10, overflow: t11, style: t12, children: [
1050
- t41,
1051
- t43
1052
- ] }), $[82] = T1, $[83] = t12, $[84] = t41, $[85] = t43, $[86] = t44) : t44 = $[86];
1053
- let t45;
1054
- $[87] !== variant ? (t45 = /* @__PURE__ */ jsx(VariantDetailFooter, { variant }), $[87] = variant, $[88] = t45) : t45 = $[88];
1055
- let t46;
1056
- $[89] !== editDialogOpen || $[90] !== variant ? (t46 = editDialogOpen && /* @__PURE__ */ jsx(EditVariantDialog, { onCancel: () => setEditDialogOpen(!1), onSubmit: () => setEditDialogOpen(!1), variant }), $[89] = editDialogOpen, $[90] = variant, $[91] = t46) : t46 = $[91];
1057
- let t47;
1058
- return $[92] !== T0 || $[93] !== t44 || $[94] !== t45 || $[95] !== t46 || $[96] !== t7 ? (t47 = /* @__PURE__ */ jsxs(T0, { direction: t1, flex: t2, height: t3, overflow: t4, children: [
1059
- t7,
1060
- t44,
1061
- t45,
1062
- t46
1063
- ] }), $[92] = T0, $[93] = t44, $[94] = t45, $[95] = t46, $[96] = t7, $[97] = t47) : t47 = $[97], t47;
1064
- }
1065
- function _temp$2(result) {
1066
- return result.document;
1203
+ }, $[44] = t13) : t13 = $[44];
1204
+ const t14 = variantDocumentsError ? /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: t("detail.documents.error") }) }) : /* @__PURE__ */ jsx(VariantDocumentsTable, { loading: documentsLoading, rows: tableRows, variantId: getVariantId(variant._id) });
1205
+ let t15;
1206
+ $[45] !== T0 || $[46] !== t13 || $[47] !== t14 ? (t15 = /* @__PURE__ */ jsx(T0, { direction: t10, flex: t11, overflow: t12, style: t13, children: t14 }), $[45] = T0, $[46] = t13, $[47] = t14, $[48] = t15) : t15 = $[48];
1207
+ let t16;
1208
+ $[49] !== variant ? (t16 = /* @__PURE__ */ jsx(VariantDetailFooter, { variant }), $[49] = variant, $[50] = t16) : t16 = $[50];
1209
+ let t17;
1210
+ return $[51] !== editDialogOpen || $[52] !== variant ? (t17 = editDialogOpen && /* @__PURE__ */ jsx(EditVariantDialog, { onCancel: () => setEditDialogOpen(!1), onSubmit: () => setEditDialogOpen(!1), variant }), $[51] = editDialogOpen, $[52] = variant, $[53] = t17) : t17 = $[53], /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", overflow: "hidden", children: [
1211
+ t3,
1212
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", flex: 1, height: "fill", overflow: "hidden", style: t4, children: [
1213
+ /* @__PURE__ */ jsx(Container, { flex: "none", width: 3, children: /* @__PURE__ */ jsx(Flex, { direction: "column", paddingX: 3, children: /* @__PURE__ */ jsxs(Card, { paddingY: 5, children: [
1214
+ /* @__PURE__ */ jsxs(Flex, { align: "flex-start", gap: 4, justify: "space-between", children: [
1215
+ /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
1216
+ /* @__PURE__ */ jsx(Text, { as: "h1", size: 4, weight: "bold", children: getVariantTitle(variant) }),
1217
+ /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: description || t("detail.no-description") })
1218
+ ] }),
1219
+ t7
1220
+ ] }),
1221
+ /* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
1222
+ t9,
1223
+ /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: conditionsText || t("overview.table.no-conditions") })
1224
+ ] }) })
1225
+ ] }) }) }),
1226
+ t15
1227
+ ] }),
1228
+ t16,
1229
+ t17
1230
+ ] });
1067
1231
  }
1068
1232
  function CreateVariantDialog(props) {
1069
1233
  const $ = c(16), {