@corva/ui 3.75.0-4 → 3.75.0-6
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/cjs-bundle/components/AddComment/Popover.js +1 -1
- package/cjs-bundle/components/AddComment/Popover.js.map +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js +1 -1
- package/cjs-bundle/components/AddComment/components/Content.js.map +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentDocument.js.map +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js +1 -1
- package/cjs-bundle/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -1
- package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js +1 -1
- package/cjs-bundle/components/AttachmentPreview/AttachmentTile.js.map +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
- package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.js +1 -1
- package/cjs-bundle/components/CommentCard/CommentCard.js.map +1 -1
- package/cjs-bundle/components/CommentComposer/ChatChannelSelector.js +1 -1
- package/cjs-bundle/components/CommentComposer/ChatChannelSelector.js.map +1 -1
- package/cjs-bundle/components/CommentComposer/ChatChannelSelector.scss.js +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
- package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
- package/cjs-bundle/utils/links.js +1 -1
- package/cjs-bundle/utils/links.js.map +1 -1
- package/components/AddComment/Popover.js +1 -1
- package/components/AddComment/Popover.js.map +1 -1
- package/components/AddComment/components/Content.js +1 -1
- package/components/AddComment/components/Content.js.map +1 -1
- package/components/AttachmentLightbox/AttachmentDocument.js +1 -1
- package/components/AttachmentLightbox/AttachmentDocument.js.map +1 -1
- package/components/AttachmentLightbox/AttachmentPreviewPane.js +1 -1
- package/components/AttachmentLightbox/AttachmentPreviewPane.js.map +1 -1
- package/components/AttachmentPreview/AttachmentPreview.types.d.ts +2 -0
- package/components/AttachmentPreview/AttachmentPreview.types.d.ts.map +1 -1
- package/components/AttachmentPreview/AttachmentTile.js +1 -1
- package/components/AttachmentPreview/AttachmentTile.js.map +1 -1
- package/components/BICOffsetPickerDialog/index.js +1 -1
- package/components/BICOffsetPickerDialog/index.js.map +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
- package/components/Casing/CasingTableV2/components/Component.js +1 -1
- package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
- package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
- package/components/CommentCard/CommentCard.d.ts.map +1 -1
- package/components/CommentCard/CommentCard.js +1 -1
- package/components/CommentCard/CommentCard.js.map +1 -1
- package/components/CommentComposer/ChatChannelSelector.d.ts.map +1 -1
- package/components/CommentComposer/ChatChannelSelector.js +1 -1
- package/components/CommentComposer/ChatChannelSelector.js.map +1 -1
- package/components/CommentComposer/ChatChannelSelector.scss.js +1 -1
- package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
- package/components/CommentComposer/useAttachmentUpload.js +1 -1
- package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
- package/components/DocumentViewer/DocumentViewer.js +1 -1
- package/components/DocumentViewer/DocumentViewer.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
- package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
- package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
- package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
- package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
- package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
- package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js +1 -1
- package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
- package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
- package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
- package/mcp-server/server.mjs +7 -7
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/utils/links.d.ts.map +1 -1
- package/utils/links.js +1 -1
- package/utils/links.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatChannelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/ChatChannelSelector.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChatChannelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/ChatChannelSelector.tsx"],"names":[],"mappings":"AAUA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA+CF,eAAO,MAAM,mBAAmB,kEAO7B,wBAAwB,4CAmC1B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{useMemo as o,useCallback as s}from"react";import{AutocompleteNext as c}from"../../componentsV2/Autocomplete/Autocomplete.js";import{Avatar as n}from"../../componentsV2/Avatar/Avatar.js";import{Text as i}from"../../componentsV2/Text/Text.js";import{TextMiddleTruncated as t}from"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import{FolderClosedIcon as r}from"../../icons/iconParkIcons.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import m from"./ChatChannelSelector.scss.js";import{jsx as e,jsxs as p}from"react/jsx-runtime";var u=function(o){return{id:o.rid,title:o.name,prefix:e("span",{className:m.optionPrefix,children:"d"===o.type?e(n,{size:24,name:o.name,imageSrc:o.avatarUrl}):e(r,{size:24})}),channel:o}},a=function(o,s){var c=s.trim().toLowerCase();return c?o.filter((function(o){var s,n=o.channel;return n.name.toLowerCase().includes(c)||(null!==(s=n.subtitle)&&void 0!==s?s:"").toLowerCase().includes(c)})):o.filter((function(o){return!o.channel.isVirtual}))},l=function(o){var s=o.channel;return p("span",{className:m.optionText,children:[e(t,{children:s.name}),s.subtitle&&e(i,{size:12,color:"T7",children:s.subtitle})]})},j=function(n){var i=n.channels,t=n.value,r=n.onChange,p=n.disabled,j=n.placeholder,I=void 0===j?"Select chat":j,d=n.testId,h=o((function(){return i.map(u)}),[i]),C=o((function(){var o;return t?null!==(o=h.find((function(o){return o.id===t.rid})))&&void 0!==o?o:u(t):void 0}),[h,t]),f=s((function(o){o&&r(o.channel)}),[r]);return e(c,{className:m.root,options:h,value:C,onChange:f,disabled:p,placeholder:I,optionSize:"medium",renderOption:l,filterOptions:a,noOptionsMessage:"No results found",clearable:!1,testId:d})};export{j as ChatChannelSelector};
|
|
2
2
|
//# sourceMappingURL=ChatChannelSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatChannelSelector.js","sources":["../../../src/components/CommentComposer/ChatChannelSelector.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"ChatChannelSelector.js","sources":["../../../src/components/CommentComposer/ChatChannelSelector.tsx"],"sourcesContent":["import { ReactNode, useCallback, useMemo } from 'react';\n\nimport { AutocompleteChangeHandler, AutocompleteNext } from '../../componentsV2/Autocomplete';\nimport { Avatar } from '../../componentsV2/Avatar';\nimport { Text } from '../../componentsV2/Text';\nimport { TextMiddleTruncated } from '../../componentsV2/TextMiddleTruncated';\nimport { FolderClosedIcon } from '../../icons';\n\nimport styles from './ChatChannelSelector.scss';\n\nexport type ChatChannel = {\n rid: string;\n name: string;\n subtitle?: string;\n avatarUrl?: string;\n type?: string;\n isVirtual?: boolean;\n};\n\nexport type ChatChannelSelectorProps = {\n channels: ChatChannel[];\n value: ChatChannel | null;\n onChange: (channel: ChatChannel) => void;\n disabled?: boolean;\n placeholder?: string;\n testId?: string;\n};\n\ntype ChannelOption = {\n id: string;\n title: string;\n prefix: ReactNode;\n channel: ChatChannel;\n};\n\nconst toOption = (channel: ChatChannel): ChannelOption => ({\n id: channel.rid,\n title: channel.name,\n // The span keeps AutocompleteMenuItem's icon auto-sizing from shrinking the 24px visuals\n prefix: (\n <span className={styles.optionPrefix}>\n {channel.type === 'd' ? (\n <Avatar size={24} name={channel.name} imageSrc={channel.avatarUrl} />\n ) : (\n <FolderClosedIcon size={24} />\n )}\n </span>\n ),\n channel,\n});\n\n// Virtual channels are not-yet-created DMs, so hide them until the user searches.\nconst filterOptions = (options: ChannelOption[], inputValue: string): ChannelOption[] => {\n const q = inputValue.trim().toLowerCase();\n if (!q) return options.filter(({ channel }) => !channel.isVirtual);\n\n return options.filter(\n ({ channel }) =>\n channel.name.toLowerCase().includes(q) || (channel.subtitle ?? '').toLowerCase().includes(q)\n );\n};\n\nconst renderOption = ({ channel }: ChannelOption) => (\n <span className={styles.optionText}>\n <TextMiddleTruncated>{channel.name}</TextMiddleTruncated>\n {channel.subtitle && (\n <Text size={12} color=\"T7\">\n {channel.subtitle}\n </Text>\n )}\n </span>\n);\n\nexport const ChatChannelSelector = ({\n channels,\n value,\n onChange,\n disabled,\n placeholder = 'Select chat',\n testId,\n}: ChatChannelSelectorProps) => {\n const options = useMemo(() => channels.map(toOption), [channels]);\n\n // Keep the value reference stable across renders: a fresh object would make MUI treat\n // every parent re-render as a selection change and reset the in-progress search input\n const selectedOption = useMemo(\n () => (value ? options.find(option => option.id === value.rid) ?? toOption(value) : undefined),\n [options, value]\n );\n\n const handleChange = useCallback<AutocompleteChangeHandler<ChannelOption>>(\n option => {\n if (option) {\n onChange(option.channel);\n }\n },\n [onChange]\n );\n\n return (\n <AutocompleteNext\n className={styles.root}\n options={options}\n value={selectedOption}\n onChange={handleChange}\n disabled={disabled}\n placeholder={placeholder}\n optionSize=\"medium\"\n renderOption={renderOption}\n filterOptions={filterOptions}\n noOptionsMessage=\"No results found\"\n clearable={false}\n testId={testId}\n />\n );\n};\n"],"names":["toOption","channel","id","rid","title","name","prefix","_jsx","className","styles","optionPrefix","children","type","Avatar","size","imageSrc","avatarUrl","FolderClosedIcon","filterOptions","options","inputValue","q","trim","toLowerCase","filter","_ref2","_channel$subtitle","includes","subtitle","_ref","isVirtual","renderOption","_ref3","_jsxs","optionText","TextMiddleTruncated","Text","color","ChatChannelSelector","_ref4","channels","value","onChange","disabled","_ref4$placeholder","placeholder","testId","useMemo","map","selectedOption","_options$find","find","option","undefined","handleChange","useCallback","AutocompleteNext","root","optionSize","noOptionsMessage","clearable"],"mappings":"4pIAmCA,IAAMA,EAAW,SAACC,GAAoB,MAAqB,CACzDC,GAAID,EAAQE,IACZC,MAAOH,EAAQ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C,IAGH,OACEnC,EAACiD,EAAgB,CACfhD,UAAWC,EAAOgD,KAClBtC,QAASA,EACTsB,MAAOQ,EACPP,SAAUY,EACVX,SAAUA,EACVE,YAAaA,EACba,WAAW,SACX3B,aAAcA,EACdb,cAAeA,EACfyC,iBAAiB,mBACjBC,WAAW,EACXd,OAAQA,GAGd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from'./../../ext-esm/style-inject/dist/style-inject.es.js';var t={
|
|
1
|
+
import e from'./../../ext-esm/style-inject/dist/style-inject.es.js';var t={root:"ChatChannelSelector_root__olCVl",optionPrefix:"ChatChannelSelector_optionPrefix__rEJEV",optionText:"ChatChannelSelector_optionText__ZZQ7Z"};e(".ChatChannelSelector_root__olCVl{flex:1;min-width:0}.ChatChannelSelector_optionPrefix__rEJEV{align-items:center;display:inline-flex;flex-shrink:0}.ChatChannelSelector_optionText__ZZQ7Z{display:flex;flex-direction:column;min-width:0}");export{t as default};
|
|
2
2
|
//# sourceMappingURL=ChatChannelSelector.scss.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachmentUpload.d.ts","sourceRoot":"","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA4C,MAAM,OAAO,CAAC;AAG9E,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,8CAA8C,CAAC;AAOtD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,QAAQ,EAAE,CAAC,WAAW,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;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BAAgB,CAAC;sBApD7B,IAAI,EAAE;0BA7BR,MAAM;2BA6FP,qBAAqB,CAAC,IAAI,CAAC;sBAW3B,qBAAqB,CAAC,IAAI,CAAC;qCAcnB,qBAAqB,CAAC,IAAI,CAAC,EAAE;;;;;;;CAmH7C,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import i from"@babel/runtime/regenerator";import{useState as
|
|
1
|
+
import r from"@babel/runtime/helpers/toConsumableArray";import e from"@babel/runtime/helpers/asyncToGenerator";import n from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import i from"@babel/runtime/regenerator";import{useState as o,useRef as u,useCallback as l,useEffect as c}from"react";import a from"react-s3-uploader/s3upload";import{getAttachmentKind as f}from"../AttachmentPreview/getAttachmentKind.js";import{ACCEPTED_ATTACHMENT_TYPES as s}from"../AttachFileButton/AttachFileButton.js";import{getS3SignedUrl as d,getS3DownloadLink as p}from"../../clients/jsonApi/index.js";import{getUrlFileName as v}from"../../utils/links.js";function m(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);e&&(t=t.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.push.apply(n,t)}return n}function h(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?m(Object(t),!0).forEach((function(e){n(r,e,t[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):m(Object(t)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))}))}return r}var g=10,b=function(r){return r.type.startsWith("image/")?"image":r.type.startsWith("video/")?"video":"file"},w=function(r){return(r/1048576).toFixed(1)},U=function(r){return{id:r.url,name:r.name,file:null,previewUrl:"",isUploading:!1,error:null,uploaded:r}},y=0,j=function(){return"attachment-".concat(y+=1)},O=function(n){var m,g,y=n.value,O=n.onChange,k=n.onError,F=n.maxSizeBytes,x=n.maxFiles,L=void 0===x?10:x,P=n.accept,A=void 0===P?s:P,S=o([]),z=t(S,2),E=z[0],R=z[1],B=u(null),D=u(new Map),C=u(new Map),M=u([]),W=u(O),T=u(k);W.current=O,T.current=k;var I=u([]),Y=l((function(r){var e=r(M.current);M.current=e,R(e),I.current=function(r){return r.map((function(r){return r.uploaded})).filter(Boolean)}(e),W.current(I.current)}),[]),_=l((function(r,e){return Y((function(n){return n.map((function(n){return n.id===r?h(h({},n),e):n}))}))}),[Y]),G=l((function(r){var e,n;null===(e=D.current.get(r))||void 0===e||e.abortUpload(),D.current.delete(r),C.current.set(r,(null!==(n=C.current.get(r))&&void 0!==n?n:0)+1)}),[]),K=l((function(r){null!=r&&r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}),[]),q=l((function(){var r,e,n;null===(r=T.current)||void 0===r||r.call(T,null!==(e=null===(n=M.current.find((function(r){return r.error})))||void 0===n?void 0:n.error)&&void 0!==e?e:null)}),[]);c((function(){return function(){D.current.forEach((function(r){return r.abortUpload()})),D.current.clear(),M.current.forEach((function(r){r.previewUrl&&URL.revokeObjectURL(r.previewUrl)}))}}),[]);var H=l((function(r,n){var t,o=(null!==(t=C.current.get(r))&&void 0!==t?t:0)+1;C.current.set(r,o);var u,l,c=function(){return C.current.get(r)===o},f=function(e){var n;c()&&(_(r,{isUploading:!1,error:e}),null===(n=T.current)||void 0===n||n.call(T,e))},s="",v=new a({files:[n],preprocess:function(r,e){return e(r)},onProgress:function(){},getSignedUrl:(l=e(i.mark((function r(e,n){var t;return i.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,d(e.name,e.type);case 3:t=r.sent,s=t.file_name,n(h(h({},t),{},{signedUrl:t.signed_url})),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(0),f((null===r.t0||void 0===r.t0?void 0:r.t0.message)||"Failed to upload the file");case 11:case"end":return r.stop()}}),r,null,[[0,8]])}))),function(r,e){return l.apply(this,arguments)}),onFinishS3Put:(u=e(i.mark((function e(){var t,o;return i.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,p(s);case 3:if(t=e.sent,o=t.url,c()){e.next=7;break}return e.abrupt("return");case 7:D.current.delete(r),_(r,{isUploading:!1,error:null,uploaded:{url:o,name:s,size:n.size}}),q(),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(0),f((null===e.t0||void 0===e.t0?void 0:e.t0.message)||"Failed to upload the file");case 15:case"end":return e.stop()}}),e,null,[[0,12]])}))),function(){return u.apply(this,arguments)}),onError:function(r){return f(r||"Failed to upload the file")}});D.current.set(r,v)}),[_,q]),J=l((function(e){var n,t=v(e);t&&(M.current.length>=L?null===(n=T.current)||void 0===n||n.call(T,"You can attach up to ".concat(L," files.")):M.current.some((function(r){var n;return(null===(n=r.uploaded)||void 0===n?void 0:n.url)===e}))||Y((function(n){return[].concat(r(n),[{id:j(),name:t,file:null,previewUrl:e,isUploading:!1,error:null,uploaded:{url:e,name:t}}])})))}),[Y,L]),N=l((function(e){var n,t,i,o,u=e.filter((function(r){return function(r,e){return e.split(",").map((function(r){return r.trim().toLowerCase()})).filter(Boolean).some((function(e){if(e.startsWith("."))return r.name.toLowerCase().endsWith(e);if(e.endsWith("/*")){var n=r.type.toLowerCase();return n?n.startsWith(e.slice(0,-1)):f({name:r.name})===e.slice(0,-1)}return r.type.toLowerCase()===e}))}(r,A)})),l=u.length<e.length?1===e.length?"That file type is not supported.":"Some files were skipped — unsupported file type.":null,c="You can attach up to ".concat(L," files."),a=L-M.current.length;if(!u.length||a<=0){var s;null===(s=T.current)||void 0===s||s.call(T,u.length?c:l)}else{var d=u.slice(0,a),p=d.map((function(r){var e=b(r),n=!!F&&r.size>F;return{id:j(),name:r.name,file:r,previewUrl:"file"===e?"":URL.createObjectURL(r),isUploading:!n,error:n?"File is too large (".concat(w(r.size)," MB). Maximum size is ").concat(w(F)," MB."):null,uploaded:null}}));Y((function(e){return[].concat(r(e),r(p))}));var v=u.length>d.length?c:null;null===(n=T.current)||void 0===n||n.call(T,null!==(t=null!==(i=null===(o=M.current.find((function(r){return r.error})))||void 0===o?void 0:o.error)&&void 0!==i?i:l)&&void 0!==t?t:v),p.filter((function(r){return!r.error})).forEach((function(r){return H(r.id,r.file)}))}}),[Y,L,F,H,A]),Q=l((function(r){var e,n=Array.from(null!==(e=r.target.files)&&void 0!==e?e:[]);B.current&&(B.current.value=""),n.length&&N(n)}),[N]),V=l((function(){var r;return null===(r=B.current)||void 0===r?void 0:r.click()}),[]),X=l((function(r){var e=String(r);G(e),K(M.current.find((function(r){return r.id===e}))),Y((function(r){return r.filter((function(r){return r.id!==e}))})),q()}),[G,K,Y,q]),Z=l((function(r){var e=String(r),n=M.current.find((function(r){return r.id===e}));null!=n&&n.file&&(G(e),_(e,{isUploading:!0,error:null}),q(),H(e,n.file))}),[G,_,H,q]),$=l((function(e){return Y((function(n){var t=new Map(n.map((function(r){return[r.id,r]}))),i=e.map((function(r){return t.get(String(r))})).filter(Boolean),o=n.filter((function(r){return!e.some((function(e){return String(e)===r.id}))}));return[].concat(r(i),r(o))}))}),[Y]),rr=l((function(){var r;M.current.forEach((function(r){G(r.id),K(r)})),Y((function(){return[]})),null===(r=T.current)||void 0===r||r.call(T,null)}),[G,Y,K]);c((function(){var r,e,n;(e=I.current,n=y,e.length===n.length&&e.every((function(r,e){return r.url===n[e].url})))||(M.current.forEach((function(r){G(r.id),r.previewUrl&&URL.revokeObjectURL(r.previewUrl)})),M.current=y.map(U),I.current=y,R(M.current),null===(r=T.current)||void 0===r||r.call(T,null))}),[y,G]);var er=o({}),nr=t(er,2),tr=nr[0],ir=nr[1],or=u(tr);or.current=tr;var ur=E.filter((function(r){return!r.file&&!r.previewUrl&&r.uploaded})).map((function(r){return r.uploaded.name})).join("|");return c((function(){var r=ur.split("|").filter((function(r){return r&&!(r in or.current)}));if(r.length){var e=!0;return Promise.all(r.map((function(r){return p(r,"inline").then((function(e){var n=e.url;return[r,n]})).catch((function(e){return console.error('Failed to sign stored attachment "'.concat(r,'"'),e),[r,""]}))}))).then((function(r){e&&ir((function(e){return h(h({},e),Object.fromEntries(r))}))})),function(){e=!1}}}),[ur]),{items:E.reduce((function(r,e){var n;if(e.file)return r.push({id:e.id,name:e.name,src:e.previewUrl,kind:b(e.file),size:e.file.size,isUploading:e.isUploading,hideDownload:!0,error:null!==(n=e.error)&&void 0!==n?n:void 0}),r;var t=e.uploaded,i=f(t),o=e.previewUrl||tr[t.name];return"file"===i||o?(r.push({id:e.id,name:t.name,src:o,kind:i,size:t.size,hideDownload:!0}),r):r}),[]),fileInputRef:B,openFileDialog:V,handleFileSelect:Q,addFiles:N,addLinkedImage:J,removeAttachment:X,handleRetry:Z,reorderAttachments:$,clearAttachments:rr,isUploading:E.some((function(r){return r.isUploading})),error:null!==(m=null===(g=E.find((function(r){return r.error})))||void 0===g?void 0:g.error)&&void 0!==m?m:null,count:E.length,isFull:E.length>=L,maxFiles:L}};export{g as DEFAULT_MAX_ATTACHMENTS,O as useAttachmentUpload};
|
|
2
2
|
//# sourceMappingURL=useAttachmentUpload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl, getS3DownloadLink } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const { url } = await getS3DownloadLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>({});\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getS3DownloadLink(name, 'inline')\n .then(({ url }: { url: string }) => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_yield$getS3DownloadL","_context2","getS3DownloadLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","_ref3","catch","console","resolved","_objectSpread","Object","fromEntries","items","reduce","acc","_entry$error","push","src","undefined","stored","count","isFull"],"mappings":"uuCAyCO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,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ACC,EAAKlJ,GAC1C,IAAAmJ,EAAhB,GAAInJ,EAAMpD,KAUR,OATAsM,EAAIE,KAAK,CACPhM,GAAI4C,EAAM5C,GACVE,KAAM0C,EAAM1C,KACZ+L,IAAKrJ,EAAMzC,WACXyI,KAAMrJ,EAAYqD,EAAMpD,MACxBwH,KAAMpE,EAAMpD,KAAKwH,KACjB5G,YAAawC,EAAMxC,YACnBC,MAAsB6L,QAAftJ,EAAAA,EAAMvC,aAAS6L,IAAAA,EAAAA,OAAAA,IAEjBJ,EAGT,IAAMK,EAASvJ,EAAMtC,SACfsI,EAAOR,EAAkB+D,GAEzBF,EAAMrJ,EAAMzC,YAAcwK,GAAWwB,EAAOjM,MAElD,MAAa,SAAT0I,GAAoBqD,GAExBH,EAAIE,KAAK,CAAEhM,GAAI4C,EAAM5C,GAAIE,KAAMiM,EAAOjM,KAAM+L,IAAAA,EAAKrD,KAAAA,EAAM5B,KAAMmF,EAAOnF,OAC7D8E,GAH6BA,CAIrC,GAAE,IAIDjK,aAAAA,EACAwH,eAAAA,EACAL,iBAAAA,EACAxB,SAAAA,EACAP,eAAAA,EACAuC,iBAAAA,EACAG,YAAAA,EACAE,mBAAAA,EACAK,iBAAAA,GACA9J,YAAauB,EAAQ0F,MAAK,SAAAzE,GAAK,OAAIA,EAAMxC,eACzCC,MAAgD,UAAzC,UAAAsB,EAAQqC,MAAK,SAAApB,GAAK,OAAIA,EAAMvC,KAAK,WAAjC,IAAAQ,OAAA,EAAAA,EAAoCR,aAAK,IAAAO,EAAAA,EAAI,KACpDwL,MAAOzK,EAAQyF,OACfiF,OAAQ1K,EAAQyF,QAAUjG,EAC1BA,SAAAA,EAEJ"}
|
|
1
|
+
{"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl, getS3DownloadLink } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const { url } = await getS3DownloadLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>({});\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getS3DownloadLink(name, 'inline')\n .then(({ url }: { url: string }) => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n hideDownload: true,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size, hideDownload: true });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_yield$getS3DownloadL","_context2","getS3DownloadLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","_ref3","catch","console","resolved","_objectSpread","Object","fromEntries","items","reduce","acc","_entry$error","push","src","hideDownload","undefined","stored","count","isFull"],"mappings":"uuCAyCO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY,EAEd,EAEaG,EAAsB,SAODC,GAAA,IAAAC,EAAAC,EANhCC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,aAAYC,EAAAP,EACZQ,SAAAA,aAvDqC,GAuDHD,EAAAE,EAAAT,EAClCU,OAAAA,aAASC,EAAyBF,EAEJG,EAAAA,EAAkB,IAAGC,EAAAC,EAAAC,EAAA,GAA5CC,EAAOH,EAAA,GAAEI,EAAUJ,EAAA,GAEpBK,EAAeC,EAAyB,MACxCC,EAAeD,EAAO,IAAIE,KAE1BC,EAAcH,EAAO,IAAIE,KAEzBE,EAAaJ,EAAgB,IAC7BK,EAAcL,EAAOf,GACrBqB,EAAaN,EAAOd,GAE1BmB,EAAYE,QAAUtB,EACtBqB,EAAWC,QAAUrB,EAIrB,IAAMsB,EAAaR,EAA6B,IAE1CS,EAASC,GAAY,SAACC,GAC1B,IAAMC,EAAOD,EAAQP,EAAWG,SAChCH,EAAWG,QAAUK,EACrBd,EAAWc,GACXJ,EAAWD,QApDK,SAACV,GAAgB,OACnCA,EAAQgB,KAAI,SAAAC,GAAK,OAAIA,EAAMtC,QAAQ,IAAEuC,OAAOC,QAAQ,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,IAAAO,EAAAA,EAAI,KACpDyL,MAAO1K,EAAQyF,OACfkF,OAAQ3K,EAAQyF,QAAUjG,EAC1BA,SAAAA,EAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{useState as t,createRef as s,useCallback as i,useEffect as n}from"react";import r from"prop-types";import p from"classnames";import{Modal as m,Typography as c,IconButton as a}from"@material-ui/core";import l from"@material-ui/icons/Close";import d from"@material-ui/icons/GetApp";import{useStyles as j}from"./styles.js";import"../DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider/IsInsideIsolatedDcAppProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/DcFullscreenElemsCoordinatorProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js";import"@babel/runtime/helpers/objectWithoutProperties";import"lodash";import"../Modal/CorvaModal.scss.js";import"@icon-park/react/es/all";import{jsx as u,jsxs as C}from"react/jsx-runtime";import"../../icons/IconParkProvider.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import"../../utils/mobileDetect.js";import"../IconButton/index.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/appPackages.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../constants/corvaCompanyId.js";import"../GradientManager/configuration/constants.js";import"uuid";import"../IconMenu/index.js";import"../StyledMenuItem/index.js";import"../AppIcon/AppIcon.js";import"../DevCenter/AppHeader/AppHeader.js";import"../DevCenter/AppSideBar/AppSideBar.js";import"../DevCenter/AppsDataProvider/AppsDataProvider.js";import"../DevCenter/AppContext.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"react-router-dom";import"query-string";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"../../utils/index.js";import"../DevCenter/DevCenterAppContainer/components/AppActions/AppActions.css.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/RemoveAppButton.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/SettingsAccordion.js";import"../DevCenter/DevCenterAppContainer/components/AnnotationsButton.js";import"../../componentsV2/Text/Text.js";import"../../componentsV2/Grid/Grid.js";import"../../componentsV2/Grid/Cell.js";import"../../componentsV2/Header/Header.scss.js";import"../../componentsV2/Button/Button.js";import"../../componentsV2/ButtonIcon/ButtonIcon.js";import"../../componentsV2/Tooltip/Tooltip.scss.js";import"../../componentsV2/Popover/Popover.js";import"../../componentsV2/PopoverPanel/PopoverPanel.js";import"../../componentsV2/Radio/Radio.js";import"../../componentsV2/RadioAndCheckboxGroup/RadioAndCheckboxGroup.scss.js";import"../../componentsV2/Checkbox/Checkbox.js";import"@babel/runtime/helpers/toConsumableArray";import"../../componentsV2/TextInput/TextInput.js";import"../../componentsV2/TextInputNext/TextInputNext.js";import"../../componentsV2/TextArea/TextArea.js";import"../../componentsV2/Label/Label.js";import"../../componentsV2/TextEndTruncated/TextEndTruncated.scss.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.scss.js";import"../../componentsV2/TextLink/TextLink.js";import"../../componentsV2/Chip/Chip.js";import"../../componentsV2/ChipAlert/ChipAlert.js";import"../../componentsV2/ChipIndicator/ChipIndicator.js";import"../../componentsV2/Avatar/Avatar.js";import"../../componentsV2/AvatarGroup/AvatarGroup.js";import"@material-ui/lab";import"../../componentsV2/ToggleButtons/ToggleButtons.scss.js";import"../../componentsV2/Paper/Paper.js";import"../../componentsV2/ModalWindow/ModalWindow.js";import"../../componentsV2/Modal/Modal.scss.js";import"../../componentsV2/Menu/Menu.js";import"../../componentsV2/utils.js";import"../../componentsV2/Hint/Hint.scss.js";import"../../componentsV2/Counter/Counter.js";import"../../componentsV2/BadgeBase/BadgeBase.scss.js";import"../../componentsV2/TemplatesControl/TemplatesControl.js";import"zustand";import"../../componentsV2/TemplatesControl/utils.js";import"../../componentsV2/TemplatesControl/icons/folder/index.js";import"../../componentsV2/TemplatesControl/Store/utils.js";import"../../componentsV2/TemplatesControl/types.js";import"../../clients/jsonApi/index.js";import"../../permissions/PermissionsContext.js";import"../../permissions/constants/index.js";import"../../permissions/withPermissionsHOC.js";import"../../permissions/ProvidePermissions.js";import"../../componentsV2/BadgeDot/BadgeDot.scss.js";import"../../componentsV2/LoaderLinear/LoaderLinear.scss.js";import"../../componentsV2/LoaderLogo/LoaderLogo.constants.js";import"../../componentsV2/LoaderLogo/LoaderLogo.scss.js";import"../../componentsV2/Switch/Switch.js";import"../../componentsV2/Tabs/Tabs.js";import"../../componentsV2/EmptyState/EmptyState.scss.js";import"../../componentsV2/FileIcon/FileIcon.js";import"../../componentsV2/Tag/Tag.js";import"react-dropzone";import"../../componentsV2/FilesDropzone/FilesDropzone.scss.js";import"../../componentsV2/FilesLoader/FilesLoader.scss.js";import"file-extension";import"image-extensions";import"video-extensions";import"../../componentsV2/FilesProcessor/FilesProcessor.scss.js";import"../../componentsV2/Skeleton/Skeleton.scss.js";import"../../utils/main.js";import"../../componentsV2/CopyToClipboard/CopyToClipboard.scss.js";import"../../componentsV2/Stepper/Step/Step.scss.js";import"../../componentsV2/Stepper/Stepper.scss.js";import"../../componentsV2/ButtonLive/ButtonLive.js";import"../../componentsV2/ButtonText/ButtonText.js";import"../../componentsV2/IndicatorLive/IndicatorLive.js";import"../../componentsV2/Accordion/Accordion.scss.js";import"../../componentsV2/Breadcrumbs/Breadcrumbs.scss.js";import"../../componentsV2/BadgeComment/BadgeComment.js";import"../../componentsV2/AppContainer/AppContainer.js";import"../../componentsV2/AppContainer/AppContainer.constants.js";import"../../componentsV2/AppFooter/AppFooter.js";import"immutable";import"../../componentsV2/AppCommonsProvider/AppCommonsContext.js";import"../../componentsV2/AppHeader/AppHeader.constants.js";import"../../componentsV2/AppHeader/AppBadge/AppBadge.scss.js";import"../../componentsV2/AppHeader/AppAssets/utils.js";import"../../componentsV2/AppHeader/AppAssets/AppAssets.scss.js";import"../PadModeSelect/PadModeSelect.js";import"../../componentsV2/AppHeader/PadMode/PadMode.scss.js";import"../../constants/streamSourceType.js";import"../../componentsV2/PadModeSelect/PadModeSelect.js";import"../../componentsV2/PadModeSelect/PadModeSelect.constants.js";import"../../componentsV2/AppCommonsProvider/AppCommonsProvider.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js";import"../../componentsV2/UniversalLink/UniversalLink.scss.js";import"../../componentsV2/AppHeader/V3/AssetChips/AssetChips.scss.js";import"moment";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.constants.js";import"../../componentsV2/AppFooter/DqPopover/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppDqPopover/DqAlertTooltip/DqAlertTooltip.scss.js";import"../../componentsV2/AppDqPopover/DqAlert/DqAlert.scss.js";import"../../componentsV2/AppDqPopover/DqAsset/DqAsset.scss.js";import"../../componentsV2/AppDqPopover/AppDqPopover.scss.js";import"../../utils/getSingleAsset.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorChip/AssetSelectorChip.js";import"../../componentsV2/AppHeader/V3/AssetSelector/constants.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/AssetSelectorSelect.scss.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/loadAssets.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelector.scss.js";import"../../clients/subscriptions/constants.js";import"querystring";import"uuid/v1";import"../../clients/subscriptions.v1.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"jsona";import"../../utils/env.js";import"../StatusBadge/constants.js";import"lodash/set";import"lodash/get";import"lodash/unset";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import"lodash/isEmpty";import"lodash/sortBy";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js";import"../../componentsV2/AppSettings/AppSettingsPinningContext.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.constants.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.scss.js";import"../../componentsV2/AppHeader/V3/constants.scss.js";import"@babel/runtime/helpers/typeof";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.js";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.constants.js";import"../../componentsV2/AppSettings/AppSettings.js";import"../../componentsV2/AppSettings/AppSettings.constants.js";import"../../componentsV2/AppSizeProvider/AppSizeProvider.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.constants.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.scss.js";import"../../componentsV2/AppHeader/V3/AppHeaderV3.scss.js";import"../../componentsV2/AppHeader/AppHeader.scss.js";import"../../componentsV2/OffsetWellsButton/OffsetWellsButton.js";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtreme.scss.js";import"highcharts";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtremeDragTracker.js";import"../../componentsV2/Autocomplete/Autocomplete.js";import"../../componentsV2/Select/Select.js";import"../../componentsV2/AppSettingsDivider/AppSettingsDivider.scss.js";import"../../componentsV2/WellArchivedMessage/WellArchivedMessage.js";import"../../componentsV2/DatePicker/DatePicker.js";import"../../componentsV2/DragHandle/DragHandle.js";import"../../componentsV2/CompletionsOffsetWellPicker/CompletionsOffsetWellPicker.js";import"../../componentsV2/Slider/constants.js";import"../../componentsV2/Slider/components/SliderThumb.js";import"../../componentsV2/Slider/Slider.scss.js";import"../../componentsV2/SliderAdvanced/SliderAdvanced.js";import"react-color";import"../../componentsV2/ColorPicker/Swatches/Swatches.scss.js";import"../../componentsV2/ColorPicker/OpacityDragtracker/OpacityDragTracker.scss.js";import"../../componentsV2/ColorPicker/ColorPicker.scss.js";import"../../componentsV2/ChartHelper/ChartHelper.scss.js";import"../../componentsV2/Hotkey/Hotkey.js";import"@tanstack/react-query";import"../../componentsV2/InterventionEventSelector/useInterventionUnitEvents.js";import"../../componentsV2/InterventionEventSelector/InterventionEventSelector.scss.js";import"@material-ui/icons";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.scss.js";import"../DevCenter/DevCenterAppContainer/components/FullscreenButton/FullscreenButton.js";import"../Icons/AnnotationIcon.js";import"../HelpCenter/HelpCenterIcon.js";import"../DevCenter/DevCenterAppContainer/components/AppInfoMessage/AppInfoMessage.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/components/ChooseAssetButton.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/DevCenterAppView.scss.js";import"../ErrorBoundary/ErrorBoundary.js";import"../ErrorBoundary/DevCenterAppErrorView/DevCenterAppErrorView.js";import"../Annotations/components/AnnotationsList/index.js";import"../Annotations/components/LastAnnotation/index.js";import"../Annotations/AnnotationsContext.js";import"../DevCenter/DevCenterAppContainer/components/RestoreAppSizeButton/index.js";import"../DevCenter/DevCenterAppContainer/DevCenterAppContainer.scss.js";import"../Toaster/Toaster.js";import"../DevCenter/NavigationBar/NavigationBar.js";import"../DevCenter/SideBar/SideBar.js";import"../DevCenter/AppSettingsPopover/AppSettingsPopover.js";import"../DevCenter/AppFilterPanelLayout/AppFilterPanelLayout.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js";import"../AssetEditor/index.js";import"../AssetEditorV2/index.js";import"../AppVersionsSelect/AppVersionsSelect.js";import I from"../LoadingIndicator/LoadingIndicator.js";import"../Typography.js";import"../RealTimeValuesSidebar/RealTimeSidebar.js";import"../CollapsableSidebar.js";import"../DateTimePicker/index.js";import"../DatePicker/index.js";import"../SlateFormattedText/SlateFormattedText.js";import"../SlateFormattedText/RenderElements.js";import"slate";import"../EmptyState/EmptyState.js";import"../ParameterCharts/ParameterCharts.js";import"../ParameterCharts/AddEditTrack.js";import"../ChartActionsList/ChartActionsList.js";import"../CopyToClipboard/CopyToClipboard.js";import"../AssetEditor/AssetEditorAutocomplete.js";import"../AssetEditor/SingleAssetEditor.js";import"../SettingEditors/ColorEditor/style.css.js";import"../SettingEditors/DropdownEditor/index.js";import"../SwitchControl/index.js";import"../ColorPicker/ColorPicker.js";import"../Chart/components/ChartButton.js";import"../Chart/components/ChartButtons.js";import"../Chart/components/ChartWrapper.js";import"../Chart/components/AxisDropdown.js";import"../Chart/components/ChartSelect.js";import"../Chart/ChartWrapperContext.js";import"../Chart/effects/useChartModifier.js";import"../Chart/components/buttons/HideAxesButton.js";import"../Chart/components/buttons/ChartTypeButton.js";import"../ColorPicker/PaletteChromePicker/PaletteChromePicker.js";import"../TruncatedText/index.js";import"../MiddleTruncatedText/MiddleTruncatedText.js";import"../RangeSlider/constants.js";import"../RangeSlider/Input.css.js";import"../RangeSlider/RangeSlider.css.js";import"../AdvancedSlider/AdvancedSlider.js";import"../Breadcrumbs/index.js";import"../VirtualizedTable/index.js";import"../EmptyView/EmptyView.js";import"../EmptyView/EmptyAppView/EmptyAppView.js";import"../Button/components/Button/index.js";import"moment-timezone";import"../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js";import"../Button/components/LiveButton/styles.js";import"../ContextMenuItem/index.js";import"../FolderMenuItem/index.js";import"../EditableItem/EditableItem/index.js";import"../EditableItem/EditableItemWithBadge/index.js";import"../Checkbox/index.js";import"../FolderMenuItemWithLinks/index.js";import"../TextField/index.js";import"../Chip/index.js";import"../Counter/index.js";import"../AnchorsList/AnchorsList.js";import"../Select/index.js";import"../Select/SelectFilterBy.js";import"../CustomSelect/index.js";import"../Tabs/Tabs.js";import"../Tabs/Tab.js";import"../ResizableTable/ResizableTable.js";import"../GradientPicker/GradientPicker.js";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"../GradientManager/GradientPreview/GradientPreview.js";import"../GradientManager/GradientSelect.scss.js";import"../GradientManager/GradientManager.styles.js";import"../Drillstring/BHASchematic.js";import"../Drillstring/BHATable/index.js";import"../Drillstring/BHAComponentIcon.js";import"../Drillstring/BHAComponentDetail/index.js";import"../Drillstring/BHATileIcon.js";import"../Drillstring/BHATile/BHATile.js";import"../Drillstring/BHAList/BHAList.js";import"../Drillstring/BHAComponentsTable/BHAComponentsTable.js";import"../Casing/CasingTable/index.js";import"../Casing/CasingComponentIcon.js";import"../Casing/CasingTileIcon.js";import"../Casing/CasingTableV2/CasingTableV2.js";import"../Casing/CasingTile/CasingTile.js";import"../DisabledSettingsMessage/DisabledSettingsMessage.js";import"../WellSummary/WellSummaryItemLabel.js";import"../WellSummary/WellSummaryItemTitle.js";import"../WellSummary/WellSummaryItemValue.js";import"../WellSummary/ActivitySummaryChart.js";import"../WellSummary/FracWirelineTimeChart.js";import"../BICOffsetPickerDialog/index.js";import"../OffsetWellButton/OffsetWellButton.js";import"../OffsetWellPickerV2/OffsetWellPickerDialog.js";import"../OffsetWellPickerV3/index.js";import"../OffsetWellChips/Chip.js";import"../OffsetWellChips/ChipsContainer.js";import"../OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/OffsetWellPickerV5WithStore.js";import"../OffsetWellMap/OffsetWellMap.js";import"@material-ui/core/Snackbar";import"../Notifications/Toast.js";import"../Notifications/Notifications.scss.js";import"../ConfirmationDialog.js";import"../TextLink/index.js";import"../Avatar/index.js";import"../Template/TemplatePopover/index.js";import"../Template/TemplateSharingDialog/index.js";import"../MenuItem/index.js";import"../MiddleTruncate/MiddleTruncate.js";import"../PinnableFilters/PinnableFilters.js";import"../HeaderLayout/HeaderLayout.js";import"../PadOffsetsPicker/PadOffsetsPicker.js";import"../PadOffsetsPicker/OffsetAssetChip.js";import"../PadOffsetsPicker/OffsetAssetsListExpander.js";import"../PadOffsetsPicker/StagesSelector.js";import"../PadOffsetsPickerV2/PadOffsetsPickerV2.js";import"../Table/TableToolbar/TableToolbar.js";import"../Table/TableContainer/TableContainer.js";import"../Table/TableCell/TableCell.js";import"../Table/TablePagination/TablePagination.js";import"../Table/TablePaginationActions/TablePaginationActions.js";import"../Tooltip/ScrollableTooltip.js";import"../PriceInput/PriceInput.js";import"../LabelsCounter/LabelsCounter.js";import"../Stepper/Stepper.js";import"../Stepper/Step/Step.js";import"../Stepper/StepsWrapper.js";import"../Comment/CommentIcon/index.js";import"../FilesLoader/FilesLoader.js";import"../../componentsV2/FileIcon/icons/ArchiveFileIcon.js";import"../../componentsV2/FileIcon/icons/CSVFileIcon.js";import"../../componentsV2/FileIcon/icons/DocFileIcon.js";import"../../componentsV2/FileIcon/icons/EDMFileIcon.js";import"../../componentsV2/FileIcon/icons/ExcelFileIcon.js";import"../../componentsV2/FileIcon/icons/ImageFileIcon.js";import"../../componentsV2/FileIcon/icons/JsonFileIcon.js";import"../../componentsV2/FileIcon/icons/LasFileIcon.js";import"../../componentsV2/FileIcon/icons/OtherFileIcon.js";import"../../componentsV2/FileIcon/icons/PdfFileIcon.js";import"../../componentsV2/FileIcon/icons/PowerPointFileIcon.js";import"../../componentsV2/FileIcon/icons/TxtFileIcon.js";import"../../componentsV2/FileIcon/icons/UnknownFileIcon.js";import"../../componentsV2/FileIcon/icons/VideoFileIcon.js";import"../../componentsV2/FileIcon/icons/XmlFileIcon.js";import"../SearchInput/index.js";import"../FeedItem/FeedItem.js";import"../FeedItem/FeedItemEditProvider/FeedItemEditProvider.js";import"../PostInput/PostInput.js";import"../KeyboardDateTimePicker.js";import"../AddComment/Popover.js";import"../AddComment/Popup.js";import"../StageDesignVActual/ComparisonBar/ComparisonBar.js";import"../StageDesignVActual/ElementsComparison/ElementsComparison.js";import"../StageDesignVActual/ComparisonHeader.js";import"../StageDesignVActual/ComparisonRow.js";import"../EmbeddedApp/DevCenterEmbeddedApp.js";import"../EmbeddedApp/EmbeddedApp.js";import"../Autocomplete/Autocomplete.js";import"../ColorPickerPalette/ColorPickerPalette.js";import"../Search/Search.js";import"../Search/components/Listbox.js";import"../Search/components/Paper.js";import"../Search/components/RecentSearches.js";import"../Search/components/Groups.js";import"../Search/components/SelectAllListItem.js";import"../StatusBadge/index.js";import"../Attachment/index.js";import"../EmojiIconButton.js";import"../FileUploadIconButton.js";import"../FilePreview/index.js";import"../FailedFileUploading.js";import"../UserMention/index.js";import"../CommentsInfo/index.js";import"../CommentInput/index.js";import"../Comment/index.js";import"../CommentLoader.js";import"../AssetNameLabel/AssetStatusBadge.js";import"../AssetEditorV2/components/PrimaryAssetSelect.js";import"../AssetEditorV2/components/SecondaryAssetSelect.js";import"../AssetEditorV2/components/SelectItem.js";import"../AssetEditorV2/components/MultipleAssetsToggle.js";import"../AssetEditorV2/components/PrimaryAssetSelectV2.js";import"../EChartsWrapper/EChartsWrapper.js";import"../AssetsMultipleSelector/AssetsMultipleSelector.js";import"../GoogleDocsViewer/index.js";import"../NewDocumentViewer/effects/useFileContent.js";import"../NewDocumentViewer/styles.js";import"../FilesLoaderV2/styles.js";import"../FilesDropzone/styles.js";import"../FilesProcessor/styles.js";import"../Hint/styles.js";import"@babel/runtime/helpers/taggedTemplateLiteral";import"fparser";import"../Formula/useFormulaStyles.js";import"../Formula/RootXIcon.js";import"../Formula/FormulaTextEditor.js";import"../Formula/CloseSuggestion.js";import"../Formula/SuggestionsMenu.js";import"../CommentCard/CommentCard.js";import"@material-ui/icons/AlternateEmail";import"../AttachFileButton/AttachFileButton.scss.js";import"../CommentInputNext/CommentInputNext.js";import"../UserMention/utils/index.js";import"react-s3-uploader/s3upload";import"../CommentComposer/CommentMetaLine.scss.js";import"@material-ui/icons/ArrowDropDown";import"@material-ui/icons/Search";import"../CommentComposer/ChatChannelSelector.scss.js";import"../CommentComposer/ShareToChatRow.scss.js";import"../CommentComposer/CommentComposer.scss.js";import"../AttachmentPreview/AttachmentPreview.js";import"../AttachmentPreview/AttachmentImage.js";import"../AttachmentPreview/AttachmentPreview.scss.js";import"../CommentPin/CommentPin.js";import"../FeedCard/FeedCard.js";import"../FeedItemCard/FeedItemCard.js";import"../NewCommentCursor/NewCommentCursor.js";import"../LinkedText/LinkedText.js";import"../FeedItem/feedItemTypes/AlertFeedItem.js";import"../FeedItem/feedItemTypes/PostFeedItem.js";import"../FeedItem/feedItemTypes/GeosteeringFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/DrillingDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/DocumentFeedItem.js";import"../FeedItem/feedItemTypes/DrillerMemoFeedItem.js";import"../FeedItem/feedItemTypes/NptFeedItem.js";import"../FeedItem/feedItemTypes/SurveyStationFeedItem/index.js";import"../FeedItem/feedItemTypes/LessonsLearnedFeedItem/index.js";import"../FeedItem/feedItemTypes/TracesMemoFeedItem.js";import"../FeedItem/feedItemTypes/DepthCommentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDocumentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionNptFeedItem.js";import"../FeedItem/feedItemTypes/StageOverviewFeedItem/index.js";import"../FeedItem/feedItemTypes/AppAnnotationFeedItem/index.js";import"../FeedItem/feedItemTypes/WellPlanFeedItem/index.js";import"../FeedItem/feedItemTypes/FluidReportFeedItem.js";import"../FeedItem/feedItemTypes/BhaFeedItem/BhaFeedItem.js";import"../FeedItem/feedItemTypes/DvDCommentFeedItem.js";import"../FeedItem/feedItemTypes/PCCommentFeedItem.js";import"../FeedItem/feedItemTypes/HookloadCommentFeedItem.js";import"../FeedItem/feedItemTypes/NptLessonsCommentFeedItem.js";import"../FeedItem/feedItemTypes/GenericDataCommentFeedItem.js";var A=function(r){var A=r.open,V=r.fileUrl,S=r.fileSize,v=r.fileName,F=r.webviewType,T=void 0===F?"google":F,g=r.onClose,D=t(!0),h=o(D,2),P=h[0],f=h[1],x=t(!1),b=o(x,2),y=b[0],B=b[1],k=s(null),E=s(null),L=j(),w=i((function(){return"office"===T?"https://view.officeapps.live.com/op/embed.aspx?src=".concat(window.encodeURIComponent(V)):"https://docs.google.com/viewer?url=".concat(encodeURIComponent(V),"&embedded=true")}),[V]),M=function(){E.current&&(E.current.src=w(),E.current.contentWindow.location.reload())},H=function(){k.current&&clearInterval(k.current),f(!1)};return n((function(){f(!0),B(!1);var e=S&&S>=1048576?S/1048576*1e4:1e4;return k&&A&&(clearInterval(k.current),k.current=setInterval(M,e)),function(){clearInterval(k.current)}}),[V,A]),u(m,{open:A,onClose:g,onContextMenu:function(e){return e.stopPropagation()},children:C("div",{className:L.cDocsViewer,children:[C("div",{className:L.cDocsViewerToolbar,children:[u(c,{children:v}),C("div",{children:[u(a,{size:"small",className:L.cDocsViewerToolbarIconButton,children:u("a",{download:!0,href:V,target:"_blank",rel:"noopener noreferrer",children:u(d,{fontSize:"small"})})}),u(a,{size:"small",onClick:g,className:L.cDocsViewerToolbarIconButton,children:u(l,{fontSize:"small"})})]})]}),P&&u("div",{className:L.cDocsViewerFrame,children:u(I,{white:!1})}),y?u("div",{className:L.cDocsViewerFrame,children:u(c,{variant:"body2",className:L.cDocsViewerFrameFailed,children:"Loading failed"})}):u("iframe",{className:p(L.cDocsViewerFrame,e({},L.cDocsViewerFrameHidden,P)),title:V,src:w(),onLoad:H,onError:function(){H(),B(!0)},ref:E})]})})};A.propTypes={open:r.bool.isRequired,fileUrl:r.string.isRequired,webviewType:r.oneOf(["google","office"]),fileName:r.string,fileSize:r.number,onClose:r.func.isRequired,classes:r.shape({}).isRequired};export{A as default};
|
|
1
|
+
import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{useState as t,createRef as s,useCallback as i,useEffect as n}from"react";import r from"prop-types";import p from"classnames";import{Modal as m,Typography as c,IconButton as a}from"@material-ui/core";import l from"@material-ui/icons/Close";import d from"@material-ui/icons/GetApp";import{useStyles as j}from"./styles.js";import"../DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider/IsInsideIsolatedDcAppProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/DcFullscreenElemsCoordinatorProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js";import"@babel/runtime/helpers/objectWithoutProperties";import"lodash";import"../Modal/CorvaModal.scss.js";import"@icon-park/react/es/all";import{jsx as u,jsxs as C}from"react/jsx-runtime";import"../../icons/IconParkProvider.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import"../../utils/mobileDetect.js";import"../IconButton/index.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/appPackages.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../constants/corvaCompanyId.js";import"../GradientManager/configuration/constants.js";import"uuid";import"../IconMenu/index.js";import"../StyledMenuItem/index.js";import"../AppIcon/AppIcon.js";import"../DevCenter/AppHeader/AppHeader.js";import"../DevCenter/AppSideBar/AppSideBar.js";import"../DevCenter/AppsDataProvider/AppsDataProvider.js";import"../DevCenter/AppContext.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"react-router-dom";import"query-string";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"../../utils/index.js";import"../DevCenter/DevCenterAppContainer/components/AppActions/AppActions.css.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/AppSettingsDialog.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/RemoveAppButton.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/SettingsAccordion.js";import"../DevCenter/DevCenterAppContainer/components/AnnotationsButton.js";import"../../componentsV2/Text/Text.js";import"../../componentsV2/Grid/Grid.js";import"../../componentsV2/Grid/Cell.js";import"../../componentsV2/Header/Header.scss.js";import"../../componentsV2/Button/Button.js";import"../../componentsV2/ButtonIcon/ButtonIcon.js";import"../../componentsV2/Tooltip/Tooltip.scss.js";import"../../componentsV2/Popover/Popover.js";import"../../componentsV2/PopoverPanel/PopoverPanel.js";import"../../componentsV2/Radio/Radio.js";import"../../componentsV2/RadioAndCheckboxGroup/RadioAndCheckboxGroup.scss.js";import"../../componentsV2/Checkbox/Checkbox.js";import"@babel/runtime/helpers/toConsumableArray";import"../../componentsV2/TextInput/TextInput.js";import"../../componentsV2/TextInputNext/TextInputNext.js";import"../../componentsV2/TextArea/TextArea.js";import"../../componentsV2/Label/Label.js";import"../../componentsV2/TextEndTruncated/TextEndTruncated.scss.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.scss.js";import"../../componentsV2/TextLink/TextLink.js";import"../../componentsV2/Chip/Chip.js";import"../../componentsV2/ChipAlert/ChipAlert.js";import"../../componentsV2/ChipIndicator/ChipIndicator.js";import"../../componentsV2/Avatar/Avatar.js";import"../../componentsV2/AvatarGroup/AvatarGroup.js";import"@material-ui/lab";import"../../componentsV2/ToggleButtons/ToggleButtons.scss.js";import"../../componentsV2/Paper/Paper.js";import"../../componentsV2/ModalWindow/ModalWindow.js";import"../../componentsV2/Modal/Modal.scss.js";import"../../componentsV2/Menu/Menu.js";import"../../componentsV2/utils.js";import"../../componentsV2/Hint/Hint.scss.js";import"../../componentsV2/Counter/Counter.js";import"../../componentsV2/BadgeBase/BadgeBase.scss.js";import"../../componentsV2/TemplatesControl/TemplatesControl.js";import"zustand";import"../../componentsV2/TemplatesControl/utils.js";import"../../componentsV2/TemplatesControl/icons/folder/index.js";import"../../componentsV2/TemplatesControl/Store/utils.js";import"../../componentsV2/TemplatesControl/types.js";import"../../clients/jsonApi/index.js";import"../../permissions/PermissionsContext.js";import"../../permissions/constants/index.js";import"../../permissions/withPermissionsHOC.js";import"../../permissions/ProvidePermissions.js";import"../../componentsV2/BadgeDot/BadgeDot.scss.js";import"../../componentsV2/LoaderLinear/LoaderLinear.scss.js";import"../../componentsV2/LoaderLogo/LoaderLogo.constants.js";import"../../componentsV2/LoaderLogo/LoaderLogo.scss.js";import"../../componentsV2/Switch/Switch.js";import"../../componentsV2/Tabs/Tabs.js";import"../../componentsV2/EmptyState/EmptyState.scss.js";import"../../componentsV2/FileIcon/FileIcon.js";import"../../componentsV2/Tag/Tag.js";import"react-dropzone";import"../../componentsV2/FilesDropzone/FilesDropzone.scss.js";import"../../componentsV2/FilesLoader/FilesLoader.scss.js";import"file-extension";import"image-extensions";import"video-extensions";import"../../componentsV2/FilesProcessor/FilesProcessor.scss.js";import"../../componentsV2/Skeleton/Skeleton.scss.js";import"../../utils/main.js";import"../../componentsV2/CopyToClipboard/CopyToClipboard.scss.js";import"../../componentsV2/Stepper/Step/Step.scss.js";import"../../componentsV2/Stepper/Stepper.scss.js";import"../../componentsV2/ButtonLive/ButtonLive.js";import"../../componentsV2/ButtonText/ButtonText.js";import"../../componentsV2/IndicatorLive/IndicatorLive.js";import"../../componentsV2/Accordion/Accordion.scss.js";import"../../componentsV2/Breadcrumbs/Breadcrumbs.scss.js";import"../../componentsV2/BadgeComment/BadgeComment.js";import"../../componentsV2/AppContainer/AppContainer.js";import"../../componentsV2/AppContainer/AppContainer.constants.js";import"../../componentsV2/AppFooter/AppFooter.js";import"immutable";import"../../componentsV2/AppCommonsProvider/AppCommonsContext.js";import"../../componentsV2/AppHeader/AppHeader.constants.js";import"../../componentsV2/AppHeader/AppBadge/AppBadge.scss.js";import"../../componentsV2/AppHeader/AppAssets/utils.js";import"../../componentsV2/AppHeader/AppAssets/AppAssets.scss.js";import"../PadModeSelect/PadModeSelect.js";import"../../componentsV2/AppHeader/PadMode/PadMode.scss.js";import"../../constants/streamSourceType.js";import"../../componentsV2/PadModeSelect/PadModeSelect.js";import"../../componentsV2/PadModeSelect/PadModeSelect.constants.js";import"../../componentsV2/AppCommonsProvider/AppCommonsProvider.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js";import"../../componentsV2/UniversalLink/UniversalLink.scss.js";import"../../componentsV2/AppHeader/V3/AssetChips/AssetChips.scss.js";import"moment";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.constants.js";import"../../componentsV2/AppFooter/DqPopover/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppDqPopover/DqAlertTooltip/DqAlertTooltip.scss.js";import"../../componentsV2/AppDqPopover/DqAlert/DqAlert.scss.js";import"../../componentsV2/AppDqPopover/DqAsset/DqAsset.scss.js";import"../../componentsV2/AppDqPopover/AppDqPopover.scss.js";import"../../utils/getSingleAsset.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorChip/AssetSelectorChip.js";import"../../componentsV2/AppHeader/V3/AssetSelector/constants.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/AssetSelectorSelect.scss.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/loadAssets.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelector.scss.js";import"../../clients/subscriptions/constants.js";import"querystring";import"uuid/v1";import"../../clients/subscriptions.v1.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"jsona";import"../../utils/env.js";import"../StatusBadge/constants.js";import"lodash/set";import"lodash/get";import"lodash/unset";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import"lodash/isEmpty";import"lodash/sortBy";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js";import"../../componentsV2/AppSettings/AppSettingsPinningContext.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.constants.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.scss.js";import"../../componentsV2/AppHeader/V3/constants.scss.js";import"@babel/runtime/helpers/typeof";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.js";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.constants.js";import"../../componentsV2/AppSettings/AppSettings.js";import"../../componentsV2/AppSettings/AppSettings.constants.js";import"../../componentsV2/AppSizeProvider/AppSizeProvider.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.constants.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.scss.js";import"../../componentsV2/AppHeader/V3/AppHeaderV3.scss.js";import"../../componentsV2/AppHeader/AppHeader.scss.js";import"../../componentsV2/OffsetWellsButton/OffsetWellsButton.js";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtreme.scss.js";import"highcharts";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtremeDragTracker.js";import"../../componentsV2/Autocomplete/Autocomplete.js";import"../../componentsV2/Select/Select.js";import"../../componentsV2/AppSettingsDivider/AppSettingsDivider.scss.js";import"../../componentsV2/WellArchivedMessage/WellArchivedMessage.js";import"../../componentsV2/DatePicker/DatePicker.js";import"../../componentsV2/DragHandle/DragHandle.js";import"../../componentsV2/CompletionsOffsetWellPicker/CompletionsOffsetWellPicker.js";import"../../componentsV2/Slider/constants.js";import"../../componentsV2/Slider/components/SliderThumb.js";import"../../componentsV2/Slider/Slider.scss.js";import"../../componentsV2/SliderAdvanced/SliderAdvanced.js";import"react-color";import"../../componentsV2/ColorPicker/Swatches/Swatches.scss.js";import"../../componentsV2/ColorPicker/OpacityDragtracker/OpacityDragTracker.scss.js";import"../../componentsV2/ColorPicker/ColorPicker.scss.js";import"../../componentsV2/ChartHelper/ChartHelper.scss.js";import"../../componentsV2/Hotkey/Hotkey.js";import"@tanstack/react-query";import"../../componentsV2/InterventionEventSelector/useInterventionUnitEvents.js";import"../../componentsV2/InterventionEventSelector/InterventionEventSelector.scss.js";import"@material-ui/icons";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.scss.js";import"../DevCenter/DevCenterAppContainer/components/FullscreenButton/FullscreenButton.js";import"../Icons/AnnotationIcon.js";import"../HelpCenter/HelpCenterIcon.js";import"../DevCenter/DevCenterAppContainer/components/AppInfoMessage/AppInfoMessage.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/components/ChooseAssetButton.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/DevCenterAppView.scss.js";import"../ErrorBoundary/ErrorBoundary.js";import"../ErrorBoundary/DevCenterAppErrorView/DevCenterAppErrorView.js";import"../Annotations/components/AnnotationsList/index.js";import"../Annotations/components/LastAnnotation/index.js";import"../Annotations/AnnotationsContext.js";import"../DevCenter/DevCenterAppContainer/components/RestoreAppSizeButton/index.js";import"../DevCenter/DevCenterAppContainer/DevCenterAppContainer.scss.js";import"../Toaster/Toaster.js";import"../DevCenter/NavigationBar/NavigationBar.js";import"../DevCenter/SideBar/SideBar.js";import"../DevCenter/AppSettingsPopover/AppSettingsPopover.js";import"../DevCenter/AppFilterPanelLayout/AppFilterPanelLayout.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js";import"../AssetEditor/index.js";import"../AssetEditorV2/index.js";import"../AppVersionsSelect/AppVersionsSelect.js";import I from"../LoadingIndicator/LoadingIndicator.js";import"../Typography.js";import"../RealTimeValuesSidebar/RealTimeSidebar.js";import"../CollapsableSidebar.js";import"../DateTimePicker/index.js";import"../DatePicker/index.js";import"../SlateFormattedText/SlateFormattedText.js";import"../SlateFormattedText/RenderElements.js";import"slate";import"../EmptyState/EmptyState.js";import"../ParameterCharts/ParameterCharts.js";import"../ParameterCharts/AddEditTrack.js";import"../ChartActionsList/ChartActionsList.js";import"../CopyToClipboard/CopyToClipboard.js";import"../AssetEditor/AssetEditorAutocomplete.js";import"../AssetEditor/SingleAssetEditor.js";import"../SettingEditors/ColorEditor/style.css.js";import"../SettingEditors/DropdownEditor/index.js";import"../SwitchControl/index.js";import"../ColorPicker/ColorPicker.js";import"../Chart/components/ChartButton.js";import"../Chart/components/ChartButtons.js";import"../Chart/components/ChartWrapper.js";import"../Chart/components/AxisDropdown.js";import"../Chart/components/ChartSelect.js";import"../Chart/ChartWrapperContext.js";import"../Chart/effects/useChartModifier.js";import"../Chart/components/buttons/HideAxesButton.js";import"../Chart/components/buttons/ChartTypeButton.js";import"../ColorPicker/PaletteChromePicker/PaletteChromePicker.js";import"../TruncatedText/index.js";import"../MiddleTruncatedText/MiddleTruncatedText.js";import"../RangeSlider/constants.js";import"../RangeSlider/Input.css.js";import"../RangeSlider/RangeSlider.css.js";import"../AdvancedSlider/AdvancedSlider.js";import"../Breadcrumbs/index.js";import"../VirtualizedTable/index.js";import"../EmptyView/EmptyView.js";import"../EmptyView/EmptyAppView/EmptyAppView.js";import"../Button/components/Button/index.js";import"moment-timezone";import"../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js";import"../Button/components/LiveButton/styles.js";import"../ContextMenuItem/index.js";import"../FolderMenuItem/index.js";import"../EditableItem/EditableItem/index.js";import"../EditableItem/EditableItemWithBadge/index.js";import"../Checkbox/index.js";import"../FolderMenuItemWithLinks/index.js";import"../TextField/index.js";import"../Chip/index.js";import"../Counter/index.js";import"../AnchorsList/AnchorsList.js";import"../Select/index.js";import"../Select/SelectFilterBy.js";import"../CustomSelect/index.js";import"../Tabs/Tabs.js";import"../Tabs/Tab.js";import"../ResizableTable/ResizableTable.js";import"../GradientPicker/GradientPicker.js";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"../GradientManager/GradientPreview/GradientPreview.js";import"../GradientManager/GradientSelect.scss.js";import"../GradientManager/GradientManager.styles.js";import"../Drillstring/BHASchematic.js";import"../Drillstring/BHATable/index.js";import"../Drillstring/BHAComponentIcon.js";import"../Drillstring/BHAComponentDetail/index.js";import"../Drillstring/BHATileIcon.js";import"../Drillstring/BHATile/BHATile.js";import"../Drillstring/BHAList/BHAList.js";import"../Drillstring/BHAComponentsTable/BHAComponentsTable.js";import"../Casing/CasingTable/index.js";import"../Casing/CasingComponentIcon.js";import"../Casing/CasingTileIcon.js";import"../Casing/CasingTableV2/CasingTableV2.js";import"../Casing/CasingTile/CasingTile.js";import"../DisabledSettingsMessage/DisabledSettingsMessage.js";import"../WellSummary/WellSummaryItemLabel.js";import"../WellSummary/WellSummaryItemTitle.js";import"../WellSummary/WellSummaryItemValue.js";import"../WellSummary/ActivitySummaryChart.js";import"../WellSummary/FracWirelineTimeChart.js";import"../BICOffsetPickerDialog/index.js";import"../OffsetWellButton/OffsetWellButton.js";import"../OffsetWellPickerV2/OffsetWellPickerDialog.js";import"../OffsetWellPickerV3/index.js";import"../OffsetWellChips/Chip.js";import"../OffsetWellChips/ChipsContainer.js";import"../OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/OffsetWellPickerV5WithStore.js";import"../OffsetWellMap/OffsetWellMap.js";import"@material-ui/core/Snackbar";import"../Notifications/Toast.js";import"../Notifications/Notifications.scss.js";import"../ConfirmationDialog.js";import"../TextLink/index.js";import"../Avatar/index.js";import"../Template/TemplatePopover/index.js";import"../Template/TemplateSharingDialog/index.js";import"../MenuItem/index.js";import"../MiddleTruncate/MiddleTruncate.js";import"../PinnableFilters/PinnableFilters.js";import"../HeaderLayout/HeaderLayout.js";import"../PadOffsetsPicker/PadOffsetsPicker.js";import"../PadOffsetsPicker/OffsetAssetChip.js";import"../PadOffsetsPicker/OffsetAssetsListExpander.js";import"../PadOffsetsPicker/StagesSelector.js";import"../PadOffsetsPickerV2/PadOffsetsPickerV2.js";import"../Table/TableToolbar/TableToolbar.js";import"../Table/TableContainer/TableContainer.js";import"../Table/TableCell/TableCell.js";import"../Table/TablePagination/TablePagination.js";import"../Table/TablePaginationActions/TablePaginationActions.js";import"../Tooltip/ScrollableTooltip.js";import"../PriceInput/PriceInput.js";import"../LabelsCounter/LabelsCounter.js";import"../Stepper/Stepper.js";import"../Stepper/Step/Step.js";import"../Stepper/StepsWrapper.js";import"../Comment/CommentIcon/index.js";import"../FilesLoader/FilesLoader.js";import"../../componentsV2/FileIcon/icons/ArchiveFileIcon.js";import"../../componentsV2/FileIcon/icons/CSVFileIcon.js";import"../../componentsV2/FileIcon/icons/DocFileIcon.js";import"../../componentsV2/FileIcon/icons/EDMFileIcon.js";import"../../componentsV2/FileIcon/icons/ExcelFileIcon.js";import"../../componentsV2/FileIcon/icons/ImageFileIcon.js";import"../../componentsV2/FileIcon/icons/JsonFileIcon.js";import"../../componentsV2/FileIcon/icons/LasFileIcon.js";import"../../componentsV2/FileIcon/icons/OtherFileIcon.js";import"../../componentsV2/FileIcon/icons/PdfFileIcon.js";import"../../componentsV2/FileIcon/icons/PowerPointFileIcon.js";import"../../componentsV2/FileIcon/icons/TxtFileIcon.js";import"../../componentsV2/FileIcon/icons/UnknownFileIcon.js";import"../../componentsV2/FileIcon/icons/VideoFileIcon.js";import"../../componentsV2/FileIcon/icons/XmlFileIcon.js";import"../SearchInput/index.js";import"../FeedItem/FeedItem.js";import"../FeedItem/FeedItemEditProvider/FeedItemEditProvider.js";import"../PostInput/PostInput.js";import"../KeyboardDateTimePicker.js";import"../AddComment/Popover.js";import"../AddComment/Popup.js";import"../StageDesignVActual/ComparisonBar/ComparisonBar.js";import"../StageDesignVActual/ElementsComparison/ElementsComparison.js";import"../StageDesignVActual/ComparisonHeader.js";import"../StageDesignVActual/ComparisonRow.js";import"../EmbeddedApp/DevCenterEmbeddedApp.js";import"../EmbeddedApp/EmbeddedApp.js";import"../Autocomplete/Autocomplete.js";import"../ColorPickerPalette/ColorPickerPalette.js";import"../Search/Search.js";import"../Search/components/Listbox.js";import"../Search/components/Paper.js";import"../Search/components/RecentSearches.js";import"../Search/components/Groups.js";import"../Search/components/SelectAllListItem.js";import"../StatusBadge/index.js";import"../Attachment/index.js";import"../EmojiIconButton.js";import"../FileUploadIconButton.js";import"../FilePreview/index.js";import"../FailedFileUploading.js";import"../UserMention/index.js";import"../CommentsInfo/index.js";import"../CommentInput/index.js";import"../Comment/index.js";import"../CommentLoader.js";import"../AssetNameLabel/AssetStatusBadge.js";import"../AssetEditorV2/components/PrimaryAssetSelect.js";import"../AssetEditorV2/components/SecondaryAssetSelect.js";import"../AssetEditorV2/components/SelectItem.js";import"../AssetEditorV2/components/MultipleAssetsToggle.js";import"../AssetEditorV2/components/PrimaryAssetSelectV2.js";import"../EChartsWrapper/EChartsWrapper.js";import"../AssetsMultipleSelector/AssetsMultipleSelector.js";import"../GoogleDocsViewer/index.js";import"../NewDocumentViewer/effects/useFileContent.js";import"../NewDocumentViewer/styles.js";import"../FilesLoaderV2/styles.js";import"../FilesDropzone/styles.js";import"../FilesProcessor/styles.js";import"../Hint/styles.js";import"@babel/runtime/helpers/taggedTemplateLiteral";import"fparser";import"../Formula/useFormulaStyles.js";import"../Formula/RootXIcon.js";import"../Formula/FormulaTextEditor.js";import"../Formula/CloseSuggestion.js";import"../Formula/SuggestionsMenu.js";import"../CommentCard/CommentCard.js";import"@material-ui/icons/AlternateEmail";import"../AttachFileButton/AttachFileButton.scss.js";import"../CommentInputNext/CommentInputNext.js";import"../UserMention/utils/index.js";import"react-s3-uploader/s3upload";import"../CommentComposer/CommentMetaLine.scss.js";import"../CommentComposer/ChatChannelSelector.scss.js";import"../CommentComposer/ShareToChatRow.scss.js";import"../CommentComposer/CommentComposer.scss.js";import"../AttachmentPreview/AttachmentPreview.js";import"../AttachmentPreview/AttachmentImage.js";import"../AttachmentPreview/AttachmentPreview.scss.js";import"../CommentPin/CommentPin.js";import"../FeedCard/FeedCard.js";import"../FeedItemCard/FeedItemCard.js";import"../NewCommentCursor/NewCommentCursor.js";import"../LinkedText/LinkedText.js";import"../FeedItem/feedItemTypes/AlertFeedItem.js";import"../FeedItem/feedItemTypes/PostFeedItem.js";import"../FeedItem/feedItemTypes/GeosteeringFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/DrillingDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/DocumentFeedItem.js";import"../FeedItem/feedItemTypes/DrillerMemoFeedItem.js";import"../FeedItem/feedItemTypes/NptFeedItem.js";import"../FeedItem/feedItemTypes/SurveyStationFeedItem/index.js";import"../FeedItem/feedItemTypes/LessonsLearnedFeedItem/index.js";import"../FeedItem/feedItemTypes/TracesMemoFeedItem.js";import"../FeedItem/feedItemTypes/DepthCommentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDocumentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionNptFeedItem.js";import"../FeedItem/feedItemTypes/StageOverviewFeedItem/index.js";import"../FeedItem/feedItemTypes/AppAnnotationFeedItem/index.js";import"../FeedItem/feedItemTypes/WellPlanFeedItem/index.js";import"../FeedItem/feedItemTypes/FluidReportFeedItem.js";import"../FeedItem/feedItemTypes/BhaFeedItem/BhaFeedItem.js";import"../FeedItem/feedItemTypes/DvDCommentFeedItem.js";import"../FeedItem/feedItemTypes/PCCommentFeedItem.js";import"../FeedItem/feedItemTypes/HookloadCommentFeedItem.js";import"../FeedItem/feedItemTypes/NptLessonsCommentFeedItem.js";import"../FeedItem/feedItemTypes/GenericDataCommentFeedItem.js";var A=function(r){var A=r.open,V=r.fileUrl,S=r.fileSize,v=r.fileName,F=r.webviewType,T=void 0===F?"google":F,g=r.onClose,h=t(!0),D=o(h,2),P=D[0],f=D[1],x=t(!1),b=o(x,2),y=b[0],B=b[1],k=s(null),E=s(null),L=j(),w=i((function(){return"office"===T?"https://view.officeapps.live.com/op/embed.aspx?src=".concat(window.encodeURIComponent(V)):"https://docs.google.com/viewer?url=".concat(encodeURIComponent(V),"&embedded=true")}),[V]),M=function(){E.current&&(E.current.src=w(),E.current.contentWindow.location.reload())},H=function(){k.current&&clearInterval(k.current),f(!1)};return n((function(){f(!0),B(!1);var e=S&&S>=1048576?S/1048576*1e4:1e4;return k&&A&&(clearInterval(k.current),k.current=setInterval(M,e)),function(){clearInterval(k.current)}}),[V,A]),u(m,{open:A,onClose:g,onContextMenu:function(e){return e.stopPropagation()},children:C("div",{className:L.cDocsViewer,children:[C("div",{className:L.cDocsViewerToolbar,children:[u(c,{children:v}),C("div",{children:[u(a,{size:"small",className:L.cDocsViewerToolbarIconButton,children:u("a",{download:!0,href:V,target:"_blank",rel:"noopener noreferrer",children:u(d,{fontSize:"small"})})}),u(a,{size:"small",onClick:g,className:L.cDocsViewerToolbarIconButton,children:u(l,{fontSize:"small"})})]})]}),P&&u("div",{className:L.cDocsViewerFrame,children:u(I,{white:!1})}),y?u("div",{className:L.cDocsViewerFrame,children:u(c,{variant:"body2",className:L.cDocsViewerFrameFailed,children:"Loading failed"})}):u("iframe",{className:p(L.cDocsViewerFrame,e({},L.cDocsViewerFrameHidden,P)),title:V,src:w(),onLoad:H,onError:function(){H(),B(!0)},ref:E})]})})};A.propTypes={open:r.bool.isRequired,fileUrl:r.string.isRequired,webviewType:r.oneOf(["google","office"]),fileName:r.string,fileSize:r.number,onClose:r.func.isRequired,classes:r.shape({}).isRequired};export{A as default};
|
|
2
2
|
//# sourceMappingURL=DocumentViewer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentViewer.js","sources":["../../../src/components/DocumentViewer/DocumentViewer.js"],"sourcesContent":["import { createRef, useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { Typography, Modal, IconButton } from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport GetAppIcon from '@material-ui/icons/GetApp';\n\nimport { useStyles } from './styles.js';\n\nimport { LoadingIndicator } from '~/components';\n\nconst REQUEST_TIMEOUT = 10000;\nconst BYTES_IN_MEGABYTE = 1048576;\n\nconst DocumentViewer = ({ open, fileUrl, fileSize, fileName, webviewType = 'google', onClose }) => {\n const [isLoading, setIsLoading] = useState(true);\n const [isLoadingFailed, setIsLoadingFailed] = useState(false);\n const timeoutRef = createRef(null);\n const iframeRef = createRef(null);\n const styles = useStyles();\n\n const getIframeLink = useCallback(() => {\n return webviewType === 'office'\n ? `https://view.officeapps.live.com/op/embed.aspx?src=${window.encodeURIComponent(fileUrl)}`\n : `https://docs.google.com/viewer?url=${encodeURIComponent(fileUrl)}&embedded=true`;\n }, [fileUrl]);\n\n const reloadFrame = () => {\n if (iframeRef.current) {\n iframeRef.current.src = getIframeLink();\n iframeRef.current.contentWindow.location.reload();\n }\n };\n\n const handleFrameLoad = () => {\n if (timeoutRef.current) {\n clearInterval(timeoutRef.current);\n }\n setIsLoading(false);\n };\n\n const handleFrameError = () => {\n handleFrameLoad();\n setIsLoadingFailed(true);\n };\n\n useEffect(() => {\n setIsLoading(true);\n setIsLoadingFailed(false);\n const timeOut =\n fileSize && fileSize >= BYTES_IN_MEGABYTE\n ? (fileSize / BYTES_IN_MEGABYTE) * REQUEST_TIMEOUT\n : REQUEST_TIMEOUT;\n\n if (timeoutRef && open) {\n clearInterval(timeoutRef.current);\n timeoutRef.current = setInterval(reloadFrame, timeOut);\n }\n\n return () => {\n clearInterval(timeoutRef.current);\n };\n }, [fileUrl, open]);\n\n return (\n <Modal open={open} onClose={onClose} onContextMenu={e => e.stopPropagation()}>\n <div className={styles.cDocsViewer}>\n <div className={styles.cDocsViewerToolbar}>\n <Typography>{fileName}</Typography>\n <div>\n <IconButton size=\"small\" className={styles.cDocsViewerToolbarIconButton}>\n <a download href={fileUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <GetAppIcon fontSize=\"small\" />\n </a>\n </IconButton>\n <IconButton\n size=\"small\"\n onClick={onClose}\n className={styles.cDocsViewerToolbarIconButton}\n >\n <CloseIcon fontSize=\"small\" />\n </IconButton>\n </div>\n </div>\n\n {isLoading && (\n <div className={styles.cDocsViewerFrame}>\n <LoadingIndicator white={false} />\n </div>\n )}\n {isLoadingFailed ? (\n <div className={styles.cDocsViewerFrame}>\n <Typography variant=\"body2\" className={styles.cDocsViewerFrameFailed}>\n Loading failed\n </Typography>\n </div>\n ) : (\n <iframe\n className={classNames(styles.cDocsViewerFrame, {\n [styles.cDocsViewerFrameHidden]: isLoading,\n })}\n title={fileUrl}\n src={getIframeLink()}\n onLoad={handleFrameLoad}\n onError={handleFrameError}\n ref={iframeRef}\n />\n )}\n </div>\n </Modal>\n );\n};\n\nDocumentViewer.propTypes = {\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string.isRequired,\n webviewType: PropTypes.oneOf(['google', 'office']),\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n onClose: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n};\n\nexport default DocumentViewer;\n"],"names":["DocumentViewer","_ref","open","fileUrl","fileSize","fileName","_ref$webviewType","webviewType","onClose","useState","_useState2","_slicedToArray","_useState","isLoading","setIsLoading","_useState4","_useState3","isLoadingFailed","setIsLoadingFailed","timeoutRef","createRef","iframeRef","styles","useStyles","getIframeLink","useCallback","concat","window","encodeURIComponent","reloadFrame","current","src","contentWindow","location","reload","handleFrameLoad","clearInterval","useEffect","timeOut","setInterval","_jsx","Modal","onContextMenu","e","stopPropagation","children","_jsxs","className","cDocsViewer","cDocsViewerToolbar","Typography","IconButton","size","cDocsViewerToolbarIconButton","download","href","target","rel","GetAppIcon","fontSize","onClick","CloseIcon","cDocsViewerFrame","LoadingIndicator","white","variant","cDocsViewerFrameFailed","classNames","cDocsViewerFrameHidden","title","onLoad","onError","ref","propTypes","PropTypes","bool","isRequired","string","oneOf","number","func","classes","shape"],"mappings":"
|
|
1
|
+
{"version":3,"file":"DocumentViewer.js","sources":["../../../src/components/DocumentViewer/DocumentViewer.js"],"sourcesContent":["import { createRef, useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { Typography, Modal, IconButton } from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport GetAppIcon from '@material-ui/icons/GetApp';\n\nimport { useStyles } from './styles.js';\n\nimport { LoadingIndicator } from '~/components';\n\nconst REQUEST_TIMEOUT = 10000;\nconst BYTES_IN_MEGABYTE = 1048576;\n\nconst DocumentViewer = ({ open, fileUrl, fileSize, fileName, webviewType = 'google', onClose }) => {\n const [isLoading, setIsLoading] = useState(true);\n const [isLoadingFailed, setIsLoadingFailed] = useState(false);\n const timeoutRef = createRef(null);\n const iframeRef = createRef(null);\n const styles = useStyles();\n\n const getIframeLink = useCallback(() => {\n return webviewType === 'office'\n ? `https://view.officeapps.live.com/op/embed.aspx?src=${window.encodeURIComponent(fileUrl)}`\n : `https://docs.google.com/viewer?url=${encodeURIComponent(fileUrl)}&embedded=true`;\n }, [fileUrl]);\n\n const reloadFrame = () => {\n if (iframeRef.current) {\n iframeRef.current.src = getIframeLink();\n iframeRef.current.contentWindow.location.reload();\n }\n };\n\n const handleFrameLoad = () => {\n if (timeoutRef.current) {\n clearInterval(timeoutRef.current);\n }\n setIsLoading(false);\n };\n\n const handleFrameError = () => {\n handleFrameLoad();\n setIsLoadingFailed(true);\n };\n\n useEffect(() => {\n setIsLoading(true);\n setIsLoadingFailed(false);\n const timeOut =\n fileSize && fileSize >= BYTES_IN_MEGABYTE\n ? (fileSize / BYTES_IN_MEGABYTE) * REQUEST_TIMEOUT\n : REQUEST_TIMEOUT;\n\n if (timeoutRef && open) {\n clearInterval(timeoutRef.current);\n timeoutRef.current = setInterval(reloadFrame, timeOut);\n }\n\n return () => {\n clearInterval(timeoutRef.current);\n };\n }, [fileUrl, open]);\n\n return (\n <Modal open={open} onClose={onClose} onContextMenu={e => e.stopPropagation()}>\n <div className={styles.cDocsViewer}>\n <div className={styles.cDocsViewerToolbar}>\n <Typography>{fileName}</Typography>\n <div>\n <IconButton size=\"small\" className={styles.cDocsViewerToolbarIconButton}>\n <a download href={fileUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <GetAppIcon fontSize=\"small\" />\n </a>\n </IconButton>\n <IconButton\n size=\"small\"\n onClick={onClose}\n className={styles.cDocsViewerToolbarIconButton}\n >\n <CloseIcon fontSize=\"small\" />\n </IconButton>\n </div>\n </div>\n\n {isLoading && (\n <div className={styles.cDocsViewerFrame}>\n <LoadingIndicator white={false} />\n </div>\n )}\n {isLoadingFailed ? (\n <div className={styles.cDocsViewerFrame}>\n <Typography variant=\"body2\" className={styles.cDocsViewerFrameFailed}>\n Loading failed\n </Typography>\n </div>\n ) : (\n <iframe\n className={classNames(styles.cDocsViewerFrame, {\n [styles.cDocsViewerFrameHidden]: isLoading,\n })}\n title={fileUrl}\n src={getIframeLink()}\n onLoad={handleFrameLoad}\n onError={handleFrameError}\n ref={iframeRef}\n />\n )}\n </div>\n </Modal>\n );\n};\n\nDocumentViewer.propTypes = {\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string.isRequired,\n webviewType: PropTypes.oneOf(['google', 'office']),\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n onClose: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n};\n\nexport default DocumentViewer;\n"],"names":["DocumentViewer","_ref","open","fileUrl","fileSize","fileName","_ref$webviewType","webviewType","onClose","useState","_useState2","_slicedToArray","_useState","isLoading","setIsLoading","_useState4","_useState3","isLoadingFailed","setIsLoadingFailed","timeoutRef","createRef","iframeRef","styles","useStyles","getIframeLink","useCallback","concat","window","encodeURIComponent","reloadFrame","current","src","contentWindow","location","reload","handleFrameLoad","clearInterval","useEffect","timeOut","setInterval","_jsx","Modal","onContextMenu","e","stopPropagation","children","_jsxs","className","cDocsViewer","cDocsViewerToolbar","Typography","IconButton","size","cDocsViewerToolbarIconButton","download","href","target","rel","GetAppIcon","fontSize","onClick","CloseIcon","cDocsViewerFrame","LoadingIndicator","white","variant","cDocsViewerFrameFailed","classNames","cDocsViewerFrameHidden","title","onLoad","onError","ref","propTypes","PropTypes","bool","isRequired","string","oneOf","number","func","classes","shape"],"mappings":"is1BAWA,IAGMA,EAAiB,SAA4EC,GAAA,IAAzEC,IAAAA,KAAMC,IAAAA,QAASC,IAAAA,SAAUC,IAAAA,SAAQC,EAAAL,EAAEM,YAAAA,aAAc,SAAQD,EAAEE,IAAAA,QACjDC,EAAAA,GAAS,GAAKC,EAAAC,EAAAC,EAAA,GAAzCC,EAASH,EAAA,GAAEI,EAAYJ,EAAA,GACgBD,EAAAA,GAAS,GAAMM,EAAAJ,EAAAK,EAAA,GAAtDC,EAAeF,EAAA,GAAEG,EAAkBH,EAAA,GACpCI,EAAaC,EAAU,MACvBC,EAAYD,EAAU,MACtBE,EAASC,IAETC,EAAgBC,GAAY,WAChC,MAAuB,WAAhBlB,EAAwB,sDAAAmB,OAC2BC,OAAOC,mBAAmBzB,IAC1CyB,sCAAAA,OAAAA,mBAAmBzB,GAAwB,iBACvF,GAAG,CAACA,IAEE0B,EAAc,WACdR,EAAUS,UACZT,EAAUS,QAAQC,IAAMP,IACxBH,EAAUS,QAAQE,cAAcC,SAASC,WAIvCC,EAAkB,WAClBhB,EAAWW,SACbM,cAAcjB,EAAWW,SAE3BhB,GAAa,IA0Bf,OAlBAuB,GAAU,WACRvB,GAAa,GACbI,GAAmB,GACnB,IAAMoB,E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