@outmarket-ai/react-sdk 0.1.0-alpha.43 → 0.1.0-alpha.44

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.
Files changed (357) hide show
  1. package/dist/{AddNoteDialog-BbX87r1H.js → AddNoteDialog-Rscj7ywA.js} +1 -1
  2. package/dist/{AlertDialog-BuNk_E8L.js → AlertDialog-Ck74fY_i.js} +1 -1
  3. package/dist/{ApproveWorkflowsList-Bv3s3hCc.js → ApproveWorkflowsList-BBNYqKpI.js} +1 -1
  4. package/dist/{BORLetterEditor-CuyM4c7H.js → BORLetterEditor-C2LqJr3D.js} +1 -1
  5. package/dist/{BillDetailModal-xAkRqp38.js → BillDetailModal-CuUK6nzN.js} +1 -1
  6. package/dist/{CoiIssueHolderModal-Dz8acf19.js → CoiIssueHolderModal-Dbnq42Eu.js} +1 -1
  7. package/dist/{ConfirmationDialog-CzL4BI_c.js → ConfirmationDialog-B4AYtu2J.js} +1 -1
  8. package/dist/{DeletePromptDialog-SzAG-Ur6.js → DeletePromptDialog-fng618F8.js} +1 -1
  9. package/dist/{EmailFormatSelectionDialog-4DtnDark.js → EmailFormatSelectionDialog-DGhQ-PFn.js} +1 -1
  10. package/dist/{ExcelExportPreviewDialog-DEtLON34.js → ExcelExportPreviewDialog-BXBEArrD.js} +1 -1
  11. package/dist/{ExplainPanel-4UPkAy-0.js → ExplainPanel-BoHpfWbO.js} +1 -1
  12. package/dist/{ExportDialog-BuZxEK2H.js → ExportDialog-C30TC7tR.js} +1 -1
  13. package/dist/{ExportToAmsDialog-DDXU07h5.js → ExportToAmsDialog-Qb3IvQLI.js} +1 -1
  14. package/dist/{ExportToDriveDialog-CYULj31Q.js → ExportToDriveDialog-BR8ccBAm.js} +1 -1
  15. package/dist/{FeedbackTool-C3pyuwN0.js → FeedbackTool-BRLzVE1v.js} +1 -1
  16. package/dist/{LayerDetailModal-BunzHHjG.js → LayerDetailModal-DIeS9rzn.js} +1 -1
  17. package/dist/{LogoEditor-BFAp0E-S.js → LogoEditor-BqVYEHx-.js} +1 -1
  18. package/dist/{MarkdownExportPreviewDialog-BH9w6owT.js → MarkdownExportPreviewDialog-PsbyVK7k.js} +1 -1
  19. package/dist/{NotificationDrawer-Nkxs3CVQ.js → NotificationDrawer-ClFQb63Q.js} +1 -1
  20. package/dist/{PhoneNumbersDisplay-BSZ-N4kS.js → PhoneNumbersDisplay-CClGxi77.js} +1 -1
  21. package/dist/{PlanSelector-G8WdVimh.js → PlanSelector-DPkd9ovm.js} +1 -1
  22. package/dist/{PlanSettingsModal--Zf6s4qx.js → PlanSettingsModal-BiE6IndG.js} +1 -1
  23. package/dist/{PlanWizardModal-C7g6mQlm.js → PlanWizardModal-D2T9m4oI.js} +1 -1
  24. package/dist/{RenameAssetDialog-B-E9YwOl.js → RenameAssetDialog-DyTr1q9l.js} +1 -1
  25. package/dist/{SaveBlockDialog-Dr1LJLhe.js → SaveBlockDialog-ChwTCWr4.js} +1 -1
  26. package/dist/{SaveOutlineDialog-DJlaRv38.js → SaveOutlineDialog-BBVesswr.js} +1 -1
  27. package/dist/{SavePromptDialog-DjMfQFXl.js → SavePromptDialog-CmEVLt1d.js} +1 -1
  28. package/dist/{ShareResourceDialog-DWpW6mjP.js → ShareResourceDialog-96Frvf7Y.js} +1 -1
  29. package/dist/{TermsNoticeModal-BtLXT42u.js → TermsNoticeModal-BCrp_mmB.js} +1 -1
  30. package/dist/{TowerAlertModal-gaEb5AOE.js → TowerAlertModal-D0xn61mD.js} +1 -1
  31. package/dist/{TowerSummaryModal-CwMvfzIx.js → TowerSummaryModal-BRXZTZG2.js} +1 -1
  32. package/dist/{VaultSettingsDialog-CLuoybBr.js → VaultSettingsDialog-CzmfRoYw.js} +1 -1
  33. package/dist/{ViewNoteDialog-DeYjlXJf.js → ViewNoteDialog-BE0P1gJZ.js} +1 -1
  34. package/dist/{WhatsNewProvider-h3HyAeqj.js → WhatsNewProvider-DWvFlY6f.js} +1 -1
  35. package/dist/{WidgetRawDataView-DCO_9lIQ.js → WidgetRawDataView-BhBH1MRV.js} +1 -1
  36. package/dist/{abap-Du5t04de.js → abap-Bpa95KhE.js} +1 -1
  37. package/dist/{abnf-Ay9Q9iTE.js → abnf-B2qSvJRy.js} +1 -1
  38. package/dist/{actionscript-Bc-Xx-_h.js → actionscript-yWjI6SzD.js} +1 -1
  39. package/dist/{activityLog-yFMk-sOT.js → activityLog-Cm65MpqN.js} +1 -1
  40. package/dist/{ada-DzubuqhB.js → ada-B0hIQwco.js} +1 -1
  41. package/dist/{agda-BDh91oLL.js → agda-DQVz7FOY.js} +1 -1
  42. package/dist/{al-DK26Scgb.js → al-Bma_HYAy.js} +1 -1
  43. package/dist/{antlr4-BkOJ9WgE.js → antlr4-D3vn8H33.js} +1 -1
  44. package/dist/{apacheconf-DL41Hbx6.js → apacheconf-kZIhI_Rh.js} +1 -1
  45. package/dist/{apex-Dj3yvlx8.js → apex-DubT7IP7.js} +1 -1
  46. package/dist/{apl-BACM7FMP.js → apl-Dfr9elW3.js} +1 -1
  47. package/dist/{applescript-BSLDH0ZG.js → applescript-BYindlo8.js} +1 -1
  48. package/dist/{aql-BeC2kDHp.js → aql-15GcbZWw.js} +1 -1
  49. package/dist/{arduino-DaY17etY.js → arduino-ByLLuVbQ.js} +1 -1
  50. package/dist/{arff-JcGrYmHi.js → arff-OPojJLUz.js} +1 -1
  51. package/dist/{asciidoc-CXk0xsh_.js → asciidoc-Cl2v4xvv.js} +1 -1
  52. package/dist/{asm6502-DeWcSkZd.js → asm6502-CB7yVfmz.js} +1 -1
  53. package/dist/{asmatmel-pCbQy2E1.js → asmatmel-K6Lx6ZK5.js} +1 -1
  54. package/dist/{aspnet-CGgQKpj1.js → aspnet-dBH1pcUx.js} +1 -1
  55. package/dist/{autohotkey-CWCByzE9.js → autohotkey-RXR1Zgc5.js} +1 -1
  56. package/dist/{autoit-CQ1kOMA_.js → autoit-a4Owx7OM.js} +1 -1
  57. package/dist/{avisynth-NidhborF.js → avisynth-BGZMSyM2.js} +1 -1
  58. package/dist/{avro-idl-YdAx5B3t.js → avro-idl-CeDTcckU.js} +1 -1
  59. package/dist/{bash-B8pjlqQB.js → bash-BRHXXDN_.js} +1 -1
  60. package/dist/{basic-ZavZkCyf.js → basic-agbCSM_c.js} +1 -1
  61. package/dist/{batch-REA8OaY-.js → batch-DJX2p8s2.js} +1 -1
  62. package/dist/{bbcode-CQxqFrIg.js → bbcode-Pjt_r6Zw.js} +1 -1
  63. package/dist/{bell-MwOGYeGm.js → bell-BTslamVx.js} +1 -1
  64. package/dist/{bicep-DJOqdV-v.js → bicep-6wBEPqE6.js} +1 -1
  65. package/dist/{birb-MAz0Fi4T.js → birb-Dk8PWwZg.js} +1 -1
  66. package/dist/{bison-8dswU4Fr.js → bison-DdgM5ASb.js} +1 -1
  67. package/dist/{blockEditorContent-DTCnAnIb.js → blockEditorContent-D_bHd1_J.js} +1 -1
  68. package/dist/{bnf-8a267BFo.js → bnf-DqfD8DaA.js} +1 -1
  69. package/dist/{brainfuck-ZFw5WqKs.js → brainfuck-N5wdszpE.js} +1 -1
  70. package/dist/{brightscript-CllkxYSJ.js → brightscript-CXu0RZA8.js} +1 -1
  71. package/dist/{bro-Cm7A80zb.js → bro-Dz5ORgap.js} +1 -1
  72. package/dist/{bsl-CzOA-Q-C.js → bsl-BJlP8tfn.js} +1 -1
  73. package/dist/{c-C_XcI9fA.js → c-CuTIIDgr.js} +1 -1
  74. package/dist/{calendar-BSCqpM2w.js → calendar-COOOT1Ui.js} +1 -1
  75. package/dist/{cfscript-Bab_Sx0C.js → cfscript-PRhCDM21.js} +1 -1
  76. package/dist/{chaiscript-BJRtfSSu.js → chaiscript-B2XOntND.js} +1 -1
  77. package/dist/{cil-DbFmDoRf.js → cil-C5RRTuzk.js} +1 -1
  78. package/dist/{clike-bEtaLLnk.js → clike-DGwSB17e.js} +1 -1
  79. package/dist/{clojure-Df236Hz6.js → clojure-DbD5dPEE.js} +1 -1
  80. package/dist/{cmake-CMDWVtX6.js → cmake-CqRykLp2.js} +1 -1
  81. package/dist/{cobol-BRt88m7d.js → cobol-Ccv66ygs.js} +1 -1
  82. package/dist/{coffeescript-BPZxgeUt.js → coffeescript-PLHWfrJQ.js} +1 -1
  83. package/dist/{concurnas-0RSRX3ww.js → concurnas-BMrKYohj.js} +1 -1
  84. package/dist/{contactsList-B0z-tO-u.js → contactsList-BdZBuEO-.js} +2 -2
  85. package/dist/{copyPreviewToClipboard-Dj2viIb5.js → copyPreviewToClipboard-D1EGxfqs.js} +1 -1
  86. package/dist/{coq-CJvpPp2t.js → coq-CCpuVc4x.js} +1 -1
  87. package/dist/{core-CMBlcCy3.js → core-BA0hq8VL.js} +1 -1
  88. package/dist/{cpp-BdufRvoG.js → cpp-CWetzYsY.js} +1 -1
  89. package/dist/{crystal-DfUhDBxB.js → crystal-BKjZToZI.js} +1 -1
  90. package/dist/{csharp-Cy21uK4u.js → csharp-BHdPnIXZ.js} +1 -1
  91. package/dist/{cshtml-D63ZTWMM.js → cshtml-BhdbtnUu.js} +1 -1
  92. package/dist/{csp-BPhKsasa.js → csp-BXWZvhkd.js} +1 -1
  93. package/dist/{css-Bul78QzK.js → css-DdJYCXrX.js} +1 -1
  94. package/dist/{css-extras-DRktiWwl.js → css-extras-CPU90kpm.js} +1 -1
  95. package/dist/{csv-7MRyr8SJ.js → csv-D0K9ZLzY.js} +1 -1
  96. package/dist/{cypher-BM7iPguF.js → cypher-K4ksHWPK.js} +1 -1
  97. package/dist/{d-C1tbKq9S.js → d-DYMp_Wuk.js} +1 -1
  98. package/dist/{dart-D0yrSyuD.js → dart-CmjMK4z3.js} +1 -1
  99. package/dist/{dataweave-BHhnhjhD.js → dataweave-CAJNqvFu.js} +1 -1
  100. package/dist/{dax-DWO7AoXR.js → dax-iIP-NSas.js} +1 -1
  101. package/dist/{dhall-DcUaRM6n.js → dhall-CQ6lAxSG.js} +1 -1
  102. package/dist/{diff-B7tW5RTJ.js → diff-C9RdrWEd.js} +1 -1
  103. package/dist/{django-DM1DPRfA.js → django-D32Qg_Dz.js} +1 -1
  104. package/dist/{dns-zone-file-CPEyHSh7.js → dns-zone-file-Be9O0pFj.js} +1 -1
  105. package/dist/{docker-CzrZay4G.js → docker-D8w5V8hf.js} +1 -1
  106. package/dist/{dot-LsAn6CKb.js → dot-BMDzcO4Q.js} +1 -1
  107. package/dist/{ebnf-Nv1otL7k.js → ebnf-C7OTCtDH.js} +1 -1
  108. package/dist/{editCarrierDialog-BXCL9gUE.js → editCarrierDialog-C3LLoIri.js} +1 -1
  109. package/dist/{editorconfig-DtBoHuXP.js → editorconfig-qppn9AA4.js} +1 -1
  110. package/dist/{eiffel-BuxyvyON.js → eiffel-BkhN1ai7.js} +1 -1
  111. package/dist/{ejs-DBB5tUwo.js → ejs-CkBbijWp.js} +1 -1
  112. package/dist/{elixir-CGr_niXy.js → elixir-C5r70aeL.js} +1 -1
  113. package/dist/{elm-BBDGnKy2.js → elm-CT45-ZSY.js} +1 -1
  114. package/dist/{erb-D9vM9M0f.js → erb-CkhfnYKi.js} +1 -1
  115. package/dist/{erlang-BzFVdM_D.js → erlang-DGDEI4cI.js} +1 -1
  116. package/dist/{etlua-BCzEctsb.js → etlua-BxRQuWCi.js} +1 -1
  117. package/dist/{excel-formula-LhPweRL3.js → excel-formula-DBI78Wpo.js} +1 -1
  118. package/dist/{exportFileGeneration-CeVM9_mI.js → exportFileGeneration-jv6-MI8B.js} +1 -1
  119. package/dist/{exportImageReadiness-peQzbc3B.js → exportImageReadiness-CDj5qZi9.js} +1 -1
  120. package/dist/{exportImageReadinessNotifier-DtXVsH7r.js → exportImageReadinessNotifier-CeLSrlmS.js} +1 -1
  121. package/dist/{exportPageHtml-CIOqbyxE.js → exportPageHtml-YIUR3iCw.js} +1 -1
  122. package/dist/{exportPreviewToDocx-CFcD1usX.js → exportPreviewToDocx-BZYEefQ4.js} +2 -2
  123. package/dist/{exportPreviewToPdf-DZ50Rsch.js → exportPreviewToPdf-DaXjpfml.js} +1 -1
  124. package/dist/{factor-CcHpcTC_.js → factor-DW-YbHRy.js} +1 -1
  125. package/dist/{false-DuIpvQCu.js → false-CIwoK_bp.js} +1 -1
  126. package/dist/{firestore-security-rules-Dd2-QvPl.js → firestore-security-rules-DbQNYCYQ.js} +1 -1
  127. package/dist/{flask-conical-Du8eZKeU.js → flask-conical-Da3wtJcE.js} +1 -1
  128. package/dist/{flow-DVlWriuW.js → flow-Cn0-1PK0.js} +1 -1
  129. package/dist/{fortran-CJisIyQD.js → fortran-BsEXgIqG.js} +1 -1
  130. package/dist/{fsharp-D9nGzLGO.js → fsharp-C2bO32k2.js} +1 -1
  131. package/dist/{ftl-D6mhwxVM.js → ftl-CLSjhWQn.js} +1 -1
  132. package/dist/{gap-BYHchtNz.js → gap-CBZ8TbG9.js} +1 -1
  133. package/dist/{gcode-D7Pwx5Cm.js → gcode-BIGw5Zoj.js} +1 -1
  134. package/dist/{gdscript-CC1NQzz9.js → gdscript-DRDBJ-b6.js} +1 -1
  135. package/dist/{gedcom-DO_flW4F.js → gedcom-BQf-XBul.js} +1 -1
  136. package/dist/{gherkin-DTEA3uXy.js → gherkin-CYc6Amj6.js} +1 -1
  137. package/dist/{git-DXXM4-Ci.js → git-KgBaBS5O.js} +1 -1
  138. package/dist/{glsl-CgB5Sdm0.js → glsl-DHJk6hAC.js} +1 -1
  139. package/dist/{gml-C61JM540.js → gml-dadmAxnP.js} +1 -1
  140. package/dist/{gn-ByHpZz4o.js → gn-CfvXXPul.js} +1 -1
  141. package/dist/{go-Cq9cs46P.js → go-ByoRUu_w.js} +1 -1
  142. package/dist/{go-module-BKAql-EX.js → go-module-ClzLogu-.js} +1 -1
  143. package/dist/{graphql-CI5K9mGP.js → graphql-BOymJWDj.js} +1 -1
  144. package/dist/{groovy-lgjVRsUE.js → groovy-CHqHkjta.js} +1 -1
  145. package/dist/{haml-C5QMjtmY.js → haml-B6GJtQk2.js} +1 -1
  146. package/dist/{handlebars-BwgQh9LH.js → handlebars-AuAgc0-f.js} +1 -1
  147. package/dist/{haskell-ult4yaQP.js → haskell-DXnJEJus.js} +1 -1
  148. package/dist/{haxe-DFez4pks.js → haxe-D8E0QiBV.js} +1 -1
  149. package/dist/{hcl-CL9-V5fU.js → hcl-CpHiQfcO.js} +1 -1
  150. package/dist/{highlighter-DXAQAEoS.js → highlighter-DAPZ5ZEj.js} +1 -1
  151. package/dist/{hlsl-D4Brxbti.js → hlsl-DYsPT6yo.js} +1 -1
  152. package/dist/{hoon-ClhZkT3O.js → hoon-Drd_pk4j.js} +1 -1
  153. package/dist/{hpkp-IACifWyZ.js → hpkp-DSLiy4_v.js} +1 -1
  154. package/dist/{hsts-Sf24DZcJ.js → hsts-B_PKsKHu.js} +1 -1
  155. package/dist/{http-CSOnKNRz.js → http-Cf1M5FbK.js} +1 -1
  156. package/dist/{ichigojam-BHuVrtPv.js → ichigojam-BrObYT8Z.js} +1 -1
  157. package/dist/{icon-CEEdJZd5.js → icon-C3S0RIlo.js} +1 -1
  158. package/dist/{icu-message-format-BubraUPX.js → icu-message-format-Cf5Qt4s1.js} +1 -1
  159. package/dist/{idris-BRasP9zu.js → idris-CXLbI--J.js} +1 -1
  160. package/dist/{iecst-uxP57CPw.js → iecst-QPbbIddO.js} +1 -1
  161. package/dist/{ignore-CaX7DqnR.js → ignore-Drp6REDq.js} +1 -1
  162. package/dist/{image-plus-CJraVezv.js → image-plus-BcyqmHS0.js} +1 -1
  163. package/dist/{index-fo9ok2c2.js → index-C0Gkblqe.js} +1 -1
  164. package/dist/{index-Bz1wSegO.js → index-CBlf4ZHC.js} +1 -1
  165. package/dist/{index-C521BAYE.js → index-CSAs9f_t.js} +1 -1
  166. package/dist/{index-BV5xk8Y3.js → index-CYwSz9D6.js} +1 -1
  167. package/dist/index-Cby4FZtk.js +1 -0
  168. package/dist/{index-PAFnPEs9.js → index-DNmsYMzw.js} +1 -1
  169. package/dist/{index-CAd6FKzO.js → index-DwvbZ9qn.js} +1 -1
  170. package/dist/{index.client-CYW9yT2N.js → index.client-BJx0ctif.js} +1 -1
  171. package/dist/index.js +1 -1
  172. package/dist/{inform7-CVzTiPjg.js → inform7-BACjKVvp.js} +1 -1
  173. package/dist/{ini-Qaf7cmlN.js → ini-DjEl7XDu.js} +1 -1
  174. package/dist/{io-COR01DoR.js → io-BgTCr5Ol.js} +1 -1
  175. package/dist/{j-yP7SR_uu.js → j-bKl98o4i.js} +1 -1
  176. package/dist/{java-Bbny__uX.js → java-Dd1qQPUu.js} +1 -1
  177. package/dist/{javadoc-DP6Ja3C9.js → javadoc-Cjg7_vYe.js} +1 -1
  178. package/dist/{javadoclike-CapAuhba.js → javadoclike-BCcCNpHL.js} +1 -1
  179. package/dist/{javascript-ADhB8gob.js → javascript-DqPXVYkL.js} +1 -1
  180. package/dist/{javastacktrace-Bb95aQdb.js → javastacktrace-9TWEhEcV.js} +1 -1
  181. package/dist/{jexl-D08ebKw3.js → jexl-KD77OyKm.js} +1 -1
  182. package/dist/{jolie-CK-ySTCl.js → jolie-DSjytNuc.js} +1 -1
  183. package/dist/{jq-BwCIBRp0.js → jq-BXF3-PqX.js} +1 -1
  184. package/dist/{js-extras-DgloDgjO.js → js-extras-Bpy1yDzs.js} +1 -1
  185. package/dist/{js-templates-hmCRafJK.js → js-templates-Nl3vE30e.js} +1 -1
  186. package/dist/{jsdoc-C35n5Znu.js → jsdoc-D6QQrQYo.js} +1 -1
  187. package/dist/{json-ByHRwNn3.js → json-B3GCDKdg.js} +1 -1
  188. package/dist/{json5-COlqTh-P.js → json5-D_-69nn_.js} +1 -1
  189. package/dist/{jsonp-Dlf8IbpE.js → jsonp-JcAa3C4I.js} +1 -1
  190. package/dist/{jsstacktrace-FPrOKWZv.js → jsstacktrace-D9GmUGI4.js} +1 -1
  191. package/dist/{jsx-CFzOc_m9.js → jsx-BNLUlg-T.js} +1 -1
  192. package/dist/{julia-BQ1ThnRa.js → julia-O4TTvxpe.js} +1 -1
  193. package/dist/{keepalived-CYQM8AtZ.js → keepalived-DnHZTPB6.js} +1 -1
  194. package/dist/{keyman-CEH_Ad6m.js → keyman-DTcchL5f.js} +1 -1
  195. package/dist/{kotlin-C67Odc1X.js → kotlin-CCK89SI-.js} +1 -1
  196. package/dist/{kumir-De3pIzfB.js → kumir-ecs2TNgC.js} +1 -1
  197. package/dist/{kusto-CrLD_pBJ.js → kusto-0MwyroVg.js} +1 -1
  198. package/dist/{latex-62-9Da8Q.js → latex-CXlebZd6.js} +1 -1
  199. package/dist/{latte-CUdphyLz.js → latte-B-m2aQBk.js} +1 -1
  200. package/dist/{less-D5ADKqV-.js → less-D57oMxoB.js} +1 -1
  201. package/dist/{lilypond-OtjWaXgK.js → lilypond-4ugjbXbl.js} +1 -1
  202. package/dist/{link-2-off-T60_9mFw.js → link-2-off-Ca2lgyZa.js} +1 -1
  203. package/dist/{liquid-8elQtUHz.js → liquid-CrgrRg9C.js} +1 -1
  204. package/dist/{lisp-zljjd4ff.js → lisp-DXIUy7zh.js} +1 -1
  205. package/dist/{livescript-DsKHdhkZ.js → livescript-aHUKAE2I.js} +1 -1
  206. package/dist/{llvm-BpdWsg1X.js → llvm-CPeVTDR4.js} +1 -1
  207. package/dist/{lock-keyhole-DvK_lZN9.js → lock-keyhole-uMCobyq9.js} +1 -1
  208. package/dist/{log-kuFOhbzg.js → log-M9-gwZMd.js} +1 -1
  209. package/dist/{lolcode-CFCcoHPQ.js → lolcode-C0TXGyuZ.js} +1 -1
  210. package/dist/{lua-B3_ke__5.js → lua-DcdvB7SD.js} +1 -1
  211. package/dist/{lucide-react-BaaLzD9l.js → lucide-react-Cb6uZUCM.js} +1 -1
  212. package/dist/{luckyexcel.umd-CCxp_d21.js → luckyexcel.umd-CMJ-jTWA.js} +1 -1
  213. package/dist/{magma-DC6GdvAW.js → magma-CbuALZN6.js} +1 -1
  214. package/dist/{makefile-CQdi7iDD.js → makefile-Ctl2m72g.js} +1 -1
  215. package/dist/{markdown-B1My0jMq.js → markdown-BBB83qSM.js} +1 -1
  216. package/dist/{markup-DcOZK3Xw.js → markup-ChaAbQEE.js} +1 -1
  217. package/dist/{markup-templating-kpXoDHpZ.js → markup-templating-BC6zTNOf.js} +1 -1
  218. package/dist/{matlab-D1gj6w7T.js → matlab-BV4wZqtC.js} +1 -1
  219. package/dist/{maxscript-CvcSniM8.js → maxscript-BeGQh6fd.js} +1 -1
  220. package/dist/{mel-93S6jqSq.js → mel-CkXjXFiq.js} +1 -1
  221. package/dist/{mermaid-DW6loAvJ.js → mermaid-DTn-xMIg.js} +1 -1
  222. package/dist/{mizar-5KjijBGr.js → mizar-B5G36J76.js} +1 -1
  223. package/dist/{mongodb-CQzyGpln.js → mongodb-pzXK78PB.js} +1 -1
  224. package/dist/{monkey-B84fUtqt.js → monkey-D0Okz-Hv.js} +1 -1
  225. package/dist/{moonscript-BsTRKUdi.js → moonscript-hZPS2rnh.js} +1 -1
  226. package/dist/{n1ql-DISr1zDm.js → n1ql-i590EfVo.js} +1 -1
  227. package/dist/{n4js-DhZEsd2v.js → n4js-Bm2BOb-b.js} +1 -1
  228. package/dist/{nand2tetris-hdl-ABW8YDTc.js → nand2tetris-hdl-otzVnETn.js} +1 -1
  229. package/dist/{naniscript-N85tXmpK.js → naniscript-DXuKBlLb.js} +1 -1
  230. package/dist/{nasm-B0AHnG7q.js → nasm-CYm5PYml.js} +1 -1
  231. package/dist/{neon-CZp7jTc6.js → neon-Bo6tY83f.js} +1 -1
  232. package/dist/{nevod-6gauoTUa.js → nevod-Gcs2A1zm.js} +1 -1
  233. package/dist/{nginx-C2zOzBAz.js → nginx-DEoE4eVH.js} +1 -1
  234. package/dist/{nim-C0Uzwy5x.js → nim-TdrtAfLM.js} +1 -1
  235. package/dist/{nix-BrdifkKo.js → nix-DmcVWv_a.js} +1 -1
  236. package/dist/{nsis-BrggHEzH.js → nsis-PBw8jCEI.js} +1 -1
  237. package/dist/{objectivec-spfzenzk.js → objectivec-qbUbr2e8.js} +1 -1
  238. package/dist/{ocaml-BKODJFl1.js → ocaml-DN65ghCF.js} +1 -1
  239. package/dist/{opencl-Bok-54Vp.js → opencl-Bp2scBGb.js} +1 -1
  240. package/dist/{openqasm-DDjgSSMR.js → openqasm-DiYNdKZA.js} +1 -1
  241. package/dist/{oz-CEHMWvb4.js → oz-CfCCMcrx.js} +1 -1
  242. package/dist/{paintbrush-CEWFWf7w.js → paintbrush-D27bg9DR.js} +1 -1
  243. package/dist/{parigp-Cfi4rbtQ.js → parigp-Dbi-TagY.js} +1 -1
  244. package/dist/{parser-DUruS4IJ.js → parser-Df90cPRN.js} +1 -1
  245. package/dist/{pascal-DPq6g9TY.js → pascal-8FyaRBQi.js} +1 -1
  246. package/dist/{pascaligo-etzXSMQt.js → pascaligo-z2M6k-2Q.js} +1 -1
  247. package/dist/{pcaxis-DbmRgQpH.js → pcaxis-CRBcuDL7.js} +1 -1
  248. package/dist/{pen-tool-Bgn3U1At.js → pen-tool-uVg30dx-.js} +1 -1
  249. package/dist/{peoplecode-DZ6isFp-.js → peoplecode-eoVCpjRQ.js} +1 -1
  250. package/dist/{perl-B4yBVerS.js → perl-CTl4omd_.js} +1 -1
  251. package/dist/{php-D7cHtvCs.js → php-DC6ow60x.js} +1 -1
  252. package/dist/{php-extras-BhGr77L3.js → php-extras-Dwhm3AVj.js} +1 -1
  253. package/dist/{phpdoc-CRreWNTx.js → phpdoc-B5RIivBB.js} +1 -1
  254. package/dist/{plsql-DrRc3bbu.js → plsql-DASNBsn8.js} +1 -1
  255. package/dist/{plyr-DpSA-MsO.js → plyr-Ce5vKEUV.js} +1 -1
  256. package/dist/{powerquery-BLFgMvAi.js → powerquery-DdnoovHd.js} +1 -1
  257. package/dist/{powershell-BPFiXnP9.js → powershell-yqxKLKdg.js} +1 -1
  258. package/dist/{processing-lKr4vrBr.js → processing-CAPvkmLV.js} +1 -1
  259. package/dist/{prolog-OSfAGXGl.js → prolog-B6cfhgQo.js} +1 -1
  260. package/dist/{promql-K--tshxl.js → promql-DCw0LI19.js} +1 -1
  261. package/dist/{properties-CMZVqHRn.js → properties-meXDNQgv.js} +1 -1
  262. package/dist/{protobuf-CvTNb9BQ.js → protobuf-fkTMKSyY.js} +1 -1
  263. package/dist/{psl-DYwBAZZD.js → psl-DZPPYzVM.js} +1 -1
  264. package/dist/{pug-1TqBuTH0.js → pug-518ifITl.js} +1 -1
  265. package/dist/{puppet-B_EcCI_v.js → puppet-s2x78VFh.js} +1 -1
  266. package/dist/{pure-CPBjkOmd.js → pure-DpzUWVMd.js} +1 -1
  267. package/dist/{purebasic-9mf0_JXX.js → purebasic-lpyyjWMT.js} +1 -1
  268. package/dist/{purescript--FL6Trhg.js → purescript-DRPDJYKO.js} +1 -1
  269. package/dist/{python-Cc5RVqLB.js → python-DdiRRIKn.js} +1 -1
  270. package/dist/{q-VpanUOqW.js → q-C5Y_0UoU.js} +1 -1
  271. package/dist/{qml-B5WyDHIC.js → qml-BGfSJxxc.js} +1 -1
  272. package/dist/{qore-wayxVcRs.js → qore-CYzA0gog.js} +1 -1
  273. package/dist/{qsharp-DvmjaF2j.js → qsharp-NJOrkaw5.js} +1 -1
  274. package/dist/{quill-B4ORCbH4.js → quill-CgGppInx.js} +1 -1
  275. package/dist/{r-CYwRogeI.js → r-GRt27eZV.js} +1 -1
  276. package/dist/{racket-RE9AidNe.js → racket-D8g6_6bU.js} +1 -1
  277. package/dist/{reason-CjkaNbJc.js → reason-BQg_azTe.js} +1 -1
  278. package/dist/{regex-D7BPd746.js → regex-CLnGg2F9.js} +1 -1
  279. package/dist/{rego-BzIBHxve.js → rego-B_vKrfdB.js} +1 -1
  280. package/dist/{renpy-BB1bnIiP.js → renpy-C-gLQSc-.js} +1 -1
  281. package/dist/{rest-2Dpcc8WB.js → rest-DC51IBzb.js} +1 -1
  282. package/dist/{rip-08osaijV.js → rip-CiK5FgGO.js} +1 -1
  283. package/dist/{roboconf-DMVEVq8H.js → roboconf-DvqYNykk.js} +1 -1
  284. package/dist/{robotframework-DlKIRW6f.js → robotframework-DNhOUpTF.js} +1 -1
  285. package/dist/{ruby-BreSnY6m.js → ruby-DBIMJkdP.js} +1 -1
  286. package/dist/{runtime-DTft3h2S.js → runtime-BifHPIs0.js} +25 -25
  287. package/dist/{rust-B6s0RNtl.js → rust-mLfW4Jis.js} +1 -1
  288. package/dist/{sas-CLgysy1W.js → sas-DodITxZ6.js} +1 -1
  289. package/dist/{sass-DFHO6zUs.js → sass-BSLEX7Yz.js} +1 -1
  290. package/dist/{scala-DtDRbcKe.js → scala-DCO-Xgiy.js} +1 -1
  291. package/dist/{scheme-DKlhmsCX.js → scheme-B80QclYj.js} +1 -1
  292. package/dist/{scss-4BIC-zMQ.js → scss-BcSMUf22.js} +1 -1
  293. package/dist/{shell-session-CsEzAmuo.js → shell-session-C59QXsqi.js} +1 -1
  294. package/dist/{smali-tiMN3sZO.js → smali-FbC4U8-2.js} +1 -1
  295. package/dist/{smalltalk-BCazX-_q.js → smalltalk-DGhaYsG5.js} +1 -1
  296. package/dist/{smarty-CksUSwL1.js → smarty-BBvzKP8A.js} +1 -1
  297. package/dist/{sml-CIY3ODnH.js → sml-CFNJ4sWx.js} +1 -1
  298. package/dist/{solidity-DJU0zXfT.js → solidity-C4SkB9lJ.js} +1 -1
  299. package/dist/{solution-file-BaMaO1TP.js → solution-file-CIOXRDPU.js} +1 -1
  300. package/dist/{soy-CxJQOvsD.js → soy-B0QWMSsQ.js} +1 -1
  301. package/dist/{sparql-Dh8jq1ey.js → sparql-B1emdHxl.js} +1 -1
  302. package/dist/{splunk-spl-D-cRFGpP.js → splunk-spl-BQT5CpVn.js} +1 -1
  303. package/dist/{sqf-rLZTc7Qv.js → sqf-COJ36VWV.js} +1 -1
  304. package/dist/{sql-CeRxouYk.js → sql-Cm6Rxm3F.js} +1 -1
  305. package/dist/{squirrel-D7o9hvRc.js → squirrel-BvbuDiB5.js} +1 -1
  306. package/dist/{stan-Md3woDOZ.js → stan-8SccDLeL.js} +1 -1
  307. package/dist/styles.css +1 -1
  308. package/dist/{stylus-ryYWCXNQ.js → stylus-BXIkN-mU.js} +1 -1
  309. package/dist/{swift-DBCInAlm.js → swift-Bfnd6xcE.js} +1 -1
  310. package/dist/{systemd-DaeW5Q3d.js → systemd-DlB6VQpH.js} +1 -1
  311. package/dist/{t4-cs-B2qiaXkP.js → t4-cs-C1jMgzWz.js} +1 -1
  312. package/dist/{t4-templating-CXPOegoo.js → t4-templating-D6Zr_zsI.js} +1 -1
  313. package/dist/{t4-vb-B2EQrsqL.js → t4-vb-Bq71PqzO.js} +1 -1
  314. package/dist/{table-Dzy4yNJZ.js → table-CPrbaW5I.js} +1 -1
  315. package/dist/{tap-G_gG_sRq.js → tap-DyR67KdS.js} +1 -1
  316. package/dist/{tcl-BwnV2t-P.js → tcl-DJgbJar5.js} +1 -1
  317. package/dist/{templateSelectorDialog-BcMQSj_0.js → templateSelectorDialog-BNvjBhpq.js} +2 -2
  318. package/dist/{textile-mIDFvte5.js → textile-CPVNLoud.js} +1 -1
  319. package/dist/{toml-iaABBvkk.js → toml-DmBxHMBz.js} +1 -1
  320. package/dist/{tremor-CqIe8z0g.js → tremor-DnT0QtrJ.js} +1 -1
  321. package/dist/{tsx-DiyaBKfA.js → tsx-DASGNI4o.js} +1 -1
  322. package/dist/{tt2-ADSheJhT.js → tt2-KkSOzlcQ.js} +1 -1
  323. package/dist/{turtle-ZJykXPsQ.js → turtle-Bou6NsTX.js} +1 -1
  324. package/dist/{twig-D9PzA24a.js → twig-DBuvt9EN.js} +1 -1
  325. package/dist/{typescript-HPWM5Vvn.js → typescript-DtZbZDta.js} +1 -1
  326. package/dist/{typoscript-W1baQ56e.js → typoscript-CKxngJhN.js} +1 -1
  327. package/dist/{unrealscript-B1xE53U9.js → unrealscript-CBOTq3tc.js} +1 -1
  328. package/dist/{uorazor-BYnFV7JR.js → uorazor-DPCvYi6m.js} +1 -1
  329. package/dist/{uri-9NPZH5EW.js → uri-BQgLu96d.js} +1 -1
  330. package/dist/{usePromptLibraryMutations-BAHofYrl.js → usePromptLibraryMutations-8U9vDhzf.js} +1 -1
  331. package/dist/{useSupabaseBlobUrl-BON8ZaoJ.js → useSupabaseBlobUrl-DrqlnXWA.js} +1 -1
  332. package/dist/{useTermsNotice-DFMjhtjf.js → useTermsNotice-CkE_Q5Tp.js} +1 -1
  333. package/dist/{user-plus-CQOONUKt.js → user-plus-4IThLzWj.js} +1 -1
  334. package/dist/{user-round-plus-DbBGAdct.js → user-round-plus-CLd-3D3w.js} +1 -1
  335. package/dist/{v-MtVdHYGb.js → v-CpbsHXeZ.js} +1 -1
  336. package/dist/{vala-CzD6F82o.js → vala-BHVtC0lQ.js} +1 -1
  337. package/dist/{vbnet-7x9se1Ug.js → vbnet-uysrqtli.js} +1 -1
  338. package/dist/{velocity-L2ehgfCO.js → velocity-D_kHHfYP.js} +1 -1
  339. package/dist/{verilog-C4jcbodQ.js → verilog-UzNA6NFZ.js} +1 -1
  340. package/dist/{vhdl-CglE9JL1.js → vhdl-C5EKOU92.js} +1 -1
  341. package/dist/{vim-CFRg4-FG.js → vim-B2VGKk7h.js} +1 -1
  342. package/dist/{visual-basic-B7c4QbC8.js → visual-basic-4WOV357e.js} +1 -1
  343. package/dist/{warpscript-Bu2s9IQz.js → warpscript-DpaRP7Xh.js} +1 -1
  344. package/dist/{wasm-DJJfqscE.js → wasm-CykGgr5f.js} +1 -1
  345. package/dist/{web-idl-7LLEeecb.js → web-idl-C2TZZI4F.js} +1 -1
  346. package/dist/{wiki-DK7esTQM.js → wiki-CE9RoQN4.js} +1 -1
  347. package/dist/{wolfram-C2Xf77Md.js → wolfram-CoSA8VPo.js} +1 -1
  348. package/dist/{wren-CYBubtxz.js → wren-DC5-ldaC.js} +1 -1
  349. package/dist/{xeora-CG4bAthb.js → xeora-BYrkBqgs.js} +1 -1
  350. package/dist/{xml-doc-9DmxE8CJ.js → xml-doc-6JSg6fqu.js} +1 -1
  351. package/dist/{xojo-CSZtRZKm.js → xojo-CdLVgTt3.js} +1 -1
  352. package/dist/{xquery-DLAQ1I2e.js → xquery-kWK0GIxx.js} +1 -1
  353. package/dist/{yaml-B-XYt3aD.js → yaml-CH2rnZTp.js} +1 -1
  354. package/dist/{yang-Cf5quOlz.js → yang-JPmPQYEP.js} +1 -1
  355. package/dist/{zig-DI05Q7nt.js → zig-BHP1XdGd.js} +1 -1
  356. package/package.json +2 -2
  357. package/dist/index-CaHu5cQK.js +0 -1
@@ -1,4 +1,4 @@
1
- import{jsxs as l,jsx as e,Fragment as j}from"react/jsx-runtime";import Ma,{useMemo as M,useState as y,useEffect as me,useCallback as O,useRef as Et}from"react";import{cf as He,fo as $e,gV as Z,gW as Re,gX as je,gY as ee,gZ as Oa,g_ as Pt,by as _a,g$ as Ba,bD as G,cm as Ha,bU as pe,P as $a,h0 as Ra,h1 as ja,h2 as It,h3 as Ft,cI as Ga,h4 as Va,h5 as Ua,h6 as Wa,h7 as qa,h8 as Xa,h9 as Ja,ha as za,hb as Ka,e3 as Ya,hc as Qa,hd as Za,cT as ei,cV as ti,ca as Ge,cW as Ve,cX as ai,d0 as ue,j as St,cK as ii,cN as kt,ch as ri,ci as li,cO as Ue,c1 as ni,c2 as oi,c8 as We,c3 as qe,he as si,hf as ci,aC as di,bN as te,c9 as hi,bH as Xe,bI as Je,bJ as ze,bK as Ke,cY as mi,cZ as pi,bL as J,c_ as At,c$ as Ye,hg as ui,hh as fi,bM as Tt,hi as gi,cu as z,d2 as Lt}from"./runtime-DTft3h2S.js";import{C as xi}from"./calendar-BSCqpM2w.js";import{u as vi}from"./useSupabaseBlobUrl-BON8ZaoJ.js";const yi=(a,i,r,o,n,s)=>["epic","activities","infinite",a,i,r,o,n,s],bi=({accountId:a,accountTypeCode:i="CUST",activityStatus:r="All",activityCode:o,associatedToId:n,associatedToType:s,enabled:u=!0})=>{var h;const{captureException:m}=He(),c=$e({queryKey:yi(a,i,r,o,n,s),queryFn:async({pageParam:v=0})=>{const I={account_id:a,account_type_code:i,activity_status:r,page_number:v,...o&&{activity_code:o},...n&&{associated_to_id:n},...s&&{associated_to_type:s}};try{const g=await Re.listActivities(I);if(je(g))throw new ee;if(Oa(g))return{activities:[],totalFound:0,totalCount:0,pageNumber:v,totalPages:0,hasMorePages:!1,status:"success",message:""};if(Pt(g)){const{message:A,statusCode:C}=g;throw new Z(A??"Epic is temporarily unavailable. Please try again.",C)}if(g.status!=="success")throw new Error(g.message||"Failed to fetch activities");return g}catch(g){throw g instanceof ee||g instanceof Z||m({error:g,extra:{pageParam:v,accountId:a,accountTypeCode:i,activityStatus:r}}),g}},getNextPageParam:(v,I)=>{if(v.hasMorePages)return I.length},initialPageParam:0,enabled:u&&!!a,staleTime:300*1e3,gcTime:600*1e3,retry:(v,I)=>I instanceof Z&&v<1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),x=M(()=>{var v;return(v=c.data)!=null&&v.pages?c.data.pages.reduce((I,g)=>[...I,...g.activities||[]],[]):[]},[(h=c.data)==null?void 0:h.pages]);return{...c,activities:x,hasMoreActivities:c.hasNextPage,loadMoreActivities:c.fetchNextPage,isLoadingMore:c.isFetchingNextPage}},Qe=50,Dt=(a,i,r,o)=>["epic","policies","infinite",a,i,r,o],Ni=({clientId:a,policyNumber:i,status:r="All",expirationDateBegins:o,enabled:n=!0,drainAll:s=!1})=>{var u,h;const{captureException:m}=He(),c=$e({queryKey:Dt(a,i,r,o),queryFn:async({pageParam:E=0})=>{const _={client_id:a,page_number:E,...i&&{policy_number:i,policy_number_comparison_type:"Containing"},...r&&{status:r},...o&&{expiration_date_begins:o}};try{const F=await Re.listPolicies(_);if(je(F))throw new ee;if(Pt(F)){const{message:p,statusCode:w}=F;throw new Z(p??"Epic is temporarily unavailable. Please try again.",w)}if(F.status!=="success")throw new Error(F.message||"Failed to fetch policies");return F}catch(F){throw F instanceof ee||F instanceof Z||m({error:F,extra:{pageParam:E,clientId:a}}),F}},getNextPageParam:(E,_)=>E.hasMorePages?_.length:void 0,initialPageParam:0,enabled:n&&!!a,staleTime:300*1e3,gcTime:600*1e3,retry:(E,_)=>_ instanceof Z&&E<1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),x=M(()=>{var E;return(((E=c.data)==null?void 0:E.pages)??[]).flatMap(_=>_.policies??[])},[(u=c.data)==null?void 0:u.pages]),v=n&&!!a,{hasNextPage:I,isFetchingNextPage:g,isError:A,fetchNextPage:C}=c,$=((h=c.data)==null?void 0:h.pages.length)??0,[X,T]=y(Qe),B=JSON.stringify(Dt(a,i,r,o));me(()=>{T(Qe)},[B]);const L=O(()=>{T(E=>Math.max(E,$)+Qe)},[$]),V=$>=X,R=s&&v&&!V&&!A&&!!I;return me(()=>{!R||g||C({cancelRefetch:!1})},[R,g,C,$]),{...c,policies:x,hasMorePolicies:c.hasNextPage,loadMorePolicies:c.fetchNextPage,isLoadingMore:c.isFetchingNextPage,isDraining:R||s&&v&&!V&&g,isDrainCapped:s&&V&&!!I,extendDrain:L}},wi=a=>{const i=["epic","clients","infinite"];return a&&Object.keys(a).length>0?[...i,a]:i},Ci=({enabled:a=!0,filters:i={}}={})=>{var r;const{toast:o}=_a(),{captureException:n}=He(),s=$e({queryKey:wi(i),queryFn:async({pageParam:h=0})=>{const m={page_number:h,...i};try{const c=await Re.listClients(m);if(je(c))throw new ee;if(c.status!=="success")throw new Error(c.message||"Failed to fetch clients");return c}catch(c){if(c instanceof ee)throw c;const x=c instanceof Error?c.message:"An unknown error occurred";throw o({title:"Couldn't reach Epic right now",description:x,variant:"destructive"}),n({error:c,extra:{pageParam:h,filters:i}}),c}},getNextPageParam:(h,m)=>{if(h.hasMorePages)return m.length},initialPageParam:0,enabled:a,staleTime:300*1e3,gcTime:600*1e3,retry:!1}),u=M(()=>{var h;return(h=s.data)!=null&&h.pages?s.data.pages.reduce((m,c)=>[...m,...c.clients||[]],[]):[]},[(r=s.data)==null?void 0:r.pages]);return{...s,clients:u,hasMoreClients:s.hasNextPage,loadMoreClients:s.fetchNextPage,isLoadingMore:s.isFetchingNextPage}},Ei=()=>{const a=Ba();return l("div",{role:"alert","data-testid":"epic-user-code-missing-alert",className:"rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100",children:[e("p",{className:"font-medium",children:"Your Epic access isn't set up yet"}),e("p",{className:"mt-1 text-amber-800 dark:text-amber-200",children:"Ask your administrator to map your Epic operator code in the Applied Epic integration settings, then reopen this dialog."}),a?e("p",{className:"mt-1 text-amber-800 dark:text-amber-200","data-testid":"epic-user-code-missing-alert-contacts",children:a}):null]})},Mt=(a,i)=>a instanceof Z?a.userMessage:i,Ot=({message:a,onRetry:i,disabled:r=!1,"data-testid":o})=>l("div",{role:"alert","data-testid":o,className:"mt-1 flex items-center justify-between gap-2",children:[e("p",{className:"text-xs text-error min-w-0",children:a}),e(G,{variant:"outline",size:"xs",leftIcon:e(Ha,{className:"h-3 w-3"}),onClick:i,disabled:r,className:"shrink-0","data-testid":o?`${o}-retry`:void 0,children:"Retry"})]}),Pi="Untitled Policy",_t=a=>{const i=$a(a);return Number.isNaN(i.getTime())||i.getFullYear()<1970?"N/A":Ra(i)},Bt=a=>{const i=a.description||Pi;return{value:String(a.policyId),label:i,customRender:l("div",{className:"flex flex-col flex-1 min-w-0",children:[e(pe,{tooltipContent:i,side:"right",children:e("span",{className:"truncate text-sm block",children:i})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:[l("span",{className:"min-w-0 truncate",children:["Policy #: ",a.policyNumber||"N/A"]}),l("span",{className:"flex items-center gap-1 shrink-0 whitespace-nowrap",children:[e(xi,{size:12}),_t(a.effectiveDate)," - ",_t(a.expirationDate)]}),l("span",{className:"min-w-0 truncate",children:["ID: ",a.policyId]})]})]})}},Ii="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";function Ht(a){return a.startsWith("data:")||a.startsWith("blob:")?!0:a.startsWith("/")&&!a.startsWith("//")}async function Fi(a,i){const r=JSON.parse(JSON.stringify(a)),o=async n=>{for(const s of n){if(!s||typeof s!="object")continue;const u=s;if(typeof u.src=="string"&&u.src.length>0&&!Ht(u.src)){let h=null;try{h=await i(u.src)}catch{h=null}u.src=h&&Ht(h)?h:Ii}Array.isArray(u.objects)&&await o(u.objects)}};return Array.isArray(r.objects)&&await o(r.objects),r}async function Si({json:a,width:i,height:r,multiplier:o=2}){if(typeof document>"u")throw new Error("rasterizeChromeBand requires a browser document");const n=document.createElement("canvas"),s=new ja(n,i,r);try{return s.workspaceWidth=i,s.workspaceHeight=r,await s.loadFromJSON(a,{awaitImages:!0}),s.canvas.renderAll(),s.canvas.toDataURL({format:"png",multiplier:o})}finally{s.dispose()}}const ki={A4:"a4",Letter:"us-letter"};function Ai(a){return a||null}async function $t(a,i,r,o,n){const s=Ai(a);if(!s||!Va(s))return null;const u=Ja(n,r),h=Ua(s,i,u);if(!h)return null;const m=Wa(a,u),c=qa(u),x=await Fi(h,o);return{html:`<img src="${await Si({json:x,width:c,height:m})}" style="display:block;width:100%;" alt="" />`,height:Xa(m)}}async function Ti(a,i,r,o,n,s="portrait",u="A4"){var h,m;let c="",x="",v,I;if(!a)return{headerHtml:c,footerHtml:x};const g=ki[u]??"us-letter";if(i){const C=await $t(a.headerBlock,"header",s,n??o,g);C&&(c=C.html,v=C.height)}if(r){const C=await $t(a.footerBlock,"footer",s,n??o,g);C&&(x=C.html,I=C.height)}if(!a.metadata)return{headerHtml:c,footerHtml:x,headerHeight:v,footerHeight:I};const A=It(a.metadata);return i&&!c&&(h=A.header)!=null&&h.template&&(c=await Ft(A.header.template,o)),r&&!x&&(m=A.footer)!=null&&m.template&&(x=await Ft(A.footer.template,o)),{headerHtml:c,footerHtml:x,headerHeight:v,footerHeight:I}}function Li(a){let i="";if(!(a!=null&&a.themeData))return i;const r=a.themeData;if(r.heading&&(i+=`
1
+ import{jsxs as l,jsx as e,Fragment as j}from"react/jsx-runtime";import Ma,{useMemo as M,useState as y,useEffect as me,useCallback as O,useRef as Et}from"react";import{cf as He,fo as $e,gV as Z,gW as Re,gX as je,gY as ee,gZ as Oa,g_ as Pt,by as _a,g$ as Ba,bD as G,cm as Ha,bU as pe,P as $a,h0 as Ra,h1 as ja,h2 as It,h3 as Ft,cI as Ga,h4 as Va,h5 as Ua,h6 as Wa,h7 as qa,h8 as Xa,h9 as Ja,ha as za,hb as Ka,e3 as Ya,hc as Qa,hd as Za,cT as ei,cV as ti,ca as Ge,cW as Ve,cX as ai,d0 as ue,j as St,cK as ii,cN as kt,ch as ri,ci as li,cO as Ue,c1 as ni,c2 as oi,c8 as We,c3 as qe,he as si,hf as ci,aC as di,bN as te,c9 as hi,bH as Xe,bI as Je,bJ as ze,bK as Ke,cY as mi,cZ as pi,bL as J,c_ as At,c$ as Ye,hg as ui,hh as fi,bM as Tt,hi as gi,cu as z,d2 as Lt}from"./runtime-BifHPIs0.js";import{C as xi}from"./calendar-COOOT1Ui.js";import{u as vi}from"./useSupabaseBlobUrl-DrqlnXWA.js";const yi=(a,i,r,o,n,s)=>["epic","activities","infinite",a,i,r,o,n,s],bi=({accountId:a,accountTypeCode:i="CUST",activityStatus:r="All",activityCode:o,associatedToId:n,associatedToType:s,enabled:u=!0})=>{var h;const{captureException:m}=He(),c=$e({queryKey:yi(a,i,r,o,n,s),queryFn:async({pageParam:v=0})=>{const I={account_id:a,account_type_code:i,activity_status:r,page_number:v,...o&&{activity_code:o},...n&&{associated_to_id:n},...s&&{associated_to_type:s}};try{const g=await Re.listActivities(I);if(je(g))throw new ee;if(Oa(g))return{activities:[],totalFound:0,totalCount:0,pageNumber:v,totalPages:0,hasMorePages:!1,status:"success",message:""};if(Pt(g)){const{message:A,statusCode:C}=g;throw new Z(A??"Epic is temporarily unavailable. Please try again.",C)}if(g.status!=="success")throw new Error(g.message||"Failed to fetch activities");return g}catch(g){throw g instanceof ee||g instanceof Z||m({error:g,extra:{pageParam:v,accountId:a,accountTypeCode:i,activityStatus:r}}),g}},getNextPageParam:(v,I)=>{if(v.hasMorePages)return I.length},initialPageParam:0,enabled:u&&!!a,staleTime:300*1e3,gcTime:600*1e3,retry:(v,I)=>I instanceof Z&&v<1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),x=M(()=>{var v;return(v=c.data)!=null&&v.pages?c.data.pages.reduce((I,g)=>[...I,...g.activities||[]],[]):[]},[(h=c.data)==null?void 0:h.pages]);return{...c,activities:x,hasMoreActivities:c.hasNextPage,loadMoreActivities:c.fetchNextPage,isLoadingMore:c.isFetchingNextPage}},Qe=50,Dt=(a,i,r,o)=>["epic","policies","infinite",a,i,r,o],Ni=({clientId:a,policyNumber:i,status:r="All",expirationDateBegins:o,enabled:n=!0,drainAll:s=!1})=>{var u,h;const{captureException:m}=He(),c=$e({queryKey:Dt(a,i,r,o),queryFn:async({pageParam:E=0})=>{const _={client_id:a,page_number:E,...i&&{policy_number:i,policy_number_comparison_type:"Containing"},...r&&{status:r},...o&&{expiration_date_begins:o}};try{const F=await Re.listPolicies(_);if(je(F))throw new ee;if(Pt(F)){const{message:p,statusCode:w}=F;throw new Z(p??"Epic is temporarily unavailable. Please try again.",w)}if(F.status!=="success")throw new Error(F.message||"Failed to fetch policies");return F}catch(F){throw F instanceof ee||F instanceof Z||m({error:F,extra:{pageParam:E,clientId:a}}),F}},getNextPageParam:(E,_)=>E.hasMorePages?_.length:void 0,initialPageParam:0,enabled:n&&!!a,staleTime:300*1e3,gcTime:600*1e3,retry:(E,_)=>_ instanceof Z&&E<1,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),x=M(()=>{var E;return(((E=c.data)==null?void 0:E.pages)??[]).flatMap(_=>_.policies??[])},[(u=c.data)==null?void 0:u.pages]),v=n&&!!a,{hasNextPage:I,isFetchingNextPage:g,isError:A,fetchNextPage:C}=c,$=((h=c.data)==null?void 0:h.pages.length)??0,[X,T]=y(Qe),B=JSON.stringify(Dt(a,i,r,o));me(()=>{T(Qe)},[B]);const L=O(()=>{T(E=>Math.max(E,$)+Qe)},[$]),V=$>=X,R=s&&v&&!V&&!A&&!!I;return me(()=>{!R||g||C({cancelRefetch:!1})},[R,g,C,$]),{...c,policies:x,hasMorePolicies:c.hasNextPage,loadMorePolicies:c.fetchNextPage,isLoadingMore:c.isFetchingNextPage,isDraining:R||s&&v&&!V&&g,isDrainCapped:s&&V&&!!I,extendDrain:L}},wi=a=>{const i=["epic","clients","infinite"];return a&&Object.keys(a).length>0?[...i,a]:i},Ci=({enabled:a=!0,filters:i={}}={})=>{var r;const{toast:o}=_a(),{captureException:n}=He(),s=$e({queryKey:wi(i),queryFn:async({pageParam:h=0})=>{const m={page_number:h,...i};try{const c=await Re.listClients(m);if(je(c))throw new ee;if(c.status!=="success")throw new Error(c.message||"Failed to fetch clients");return c}catch(c){if(c instanceof ee)throw c;const x=c instanceof Error?c.message:"An unknown error occurred";throw o({title:"Couldn't reach Epic right now",description:x,variant:"destructive"}),n({error:c,extra:{pageParam:h,filters:i}}),c}},getNextPageParam:(h,m)=>{if(h.hasMorePages)return m.length},initialPageParam:0,enabled:a,staleTime:300*1e3,gcTime:600*1e3,retry:!1}),u=M(()=>{var h;return(h=s.data)!=null&&h.pages?s.data.pages.reduce((m,c)=>[...m,...c.clients||[]],[]):[]},[(r=s.data)==null?void 0:r.pages]);return{...s,clients:u,hasMoreClients:s.hasNextPage,loadMoreClients:s.fetchNextPage,isLoadingMore:s.isFetchingNextPage}},Ei=()=>{const a=Ba();return l("div",{role:"alert","data-testid":"epic-user-code-missing-alert",className:"rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100",children:[e("p",{className:"font-medium",children:"Your Epic access isn't set up yet"}),e("p",{className:"mt-1 text-amber-800 dark:text-amber-200",children:"Ask your administrator to map your Epic operator code in the Applied Epic integration settings, then reopen this dialog."}),a?e("p",{className:"mt-1 text-amber-800 dark:text-amber-200","data-testid":"epic-user-code-missing-alert-contacts",children:a}):null]})},Mt=(a,i)=>a instanceof Z?a.userMessage:i,Ot=({message:a,onRetry:i,disabled:r=!1,"data-testid":o})=>l("div",{role:"alert","data-testid":o,className:"mt-1 flex items-center justify-between gap-2",children:[e("p",{className:"text-xs text-error min-w-0",children:a}),e(G,{variant:"outline",size:"xs",leftIcon:e(Ha,{className:"h-3 w-3"}),onClick:i,disabled:r,className:"shrink-0","data-testid":o?`${o}-retry`:void 0,children:"Retry"})]}),Pi="Untitled Policy",_t=a=>{const i=$a(a);return Number.isNaN(i.getTime())||i.getFullYear()<1970?"N/A":Ra(i)},Bt=a=>{const i=a.description||Pi;return{value:String(a.policyId),label:i,customRender:l("div",{className:"flex flex-col flex-1 min-w-0",children:[e(pe,{tooltipContent:i,side:"right",children:e("span",{className:"truncate text-sm block",children:i})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:[l("span",{className:"min-w-0 truncate",children:["Policy #: ",a.policyNumber||"N/A"]}),l("span",{className:"flex items-center gap-1 shrink-0 whitespace-nowrap",children:[e(xi,{size:12}),_t(a.effectiveDate)," - ",_t(a.expirationDate)]}),l("span",{className:"min-w-0 truncate",children:["ID: ",a.policyId]})]})]})}},Ii="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==";function Ht(a){return a.startsWith("data:")||a.startsWith("blob:")?!0:a.startsWith("/")&&!a.startsWith("//")}async function Fi(a,i){const r=JSON.parse(JSON.stringify(a)),o=async n=>{for(const s of n){if(!s||typeof s!="object")continue;const u=s;if(typeof u.src=="string"&&u.src.length>0&&!Ht(u.src)){let h=null;try{h=await i(u.src)}catch{h=null}u.src=h&&Ht(h)?h:Ii}Array.isArray(u.objects)&&await o(u.objects)}};return Array.isArray(r.objects)&&await o(r.objects),r}async function Si({json:a,width:i,height:r,multiplier:o=2}){if(typeof document>"u")throw new Error("rasterizeChromeBand requires a browser document");const n=document.createElement("canvas"),s=new ja(n,i,r);try{return s.workspaceWidth=i,s.workspaceHeight=r,await s.loadFromJSON(a,{awaitImages:!0}),s.canvas.renderAll(),s.canvas.toDataURL({format:"png",multiplier:o})}finally{s.dispose()}}const ki={A4:"a4",Letter:"us-letter"};function Ai(a){return a||null}async function $t(a,i,r,o,n){const s=Ai(a);if(!s||!Va(s))return null;const u=Ja(n,r),h=Ua(s,i,u);if(!h)return null;const m=Wa(a,u),c=qa(u),x=await Fi(h,o);return{html:`<img src="${await Si({json:x,width:c,height:m})}" style="display:block;width:100%;" alt="" />`,height:Xa(m)}}async function Ti(a,i,r,o,n,s="portrait",u="A4"){var h,m;let c="",x="",v,I;if(!a)return{headerHtml:c,footerHtml:x};const g=ki[u]??"us-letter";if(i){const C=await $t(a.headerBlock,"header",s,n??o,g);C&&(c=C.html,v=C.height)}if(r){const C=await $t(a.footerBlock,"footer",s,n??o,g);C&&(x=C.html,I=C.height)}if(!a.metadata)return{headerHtml:c,footerHtml:x,headerHeight:v,footerHeight:I};const A=It(a.metadata);return i&&!c&&(h=A.header)!=null&&h.template&&(c=await Ft(A.header.template,o)),r&&!x&&(m=A.footer)!=null&&m.template&&(x=await Ft(A.footer.template,o)),{headerHtml:c,footerHtml:x,headerHeight:v,footerHeight:I}}function Li(a){let i="";if(!(a!=null&&a.themeData))return i;const r=a.themeData;if(r.heading&&(i+=`
2
2
  h1 { color: ${r.heading.h1??"#1a1a1a"} !important; }
3
3
  h2 { color: ${r.heading.h2??"#2d2d2d"} !important; }
4
4
  h3 { color: ${r.heading.h3??"#404040"} !important; }
@@ -1 +1 @@
1
- import{jsxs as a,jsx as l,Fragment as b}from"react/jsx-runtime";import cl,{useState as c,useRef as Xl,useMemo as A,useCallback as g,useEffect as M}from"react";import{cK as $l,cL as Bl,cM as Vl,cN as dl,cO as ql,cP as Kl,cQ as Ql,cR as se,cS as Wl,bU as y,_ as ol,c1 as zl,c2 as Hl,c8 as re,c3 as ce,bD as p,cT as Jl,cU as Yl,cV as Zl,cW as Fe,cX as et,ca as de,bN as T,c9 as lt,bH as ml,bI as hl,bJ as ul,bK as pl,cY as tt,cZ as at,bL as oe,c_ as xl,c$ as Q,d0 as me,aC as it,j as fl,cu as I,d1 as nt,d2 as st}from"./runtime-DTft3h2S.js";import{g as rt}from"./exportFileGeneration-CeVM9_mI.js";const ct=[{value:"PDF",label:"PDF",icon:tt},{value:"DOC",label:"Word Document",icon:at}],dt=[{value:"EXCEL_SINGLE",label:"Single Sheet Excel",icon:xl},{value:"EXCEL_MULTI",label:"Multi Sheet Excel",icon:xl}],vl=(o,w)=>!o||!o.trim()?w!=null&&w.allowEmpty?null:"Please enter an artifact name":o.includes("/")?"Cannot contain forward slashes (/)":o.includes("\\")?"Cannot contain backslashes (\\)":/[<>:"|?*]/.test(o)?'Cannot contain: < > : " | ? *':null,ot=({folder:o,onFolderClick:w,onSelectFolder:he,isLoading:x})=>{var C;const[ue,W]=c(!1);return a("div",{className:"flex items-center gap-3 p-3 hover:bg-neutral08 border-b last:border-b-0 min-h-[56px] cursor-pointer",onMouseEnter:()=>!x&&W(!0),onMouseLeave:()=>W(!1),onClick:()=>w(o),children:[l("div",{className:"flex-shrink-0",children:l(me,{className:"w-5 h-5 text-neutral03"})}),l("div",{className:"flex-1 min-w-0",children:l("div",{className:"text-sm font-medium truncate",children:o.name})}),l("div",{className:"flex items-center gap-2",children:((C=o.folder)==null?void 0:C.acceptsAttachments)!==!1&&l(p,{size:"sm",onClick:v=>{v.stopPropagation(),he(o)},disabled:x,className:fl("h-8 px-2 text-xs transition-opacity duration-200",ue?"opacity-100":"opacity-0"),children:"Select Folder"})})]})},mt=({isOpen:o,onClose:w,originFeature:he,providerType:x,defaultArtifactName:C="",hasTable:ue=!1,fileGenerators:W,providerLabel:v="AMS",artifactContent:pe="",excelOnly:Nl=!1,singleExcelOnly:xe=!1})=>{var Ae;const D=Nl||xe,{isExportBlocked:gl,refuseExport:bl}=$l(),Me=Bl(),{attachToTypes:Te,canListActivities:yl,canListPolicies:wl,clientNameSearch:Cl,isFolderSupported:fe,isFolderRequired:El,isActivityRequiredForExport:E,isActivityScopedToPolicy:h}=Vl(x),kl=Cl==="required",O=Te.includes("Activity")&&yl||E,z=Te.includes("Policy")&&wl||h,Ie=O||z,[N,De]=c(dl(C)),[f,Oe]=c(D?"EXCEL_SINGLE":"PDF"),[i,ve]=c(null),[d,Re]=c(!1),[_e,k]=c(!1),[Ne,H]=c(""),[je,J]=c(null),[Y,Z]=c(1),ge=Xl(null),[Pl,Ue]=c(!1),[u,P]=c([]),[Ge,Xe]=c("Activity"),[r,S]=c(null),[s,R]=c(null),[$e,Be]=c(""),_=ql($e,500),[be,ee]=c(0),[ye,we]=c(0),[j,Ce]=c([]),[U,G]=c([]),[X,le]=c([]),Ee=A(()=>N?vl(N,{allowEmpty:!0}):null,[N]),{clients:$,isLoadingClients:ke,hasMoreClients:te,selectClient:Ve,selectedClient:Pe,currentFolderItems:qe,navigateToFolder:Se,navigateToRoot:Le,isLoadingAttachments:Ke,clearClientSelection:Qe,setSearchText:We,onClientsPageChange:ae,currentClientsPage:B}=Kl({providerType:x,isAmsTab:o,keepClientsEnabled:!0}),Sl=g(()=>{te&&!ke&&ae(B+1)},[te,ke,ae,B]),{activities:V,isLoading:ie,hasMorePages:L}=Ql({providerType:x,clientId:(i==null?void 0:i.id)||"",policyId:h?s==null?void 0:s.id:void 0,offset:be*se.activities,limit:se.activities,enabled:!!i&&O&&(!h||!!s)}),{policies:q,isLoading:ne,hasMorePages:F}=Wl({providerType:x,clientId:(i==null?void 0:i.id)||"",offset:ye*se.policies,limit:se.policies,enabled:!!i&&z}),K=cl.useRef(null);M(()=>{if(K.current===null){K.current=_;return}K.current!==_&&(Ce([]),We(_),K.current=_)},[_,We]),M(()=>{B===0&&$.length>0?Ce($):B>0&&$.length>0&&Ce(e=>{const t=new Set(e.map(m=>m.id)),n=$.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[$,B]),M(()=>{o&&(De(dl(C)),Oe(D?"EXCEL_SINGLE":"PDF"),ve(null),Be(""),H(""),J(null),k(!1),P([]),Z(1),ge.current=null,Ue(!1),Xe(O?"Activity":"Policy"),S(null),R(null),ee(0),we(0),G([]),le([]),Qe(),K.current="",ae(0))},[o,C,Qe,ae,D]),M(()=>{be===0?G(e=>e.length===0&&V.length===0?e:V):V.length>0&&G(e=>{const t=new Set(e.map(m=>m.id)),n=V.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[V,be]),M(()=>{ye===0?le(e=>e.length===0&&q.length===0?e:q):q.length>0&&le(e=>{const t=new Set(e.map(m=>m.id)),n=q.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[q,ye]),M(()=>{Pe&&ve(Pe)},[Pe]);const Ll=g(e=>{Be(e)},[]),Fl=g(e=>{const t=j.find(n=>n.id===e);t&&(ve(t),Ve(t),S(null),R(null),P([]),H(""),J(null),k(!1),ee(0),we(0),G([]),le([]))},[j,Ve]),Al=g(e=>{Xe(e),S(null),R(null)},[]),ze=g(e=>{if(e==="none")S(null);else{const t=U.find(n=>n.id===e);S(t||null)}},[U]),He=g(e=>{if(e==="none")R(null);else{const t=X.find(n=>n.id===e);R(t||null)}h&&(S(null),G([]),ee(0))},[X,h]),Je=g(()=>{L&&!ie&&ee(e=>e+1)},[L,ie]),Ye=g(()=>{F&&!ne&&we(e=>e+1)},[F,ne]),Ml=A(()=>{const e=j.map(t=>({value:t.id,label:t.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[a("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[l(y,{tooltipContent:t.name,side:"right",children:l("span",{className:"truncate text-sm block",children:t.name})}),l(ol,{tags:t.tags})]}),a("span",{className:"text-xs text-neutral03",children:[t.type," \u2022 ",t.status]})]})}));return i&&!j.some(t=>t.id===i.id)&&e.unshift({value:i.id,label:i.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[a("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[l(y,{tooltipContent:i.name,side:"right",children:l("span",{className:"truncate text-sm block",children:i.name})}),l(ol,{tags:i.tags})]}),a("span",{className:"text-xs text-neutral03",children:[i.type," \u2022 ",i.status]})]})}),e},[j,i]),Ze=A(()=>{const e=[];if(E||e.push({value:"none",label:"None"}),U.forEach(t=>{e.push({value:t.id,label:t.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:t.name,side:"right",children:l("span",{className:"truncate text-sm block",children:t.name})}),l(y,{tooltipContent:`Code: ${t.code}`,side:"right",children:a("span",{className:"truncate text-xs text-neutral03 block",children:["Code: ",t.code]})})]})})}),r&&!U.some(t=>t.id===r.id)){const t=E?0:1;e.splice(t,0,{value:r.id,label:r.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:r.name,side:"right",children:l("span",{className:"truncate text-sm block",children:r.name})}),l(y,{tooltipContent:`Code: ${r.code}`,side:"right",children:a("span",{className:"truncate text-xs text-neutral03 block",children:["Code: ",r.code]})})]})})}return e},[U,r,E]),el=A(()=>{const e=[];if(h||e.push({value:"none",label:"None"}),X.forEach(t=>{e.push({value:t.id,label:t.name||"Untitled Policy",customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:t.name||"Untitled Policy",side:"right",children:l("span",{className:"truncate text-sm block",children:t.name||"Untitled Policy"})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:a("span",{children:["Number: ",t.number]})})]})})}),s&&!X.some(t=>t.id===s.id)){const t=h?0:1;e.splice(t,0,{value:s.id,label:s.name||"Untitled Policy",customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:s.name||"Untitled Policy",side:"right",children:l("span",{className:"truncate text-sm block",children:s.name||"Untitled Policy"})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:a("span",{children:["Number: ",s.number]})})]})})}return e},[X,s,h]),ll=async()=>{if(gl){bl();return}Re(!0);try{let e,t;r?(e=r.id,t="Activity"):s&&(e=s.id,t="Policy");let n="";f==="PDF"?n="pdf":f==="DOC"?n="doc":(f==="EXCEL_SINGLE"||f==="EXCEL_MULTI")&&(n="xlsx");const m=await rt({fileType:f,artifactContent:pe,artifactName:N,pdfBlobGenerator:ge.current,fileGenerators:W});if(!m)throw new Error("Failed to generate file");const rl=`${N.trim()}.${n}`;if((await nt.createAttachment({fileName:rl,fileBlob:m,clientId:i.id,attachToId:e,attachToType:t,folderId:fe?je:void 0},x,he)).status)Me.invalidateQueries({queryKey:["ams",x,"folder"],refetchType:"none"}),Me.invalidateQueries({queryKey:["ams",x,"attachments"],refetchType:"none"}),I({title:`Exported to ${v}`,description:`${rl} has been uploaded to ${i.name}`,variant:"success"}),w();else throw new Error("Export failed - server returned unsuccessful status")}catch(e){if(st(e))return;console.error("Export to AMS failed:",e),I({title:"Export Failed",description:e instanceof Error?e.message:"An unknown error occurred",variant:"destructive"})}finally{Re(!1)}},tl=()=>{d||(Z(1),w())},Tl=()=>{const e=vl(N);if(e){I({title:"Validation Error",description:e,variant:"destructive"});return}if(!i){I({title:"Validation Error",description:"Please select a client",variant:"destructive"});return}if(h&&!s){I({title:"Validation Error",description:"Please select a policy",variant:"destructive"});return}if(E&&!r){I({title:"Validation Error",description:"Please select an activity",variant:"destructive"});return}Z(2)},al=()=>{Z(1)},Il=e=>{switch(e){case"PDF":return"PDF";case"DOC":return"Word Document";case"EXCEL_SINGLE":return"Single Sheet Excel";case"EXCEL_MULTI":return"Multi Sheet Excel";default:return e}},Dl=g(e=>{ge.current=e,Ue(!0)},[]),il=Y===2&&!!pe&&!xe,Ol=e=>{e.type==="folder"&&(Se(e.id,e.name),P(t=>{var n;return[...t,{id:e.id,name:e.name,acceptsAttachments:(n=e.folder)==null?void 0:n.acceptsAttachments}]}))},Rl=e=>{const t=[...u.map(n=>n.name),e.name].join("/");H(t),J(e.id),k(!1)},_l=()=>{var e;const t=u.map(m=>m.name).join("/");H(t);const n=u.length>0?(e=u[u.length-1])==null?void 0:e.id:null;J(n||null),k(!1)},jl=()=>{if(u.length>0){const e=u.slice(0,-1);if(P(e),e.length===0)Le();else{const t=e[e.length-1];Se(t.id,t.name)}}},Ul=()=>{P([]),Le()},nl=e=>{if(e===-1)Ul();else{const t=u.slice(0,e+1);if(P(t),t.length>0){const n=t[t.length-1];Se(n.id,n.name)}else Le()}},Gl=A(()=>[{name:"Root",id:"",index:-1},...u.map((e,t)=>({...e,index:t}))],[u]),sl=A(()=>qe.filter(e=>e.type==="folder"),[qe]);return l(zl,{open:o,onOpenChange:tl,children:l(Hl,{className:fl("sm:max-w-[650px] transition-all duration-200 w-full",_e?"sm:max-w-[650px] w-[70vw] h-[70vh] max-h-[700px] flex flex-col gap-1":"",il?"sm:max-w-[1400px] w-[90vw] h-[90vh] p-0 gap-0 flex flex-col":""),closeOnOutsideClick:!1,children:_e?a(b,{children:[a(re,{className:"flex-shrink-0 px-6 pt-6",children:[l(ce,{children:"Select destination folder"}),i&&a("div",{className:"text-sm text-neutral03 mt-1",children:["Client: ",i.name]})]}),l("div",{className:"flex-1 flex flex-col gap-1 p-4 min-h-0",children:a("div",{className:"flex-1 flex flex-col border rounded-lg min-h-0 overflow-hidden",children:[l("div",{className:"flex-shrink-0 flex items-center justify-between p-3 border-b bg-neutral08 min-h-[56px]",children:a("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[u.length>0&&l(p,{variant:"ghost",size:"sm",onClick:jl,className:"h-6 w-6 p-0 flex-shrink-0",children:l(Jl,{className:"w-4 h-4"})}),l("button",{onClick:()=>nl(-1),className:"hover:text-primary text-neutral03 flex-shrink-0 p-1 rounded hover:bg-neutral07",title:v,children:l(Yl,{className:"w-4 h-4"})}),Gl.filter(e=>e.name!=="Root").map((e,t)=>a(cl.Fragment,{children:[l(Zl,{className:"w-4 h-4 text-neutral04 flex-shrink-0"}),l("button",{onClick:()=>nl(e.index),className:"text-sm hover:text-primary truncate",children:e.name})]},e.id||t))]})}),l("div",{className:"flex-1 overflow-y-auto",children:Ke?l("div",{className:"space-y-0",children:Array(5).fill(0).map((e,t)=>a("div",{className:"flex items-center gap-3 p-3 border-b last:border-b-0 min-h-[56px]",children:[l(Fe,{className:"w-5 h-5 rounded-md"}),l(Fe,{className:"flex-1 h-4 rounded-md"}),l(Fe,{className:"w-24 h-8 rounded-md"})]},t))}):sl.length===0?a("div",{className:"flex flex-col items-center justify-center py-8 h-full",children:[l(et,{className:"w-8 h-8 text-neutral03 mb-2"}),l("div",{className:"text-sm text-neutral03",children:"No folders in this location"})]}):l("div",{className:"space-y-0",children:sl.map(e=>l(ot,{folder:e,onFolderClick:Ol,onSelectFolder:Rl,isLoading:Ke},e.id))})})]})}),a(de,{className:"flex-shrink-0 px-6 pb-6 pt-4 border-t border-border-primary",children:[l(p,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),l(p,{onClick:_l,disabled:u.length===0||((Ae=u[u.length-1])==null?void 0:Ae.acceptsAttachments)===!1,children:"Select Folder"})]})]}):Y===1?a(b,{children:[l(re,{className:"px-6 pt-6 flex-shrink-0",children:a(ce,{children:["Export to ",v]})}),a("div",{className:"px-6 py-4 flex-1 min-h-0 min-w-0 overflow-hidden",children:[a("div",{className:"grid grid-cols-[1fr_140px] gap-3 pb-4",children:[a("div",{className:"space-y-2",children:[l(T,{htmlFor:"artifact-name",className:"text-sm font-medium text-neutral-700",children:"Artifact name"}),l(lt,{id:"artifact-name",size:"sm",value:N,onChange:e=>De(e.target.value),placeholder:"Enter artifact name",disabled:d,required:!0,className:"h-10",error:!!Ee,errorMessage:Ee||void 0})]}),a("div",{className:"space-y-2",children:[l(T,{htmlFor:"file-type",className:"text-sm font-medium text-neutral-700",children:"Type"}),a(ml,{value:f,onValueChange:e=>Oe(e),children:[l(hl,{id:"file-type",disabled:d,className:"h-10 w-full",children:l(ul,{placeholder:"Select file type"})}),a(pl,{children:[!D&&ct.map(e=>l(oe,{value:e.value,children:a("div",{className:"flex items-center gap-2",children:[l(e.icon,{className:"h-4 w-4 flex-shrink-0"}),l("span",{children:e.label})]})},e.value)),(ue||D)&&dt.filter(e=>!xe||e.value==="EXCEL_SINGLE").map(e=>l(oe,{value:e.value,children:a("div",{className:"flex items-center gap-2",children:[l(e.icon,{className:"h-4 w-4 flex-shrink-0"}),l("span",{children:e.label})]})},e.value))]})]})]})]}),l("div",{className:"border-t border-gray-200 my-2 dark:border-neutral-800"}),a("div",{className:"space-y-2 pb-2 pt-3",children:[l(T,{htmlFor:"client-select",className:"text-sm font-medium text-neutral-700",children:"Attached To"}),l(Q,{id:"client-select",options:Ml,value:(i==null?void 0:i.id)||"",onChange:Fl,placeholder:"Select Client",searchPlaceholder:"Search clients...",emptyMessage:kl&&!$e?"Type a client name to search":"No clients found",disabled:d,isLoadingItems:ke,hasMore:te,onLoadMore:te?Sl:void 0,onSearchChange:Ll,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]}),Ie&&h?a("div",{className:"space-y-3 pb-4",children:[a("div",{className:"space-y-2",children:[l(T,{className:"text-sm font-medium text-neutral-700",children:"Policy"}),l(Q,{id:"policy-select",options:el,value:(s==null?void 0:s.id)||"",onChange:He,placeholder:"Select policy...",searchPlaceholder:"Search policies...",emptyMessage:"No policies found",disabled:d||!i,isLoadingItems:ne,onLoadMore:F?Ye:void 0,hasMore:F,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]}),a("div",{className:"space-y-2",children:[l(T,{className:"text-sm font-medium text-neutral-700",children:"Activity"}),l(Q,{id:"activity-select",options:Ze,value:(r==null?void 0:r.id)||"",onChange:ze,placeholder:s?"Select activity...":"Select a policy first",searchPlaceholder:"Search activities...",emptyMessage:"No activities found",disabled:d||!i||!s,isLoadingItems:ie,onLoadMore:L?Je:void 0,hasMore:L,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]})]}):Ie?a("div",{className:"grid grid-cols-[140px_1fr] gap-3 pb-4",children:[l("div",{className:"space-y-2",children:a(ml,{value:Ge,onValueChange:Al,disabled:d||!i,children:[l(hl,{id:"related-entity",className:"h-10 w-full",children:l(ul,{placeholder:"Select type"})}),a(pl,{children:[O&&l(oe,{value:"Activity",children:"Activity"}),z&&l(oe,{value:"Policy",children:"Policy"})]})]})}),l("div",{className:"space-y-2 min-w-0",children:Ge==="Activity"&&O?l("div",{className:"w-full min-w-0",children:l(Q,{id:"activity-select",options:Ze,value:(r==null?void 0:r.id)||"none",onChange:ze,placeholder:"Choose...",searchPlaceholder:"Search activities...",emptyMessage:"No activities found",disabled:d||!i,isLoadingItems:ie,onLoadMore:L?Je:void 0,hasMore:L,showSearch:!0,className:"w-full h-10 max-w-full",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})}):z?l("div",{className:"w-full min-w-0",children:l(Q,{id:"policy-select",options:el,value:(s==null?void 0:s.id)||"none",onChange:He,placeholder:"Choose...",searchPlaceholder:"Search policies...",emptyMessage:"No policies found",disabled:d||!i,isLoadingItems:ne,onLoadMore:F?Ye:void 0,hasMore:F,showSearch:!0,className:"w-full h-10 max-w-full",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})}):null})]}):null,fe&&a(b,{children:[l("div",{className:"border-t border-gray-200 my-2 dark:border-neutral-800"}),a("div",{className:"space-y-2 pt-3",children:[l(T,{htmlFor:"destination-folder",className:"text-sm font-medium text-neutral-700",children:"Destination folder"}),a("div",{className:"flex items-center gap-2",children:[l("div",{className:"flex-1 h-10 px-3 py-2 border border-border-primary rounded-md bg-white flex items-center gap-2 dark:bg-neutral-900",children:Ne?a(b,{children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm truncate",children:Ne})]}):a(b,{children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm text-neutral03",children:v})]})}),l(p,{variant:"outline",onClick:()=>k(!0),disabled:d||!i,className:"h-10",children:"Browse"})]})]})]})]}),a(de,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[l(p,{variant:"outline",onClick:tl,disabled:d,children:"Cancel"}),l(p,{onClick:Tl,disabled:d||!!Ee||!i||El&&!je||h&&!s||E&&!r,children:"Next"})]})]}):Y===2?il?a(b,{children:[l(re,{className:"px-6 py-4 border-b border-border-primary flex-shrink-0",children:l(ce,{children:"Export Preview"})}),l(it,{markdownContent:pe,documentName:N,isActive:o&&Y===2,isExporting:d,onGeneratePdfBlobReady:f==="PDF"?Dl:void 0}),a(de,{className:"px-6 py-4 border-t border-border-primary flex-shrink-0",children:[l(p,{variant:"outline",onClick:al,disabled:d,children:"Back"}),l(p,{onClick:ll,disabled:f==="PDF"?!Pl:!1,isLoading:d,children:d?"Exporting...":`Export to ${v}`})]})]}):a(b,{children:[l(re,{className:"px-6 pt-6 flex-shrink-0",children:a(ce,{children:["Confirm Export to ",v]})}),l("div",{className:"px-6 py-4 flex-1 min-h-0",children:a("div",{className:"space-y-4",children:[l("p",{className:"text-sm text-neutral03",children:"Please review the export details below:"}),a("div",{className:"border border-border-primary rounded-lg p-4 space-y-3 bg-neutral08",children:[a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"File Name"}),a("span",{className:"text-sm text-right",children:[N,".",f.toLowerCase().replace("excel_single","xlsx").replace("excel_multi","xlsx").replace("doc","doc")]})]}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"File Type"}),l("span",{className:"text-sm",children:Il(f)})]}),l("div",{className:"border-t border-border-primary my-2"}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Client"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:i==null?void 0:i.name})]}),h&&s&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Policy"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:s.name||"N/A"})]}),h&&r&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Activity"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:r.name})]}),!h&&(r||s)&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:r?"Activity":"Policy"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:r?r.name:(s==null?void 0:s.name)||"N/A"})]}),fe&&a(b,{children:[l("div",{className:"border-t border-border-primary my-2"}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Destination Folder"}),a("div",{className:"flex items-center gap-2",children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm text-right",children:Ne||v})]})]})]})]})]})}),a(de,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[l(p,{variant:"outline",onClick:al,disabled:d,children:"Back"}),l(p,{onClick:ll,isLoading:d,disabled:d,children:"Export"})]})]}):null})})};export{mt as ExportToAmsDialog};
1
+ import{jsxs as a,jsx as l,Fragment as b}from"react/jsx-runtime";import cl,{useState as c,useRef as Xl,useMemo as A,useCallback as g,useEffect as M}from"react";import{cK as $l,cL as Bl,cM as Vl,cN as dl,cO as ql,cP as Kl,cQ as Ql,cR as se,cS as Wl,bU as y,_ as ol,c1 as zl,c2 as Hl,c8 as re,c3 as ce,bD as p,cT as Jl,cU as Yl,cV as Zl,cW as Fe,cX as et,ca as de,bN as T,c9 as lt,bH as ml,bI as hl,bJ as ul,bK as pl,cY as tt,cZ as at,bL as oe,c_ as xl,c$ as Q,d0 as me,aC as it,j as fl,cu as I,d1 as nt,d2 as st}from"./runtime-BifHPIs0.js";import{g as rt}from"./exportFileGeneration-jv6-MI8B.js";const ct=[{value:"PDF",label:"PDF",icon:tt},{value:"DOC",label:"Word Document",icon:at}],dt=[{value:"EXCEL_SINGLE",label:"Single Sheet Excel",icon:xl},{value:"EXCEL_MULTI",label:"Multi Sheet Excel",icon:xl}],vl=(o,w)=>!o||!o.trim()?w!=null&&w.allowEmpty?null:"Please enter an artifact name":o.includes("/")?"Cannot contain forward slashes (/)":o.includes("\\")?"Cannot contain backslashes (\\)":/[<>:"|?*]/.test(o)?'Cannot contain: < > : " | ? *':null,ot=({folder:o,onFolderClick:w,onSelectFolder:he,isLoading:x})=>{var C;const[ue,W]=c(!1);return a("div",{className:"flex items-center gap-3 p-3 hover:bg-neutral08 border-b last:border-b-0 min-h-[56px] cursor-pointer",onMouseEnter:()=>!x&&W(!0),onMouseLeave:()=>W(!1),onClick:()=>w(o),children:[l("div",{className:"flex-shrink-0",children:l(me,{className:"w-5 h-5 text-neutral03"})}),l("div",{className:"flex-1 min-w-0",children:l("div",{className:"text-sm font-medium truncate",children:o.name})}),l("div",{className:"flex items-center gap-2",children:((C=o.folder)==null?void 0:C.acceptsAttachments)!==!1&&l(p,{size:"sm",onClick:v=>{v.stopPropagation(),he(o)},disabled:x,className:fl("h-8 px-2 text-xs transition-opacity duration-200",ue?"opacity-100":"opacity-0"),children:"Select Folder"})})]})},mt=({isOpen:o,onClose:w,originFeature:he,providerType:x,defaultArtifactName:C="",hasTable:ue=!1,fileGenerators:W,providerLabel:v="AMS",artifactContent:pe="",excelOnly:Nl=!1,singleExcelOnly:xe=!1})=>{var Ae;const D=Nl||xe,{isExportBlocked:gl,refuseExport:bl}=$l(),Me=Bl(),{attachToTypes:Te,canListActivities:yl,canListPolicies:wl,clientNameSearch:Cl,isFolderSupported:fe,isFolderRequired:El,isActivityRequiredForExport:E,isActivityScopedToPolicy:h}=Vl(x),kl=Cl==="required",O=Te.includes("Activity")&&yl||E,z=Te.includes("Policy")&&wl||h,Ie=O||z,[N,De]=c(dl(C)),[f,Oe]=c(D?"EXCEL_SINGLE":"PDF"),[i,ve]=c(null),[d,Re]=c(!1),[_e,k]=c(!1),[Ne,H]=c(""),[je,J]=c(null),[Y,Z]=c(1),ge=Xl(null),[Pl,Ue]=c(!1),[u,P]=c([]),[Ge,Xe]=c("Activity"),[r,S]=c(null),[s,R]=c(null),[$e,Be]=c(""),_=ql($e,500),[be,ee]=c(0),[ye,we]=c(0),[j,Ce]=c([]),[U,G]=c([]),[X,le]=c([]),Ee=A(()=>N?vl(N,{allowEmpty:!0}):null,[N]),{clients:$,isLoadingClients:ke,hasMoreClients:te,selectClient:Ve,selectedClient:Pe,currentFolderItems:qe,navigateToFolder:Se,navigateToRoot:Le,isLoadingAttachments:Ke,clearClientSelection:Qe,setSearchText:We,onClientsPageChange:ae,currentClientsPage:B}=Kl({providerType:x,isAmsTab:o,keepClientsEnabled:!0}),Sl=g(()=>{te&&!ke&&ae(B+1)},[te,ke,ae,B]),{activities:V,isLoading:ie,hasMorePages:L}=Ql({providerType:x,clientId:(i==null?void 0:i.id)||"",policyId:h?s==null?void 0:s.id:void 0,offset:be*se.activities,limit:se.activities,enabled:!!i&&O&&(!h||!!s)}),{policies:q,isLoading:ne,hasMorePages:F}=Wl({providerType:x,clientId:(i==null?void 0:i.id)||"",offset:ye*se.policies,limit:se.policies,enabled:!!i&&z}),K=cl.useRef(null);M(()=>{if(K.current===null){K.current=_;return}K.current!==_&&(Ce([]),We(_),K.current=_)},[_,We]),M(()=>{B===0&&$.length>0?Ce($):B>0&&$.length>0&&Ce(e=>{const t=new Set(e.map(m=>m.id)),n=$.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[$,B]),M(()=>{o&&(De(dl(C)),Oe(D?"EXCEL_SINGLE":"PDF"),ve(null),Be(""),H(""),J(null),k(!1),P([]),Z(1),ge.current=null,Ue(!1),Xe(O?"Activity":"Policy"),S(null),R(null),ee(0),we(0),G([]),le([]),Qe(),K.current="",ae(0))},[o,C,Qe,ae,D]),M(()=>{be===0?G(e=>e.length===0&&V.length===0?e:V):V.length>0&&G(e=>{const t=new Set(e.map(m=>m.id)),n=V.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[V,be]),M(()=>{ye===0?le(e=>e.length===0&&q.length===0?e:q):q.length>0&&le(e=>{const t=new Set(e.map(m=>m.id)),n=q.filter(m=>!t.has(m.id));return n.length===0?e:[...e,...n]})},[q,ye]),M(()=>{Pe&&ve(Pe)},[Pe]);const Ll=g(e=>{Be(e)},[]),Fl=g(e=>{const t=j.find(n=>n.id===e);t&&(ve(t),Ve(t),S(null),R(null),P([]),H(""),J(null),k(!1),ee(0),we(0),G([]),le([]))},[j,Ve]),Al=g(e=>{Xe(e),S(null),R(null)},[]),ze=g(e=>{if(e==="none")S(null);else{const t=U.find(n=>n.id===e);S(t||null)}},[U]),He=g(e=>{if(e==="none")R(null);else{const t=X.find(n=>n.id===e);R(t||null)}h&&(S(null),G([]),ee(0))},[X,h]),Je=g(()=>{L&&!ie&&ee(e=>e+1)},[L,ie]),Ye=g(()=>{F&&!ne&&we(e=>e+1)},[F,ne]),Ml=A(()=>{const e=j.map(t=>({value:t.id,label:t.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[a("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[l(y,{tooltipContent:t.name,side:"right",children:l("span",{className:"truncate text-sm block",children:t.name})}),l(ol,{tags:t.tags})]}),a("span",{className:"text-xs text-neutral03",children:[t.type," \u2022 ",t.status]})]})}));return i&&!j.some(t=>t.id===i.id)&&e.unshift({value:i.id,label:i.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[a("div",{className:"flex items-center gap-2 flex-wrap min-w-0",children:[l(y,{tooltipContent:i.name,side:"right",children:l("span",{className:"truncate text-sm block",children:i.name})}),l(ol,{tags:i.tags})]}),a("span",{className:"text-xs text-neutral03",children:[i.type," \u2022 ",i.status]})]})}),e},[j,i]),Ze=A(()=>{const e=[];if(E||e.push({value:"none",label:"None"}),U.forEach(t=>{e.push({value:t.id,label:t.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:t.name,side:"right",children:l("span",{className:"truncate text-sm block",children:t.name})}),l(y,{tooltipContent:`Code: ${t.code}`,side:"right",children:a("span",{className:"truncate text-xs text-neutral03 block",children:["Code: ",t.code]})})]})})}),r&&!U.some(t=>t.id===r.id)){const t=E?0:1;e.splice(t,0,{value:r.id,label:r.name,customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:r.name,side:"right",children:l("span",{className:"truncate text-sm block",children:r.name})}),l(y,{tooltipContent:`Code: ${r.code}`,side:"right",children:a("span",{className:"truncate text-xs text-neutral03 block",children:["Code: ",r.code]})})]})})}return e},[U,r,E]),el=A(()=>{const e=[];if(h||e.push({value:"none",label:"None"}),X.forEach(t=>{e.push({value:t.id,label:t.name||"Untitled Policy",customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:t.name||"Untitled Policy",side:"right",children:l("span",{className:"truncate text-sm block",children:t.name||"Untitled Policy"})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:a("span",{children:["Number: ",t.number]})})]})})}),s&&!X.some(t=>t.id===s.id)){const t=h?0:1;e.splice(t,0,{value:s.id,label:s.name||"Untitled Policy",customRender:a("div",{className:"flex flex-col flex-1 min-w-0",children:[l(y,{tooltipContent:s.name||"Untitled Policy",side:"right",children:l("span",{className:"truncate text-sm block",children:s.name||"Untitled Policy"})}),l("div",{className:"flex gap-3 text-xs text-neutral03",children:a("span",{children:["Number: ",s.number]})})]})})}return e},[X,s,h]),ll=async()=>{if(gl){bl();return}Re(!0);try{let e,t;r?(e=r.id,t="Activity"):s&&(e=s.id,t="Policy");let n="";f==="PDF"?n="pdf":f==="DOC"?n="doc":(f==="EXCEL_SINGLE"||f==="EXCEL_MULTI")&&(n="xlsx");const m=await rt({fileType:f,artifactContent:pe,artifactName:N,pdfBlobGenerator:ge.current,fileGenerators:W});if(!m)throw new Error("Failed to generate file");const rl=`${N.trim()}.${n}`;if((await nt.createAttachment({fileName:rl,fileBlob:m,clientId:i.id,attachToId:e,attachToType:t,folderId:fe?je:void 0},x,he)).status)Me.invalidateQueries({queryKey:["ams",x,"folder"],refetchType:"none"}),Me.invalidateQueries({queryKey:["ams",x,"attachments"],refetchType:"none"}),I({title:`Exported to ${v}`,description:`${rl} has been uploaded to ${i.name}`,variant:"success"}),w();else throw new Error("Export failed - server returned unsuccessful status")}catch(e){if(st(e))return;console.error("Export to AMS failed:",e),I({title:"Export Failed",description:e instanceof Error?e.message:"An unknown error occurred",variant:"destructive"})}finally{Re(!1)}},tl=()=>{d||(Z(1),w())},Tl=()=>{const e=vl(N);if(e){I({title:"Validation Error",description:e,variant:"destructive"});return}if(!i){I({title:"Validation Error",description:"Please select a client",variant:"destructive"});return}if(h&&!s){I({title:"Validation Error",description:"Please select a policy",variant:"destructive"});return}if(E&&!r){I({title:"Validation Error",description:"Please select an activity",variant:"destructive"});return}Z(2)},al=()=>{Z(1)},Il=e=>{switch(e){case"PDF":return"PDF";case"DOC":return"Word Document";case"EXCEL_SINGLE":return"Single Sheet Excel";case"EXCEL_MULTI":return"Multi Sheet Excel";default:return e}},Dl=g(e=>{ge.current=e,Ue(!0)},[]),il=Y===2&&!!pe&&!xe,Ol=e=>{e.type==="folder"&&(Se(e.id,e.name),P(t=>{var n;return[...t,{id:e.id,name:e.name,acceptsAttachments:(n=e.folder)==null?void 0:n.acceptsAttachments}]}))},Rl=e=>{const t=[...u.map(n=>n.name),e.name].join("/");H(t),J(e.id),k(!1)},_l=()=>{var e;const t=u.map(m=>m.name).join("/");H(t);const n=u.length>0?(e=u[u.length-1])==null?void 0:e.id:null;J(n||null),k(!1)},jl=()=>{if(u.length>0){const e=u.slice(0,-1);if(P(e),e.length===0)Le();else{const t=e[e.length-1];Se(t.id,t.name)}}},Ul=()=>{P([]),Le()},nl=e=>{if(e===-1)Ul();else{const t=u.slice(0,e+1);if(P(t),t.length>0){const n=t[t.length-1];Se(n.id,n.name)}else Le()}},Gl=A(()=>[{name:"Root",id:"",index:-1},...u.map((e,t)=>({...e,index:t}))],[u]),sl=A(()=>qe.filter(e=>e.type==="folder"),[qe]);return l(zl,{open:o,onOpenChange:tl,children:l(Hl,{className:fl("sm:max-w-[650px] transition-all duration-200 w-full",_e?"sm:max-w-[650px] w-[70vw] h-[70vh] max-h-[700px] flex flex-col gap-1":"",il?"sm:max-w-[1400px] w-[90vw] h-[90vh] p-0 gap-0 flex flex-col":""),closeOnOutsideClick:!1,children:_e?a(b,{children:[a(re,{className:"flex-shrink-0 px-6 pt-6",children:[l(ce,{children:"Select destination folder"}),i&&a("div",{className:"text-sm text-neutral03 mt-1",children:["Client: ",i.name]})]}),l("div",{className:"flex-1 flex flex-col gap-1 p-4 min-h-0",children:a("div",{className:"flex-1 flex flex-col border rounded-lg min-h-0 overflow-hidden",children:[l("div",{className:"flex-shrink-0 flex items-center justify-between p-3 border-b bg-neutral08 min-h-[56px]",children:a("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[u.length>0&&l(p,{variant:"ghost",size:"sm",onClick:jl,className:"h-6 w-6 p-0 flex-shrink-0",children:l(Jl,{className:"w-4 h-4"})}),l("button",{onClick:()=>nl(-1),className:"hover:text-primary text-neutral03 flex-shrink-0 p-1 rounded hover:bg-neutral07",title:v,children:l(Yl,{className:"w-4 h-4"})}),Gl.filter(e=>e.name!=="Root").map((e,t)=>a(cl.Fragment,{children:[l(Zl,{className:"w-4 h-4 text-neutral04 flex-shrink-0"}),l("button",{onClick:()=>nl(e.index),className:"text-sm hover:text-primary truncate",children:e.name})]},e.id||t))]})}),l("div",{className:"flex-1 overflow-y-auto",children:Ke?l("div",{className:"space-y-0",children:Array(5).fill(0).map((e,t)=>a("div",{className:"flex items-center gap-3 p-3 border-b last:border-b-0 min-h-[56px]",children:[l(Fe,{className:"w-5 h-5 rounded-md"}),l(Fe,{className:"flex-1 h-4 rounded-md"}),l(Fe,{className:"w-24 h-8 rounded-md"})]},t))}):sl.length===0?a("div",{className:"flex flex-col items-center justify-center py-8 h-full",children:[l(et,{className:"w-8 h-8 text-neutral03 mb-2"}),l("div",{className:"text-sm text-neutral03",children:"No folders in this location"})]}):l("div",{className:"space-y-0",children:sl.map(e=>l(ot,{folder:e,onFolderClick:Ol,onSelectFolder:Rl,isLoading:Ke},e.id))})})]})}),a(de,{className:"flex-shrink-0 px-6 pb-6 pt-4 border-t border-border-primary",children:[l(p,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),l(p,{onClick:_l,disabled:u.length===0||((Ae=u[u.length-1])==null?void 0:Ae.acceptsAttachments)===!1,children:"Select Folder"})]})]}):Y===1?a(b,{children:[l(re,{className:"px-6 pt-6 flex-shrink-0",children:a(ce,{children:["Export to ",v]})}),a("div",{className:"px-6 py-4 flex-1 min-h-0 min-w-0 overflow-hidden",children:[a("div",{className:"grid grid-cols-[1fr_140px] gap-3 pb-4",children:[a("div",{className:"space-y-2",children:[l(T,{htmlFor:"artifact-name",className:"text-sm font-medium text-neutral-700",children:"Artifact name"}),l(lt,{id:"artifact-name",size:"sm",value:N,onChange:e=>De(e.target.value),placeholder:"Enter artifact name",disabled:d,required:!0,className:"h-10",error:!!Ee,errorMessage:Ee||void 0})]}),a("div",{className:"space-y-2",children:[l(T,{htmlFor:"file-type",className:"text-sm font-medium text-neutral-700",children:"Type"}),a(ml,{value:f,onValueChange:e=>Oe(e),children:[l(hl,{id:"file-type",disabled:d,className:"h-10 w-full",children:l(ul,{placeholder:"Select file type"})}),a(pl,{children:[!D&&ct.map(e=>l(oe,{value:e.value,children:a("div",{className:"flex items-center gap-2",children:[l(e.icon,{className:"h-4 w-4 flex-shrink-0"}),l("span",{children:e.label})]})},e.value)),(ue||D)&&dt.filter(e=>!xe||e.value==="EXCEL_SINGLE").map(e=>l(oe,{value:e.value,children:a("div",{className:"flex items-center gap-2",children:[l(e.icon,{className:"h-4 w-4 flex-shrink-0"}),l("span",{children:e.label})]})},e.value))]})]})]})]}),l("div",{className:"border-t border-gray-200 my-2 dark:border-neutral-800"}),a("div",{className:"space-y-2 pb-2 pt-3",children:[l(T,{htmlFor:"client-select",className:"text-sm font-medium text-neutral-700",children:"Attached To"}),l(Q,{id:"client-select",options:Ml,value:(i==null?void 0:i.id)||"",onChange:Fl,placeholder:"Select Client",searchPlaceholder:"Search clients...",emptyMessage:kl&&!$e?"Type a client name to search":"No clients found",disabled:d,isLoadingItems:ke,hasMore:te,onLoadMore:te?Sl:void 0,onSearchChange:Ll,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]}),Ie&&h?a("div",{className:"space-y-3 pb-4",children:[a("div",{className:"space-y-2",children:[l(T,{className:"text-sm font-medium text-neutral-700",children:"Policy"}),l(Q,{id:"policy-select",options:el,value:(s==null?void 0:s.id)||"",onChange:He,placeholder:"Select policy...",searchPlaceholder:"Search policies...",emptyMessage:"No policies found",disabled:d||!i,isLoadingItems:ne,onLoadMore:F?Ye:void 0,hasMore:F,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]}),a("div",{className:"space-y-2",children:[l(T,{className:"text-sm font-medium text-neutral-700",children:"Activity"}),l(Q,{id:"activity-select",options:Ze,value:(r==null?void 0:r.id)||"",onChange:ze,placeholder:s?"Select activity...":"Select a policy first",searchPlaceholder:"Search activities...",emptyMessage:"No activities found",disabled:d||!i||!s,isLoadingItems:ie,onLoadMore:L?Je:void 0,hasMore:L,showSearch:!0,className:"w-full h-10",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})]})]}):Ie?a("div",{className:"grid grid-cols-[140px_1fr] gap-3 pb-4",children:[l("div",{className:"space-y-2",children:a(ml,{value:Ge,onValueChange:Al,disabled:d||!i,children:[l(hl,{id:"related-entity",className:"h-10 w-full",children:l(ul,{placeholder:"Select type"})}),a(pl,{children:[O&&l(oe,{value:"Activity",children:"Activity"}),z&&l(oe,{value:"Policy",children:"Policy"})]})]})}),l("div",{className:"space-y-2 min-w-0",children:Ge==="Activity"&&O?l("div",{className:"w-full min-w-0",children:l(Q,{id:"activity-select",options:Ze,value:(r==null?void 0:r.id)||"none",onChange:ze,placeholder:"Choose...",searchPlaceholder:"Search activities...",emptyMessage:"No activities found",disabled:d||!i,isLoadingItems:ie,onLoadMore:L?Je:void 0,hasMore:L,showSearch:!0,className:"w-full h-10 max-w-full",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})}):z?l("div",{className:"w-full min-w-0",children:l(Q,{id:"policy-select",options:el,value:(s==null?void 0:s.id)||"none",onChange:He,placeholder:"Choose...",searchPlaceholder:"Search policies...",emptyMessage:"No policies found",disabled:d||!i,isLoadingItems:ne,onLoadMore:F?Ye:void 0,hasMore:F,showSearch:!0,className:"w-full h-10 max-w-full",popoverProps:{avoidCollisions:!0,sideOffset:4,align:"start",usePortal:!0}})}):null})]}):null,fe&&a(b,{children:[l("div",{className:"border-t border-gray-200 my-2 dark:border-neutral-800"}),a("div",{className:"space-y-2 pt-3",children:[l(T,{htmlFor:"destination-folder",className:"text-sm font-medium text-neutral-700",children:"Destination folder"}),a("div",{className:"flex items-center gap-2",children:[l("div",{className:"flex-1 h-10 px-3 py-2 border border-border-primary rounded-md bg-white flex items-center gap-2 dark:bg-neutral-900",children:Ne?a(b,{children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm truncate",children:Ne})]}):a(b,{children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm text-neutral03",children:v})]})}),l(p,{variant:"outline",onClick:()=>k(!0),disabled:d||!i,className:"h-10",children:"Browse"})]})]})]})]}),a(de,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[l(p,{variant:"outline",onClick:tl,disabled:d,children:"Cancel"}),l(p,{onClick:Tl,disabled:d||!!Ee||!i||El&&!je||h&&!s||E&&!r,children:"Next"})]})]}):Y===2?il?a(b,{children:[l(re,{className:"px-6 py-4 border-b border-border-primary flex-shrink-0",children:l(ce,{children:"Export Preview"})}),l(it,{markdownContent:pe,documentName:N,isActive:o&&Y===2,isExporting:d,onGeneratePdfBlobReady:f==="PDF"?Dl:void 0}),a(de,{className:"px-6 py-4 border-t border-border-primary flex-shrink-0",children:[l(p,{variant:"outline",onClick:al,disabled:d,children:"Back"}),l(p,{onClick:ll,disabled:f==="PDF"?!Pl:!1,isLoading:d,children:d?"Exporting...":`Export to ${v}`})]})]}):a(b,{children:[l(re,{className:"px-6 pt-6 flex-shrink-0",children:a(ce,{children:["Confirm Export to ",v]})}),l("div",{className:"px-6 py-4 flex-1 min-h-0",children:a("div",{className:"space-y-4",children:[l("p",{className:"text-sm text-neutral03",children:"Please review the export details below:"}),a("div",{className:"border border-border-primary rounded-lg p-4 space-y-3 bg-neutral08",children:[a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"File Name"}),a("span",{className:"text-sm text-right",children:[N,".",f.toLowerCase().replace("excel_single","xlsx").replace("excel_multi","xlsx").replace("doc","doc")]})]}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"File Type"}),l("span",{className:"text-sm",children:Il(f)})]}),l("div",{className:"border-t border-border-primary my-2"}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Client"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:i==null?void 0:i.name})]}),h&&s&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Policy"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:s.name||"N/A"})]}),h&&r&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Activity"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:r.name})]}),!h&&(r||s)&&a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:r?"Activity":"Policy"}),l("span",{className:"text-sm text-right max-w-[250px] truncate",children:r?r.name:(s==null?void 0:s.name)||"N/A"})]}),fe&&a(b,{children:[l("div",{className:"border-t border-border-primary my-2"}),a("div",{className:"flex justify-between items-start",children:[l("span",{className:"text-sm font-medium text-neutral03",children:"Destination Folder"}),a("div",{className:"flex items-center gap-2",children:[l(me,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),l("span",{className:"text-sm text-right",children:Ne||v})]})]})]})]})]})}),a(de,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[l(p,{variant:"outline",onClick:al,disabled:d,children:"Back"}),l(p,{onClick:ll,isLoading:d,disabled:d,children:"Export"})]})]}):null})})};export{mt as ExportToAmsDialog};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as l,Fragment as N}from"react/jsx-runtime";import te,{useState as s,useRef as Le,useMemo as B,useCallback as u}from"react";import{cL as De,cK as Fe,cN as ne,d5 as Se,d6 as Te,c1 as Me,c2 as Pe,c8 as T,c3 as M,bD as c,cT as Oe,cU as _e,cV as Ge,cW as $,cX as Ie,ca as P,bN as A,c9 as je,bH as Xe,bI as Be,bJ as $e,bK as Ae,cY as Ue,cZ as ze,bL as se,c_ as ce,d0 as U,d7 as de,aC as Ke,j as oe,d8 as Re,cu as z,d9 as Ve,da as We,d2 as qe}from"./runtime-DTft3h2S.js";import{g as He}from"./exportFileGeneration-CeVM9_mI.js";const Je=[{value:"PDF",label:"PDF",icon:Ue},{value:"DOC",label:"Word Document",icon:ze}],Qe=[{value:"EXCEL_SINGLE",label:"Single Sheet Excel",icon:ce},{value:"EXCEL_MULTI",label:"Multi Sheet Excel",icon:ce}],me=(t,h)=>!t||!t.trim()?h!=null&&h.allowEmpty?null:"Please enter an artifact name":t.includes("/")?"Cannot contain forward slashes (/)":t.includes("\\")?"Cannot contain backslashes (\\)":/[<>:"|?*]/.test(t)?'Cannot contain: < > : " | ? *':null,Ye=({folder:t,onNavigate:h,onSelect:b,isLoading:w})=>{const[O,f]=s(!1),m=t.itemType!=="site",o=t.itemType==="site"?e(Re,{className:"w-5 h-5 text-neutral03"}):t.itemType==="drive"?e(de,{className:"w-5 h-5 text-neutral03"}):e(U,{className:"w-5 h-5 text-neutral03"});return l("div",{className:"flex items-center gap-3 p-3 hover:bg-neutral08 border-b last:border-b-0 min-h-[56px] cursor-pointer",onMouseEnter:()=>!w&&f(!0),onMouseLeave:()=>f(!1),onClick:()=>h(t),children:[e("div",{className:"flex-shrink-0",children:o}),e("div",{className:"flex-1 min-w-0",children:e("div",{className:"text-sm font-medium truncate",children:t.name})}),m&&e("div",{className:"flex items-center gap-2",children:e(c,{size:"sm",onClick:C=>{C.stopPropagation(),b(t)},disabled:w,className:oe("h-8 px-2 text-xs transition-opacity duration-200",O?"opacity-100":"opacity-0"),children:"Select Folder"})})]})},Ze={google_drive:"Google Drive",onedrive:"OneDrive"},ea=({isOpen:t,onClose:h,defaultArtifactName:b="",hasTable:w=!1,fileGenerators:O,artifactContent:f="",provider:m,singleExcelOnly:o=!1})=>{var C;const g=Ze[m]??m,K=m==="onedrive"?"My OneDrive (root)":"My Drive (root)",he=De(),{isExportBlocked:pe,refuseExport:xe}=Fe(),[d,R]=s(ne(b)),[p,V]=s(o?"EXCEL_SINGLE":"PDF"),[n,W]=s(!1),[_,y]=s(!1),[G,k]=s(""),[q,L]=s(null),[D,F]=s(1),[ue,v]=s(void 0),[i,E]=s([]),I=Le(null),[fe,H]=s(!1),j=B(()=>d?me(d,{allowEmpty:!0}):null,[d]),{data:X,isLoading:J}=Se({folderId:ue,foldersOnly:!0,enabled:t&&_,provider:m}),Q=B(()=>(X==null?void 0:X.pages.flatMap(a=>a.files).filter(a=>a.mimeType===Te))??[],[X]);te.useEffect(()=>{t&&(R(ne(b)),V(o?"EXCEL_SINGLE":"PDF"),k(""),L(null),y(!1),E([]),v(void 0),F(1),I.current=null,H(!1))},[t,b,o]);const ve=u(a=>{v(a.id),E(r=>[...r,{id:a.id,name:a.name,itemType:a.itemType}])},[]),Ne=u(a=>{const r=[...i.map(x=>x.name),a.name].join("/");k(r),L(a.id),y(!1)},[i]),be=u(()=>{var a;if(i.length===0)k(""),L(null);else{const r=i.map(x=>x.name).join("/");k(r),L(((a=i[i.length-1])==null?void 0:a.id)??null)}y(!1)},[i]),ge=u(()=>{var a;if(i.length>0){const r=i.slice(0,-1);E(r),v(r.length>0?(a=r[r.length-1])==null?void 0:a.id:void 0)}},[i]),Y=u(()=>{E([]),v(void 0)},[]),Z=u(a=>{var r;if(a===-1)Y();else{const x=i.slice(0,a+1);E(x),v((r=x[x.length-1])==null?void 0:r.id)}},[i,Y]),S=m==="onedrive"?"My OneDrive":"My Drive",ye=B(()=>[{name:S,id:"",index:-1},...i.map((a,r)=>({...a,index:r}))],[i,S]),Ee=(i.length>0?(C=i[i.length-1])==null?void 0:C.itemType:void 0)!=="site",we=()=>{const a=me(d);if(a){z({title:"Validation Error",description:a,variant:"destructive"});return}F(2)},ee=()=>F(1),Ce=u(a=>{I.current=a,H(!0)},[]),ae=a=>{switch(a){case"PDF":return"pdf";case"DOC":return"doc";case"EXCEL_SINGLE":case"EXCEL_MULTI":return"xlsx"}},ke=a=>{switch(a){case"PDF":return"PDF";case"DOC":return"Word Document";case"EXCEL_SINGLE":return"Single Sheet Excel";case"EXCEL_MULTI":return"Multi Sheet Excel"}},le=async()=>{if(pe){xe();return}W(!0);try{const a=await He({fileType:p,artifactContent:f,artifactName:d,pdfBlobGenerator:I.current,fileGenerators:O});if(!a)throw new Error("Failed to generate file");const r=`${d.trim()}.${ae(p)}`;await Ve(a,r,q??void 0,m),he.invalidateQueries({queryKey:[We]}),z({title:`Exported to ${g}`,description:`${r} has been uploaded successfully`,variant:"success"}),h()}catch(a){if(qe(a))return;console.error(`Export to ${g} failed:`,a),z({title:"Export Failed",description:a instanceof Error?a.message:"An unknown error occurred",variant:"destructive"})}finally{W(!1)}},re=()=>{n||(F(1),h())},ie=D===2&&!!f&&!o;return e(Me,{open:t,onOpenChange:re,children:e(Pe,{className:oe("sm:max-w-[650px] transition-all duration-200 w-full",_?"sm:max-w-[650px] w-[70vw] h-[70vh] max-h-[700px] flex flex-col gap-1":"",ie?"sm:max-w-[1400px] w-[90vw] h-[90vh] p-0 gap-0 flex flex-col":""),closeOnOutsideClick:!1,children:_?l(N,{children:[e(T,{className:"flex-shrink-0 px-6 pt-6",children:e(M,{children:"Select destination folder"})}),e("div",{className:"flex-1 flex flex-col gap-1 p-4 min-h-0",children:l("div",{className:"flex-1 flex flex-col border rounded-lg min-h-0 overflow-hidden",children:[e("div",{className:"flex-shrink-0 flex items-center justify-between p-3 border-b bg-neutral08 min-h-[56px]",children:l("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[i.length>0&&e(c,{variant:"ghost",size:"sm",onClick:ge,className:"h-6 w-6 p-0 flex-shrink-0",children:e(Oe,{className:"w-4 h-4"})}),e("button",{onClick:()=>Z(-1),className:"hover:text-primary text-neutral03 flex-shrink-0 p-1 rounded hover:bg-neutral07",title:S,children:e(_e,{className:"w-4 h-4"})}),ye.filter(a=>a.name!==S).map((a,r)=>l(te.Fragment,{children:[e(Ge,{className:"w-4 h-4 text-neutral04 flex-shrink-0"}),e("button",{onClick:()=>Z(a.index),className:"text-sm hover:text-primary truncate",children:a.name})]},a.id||r))]})}),e("div",{className:"flex-1 overflow-y-auto",children:J?e("div",{className:"space-y-0",children:Array(5).fill(0).map((a,r)=>l("div",{className:"flex items-center gap-3 p-3 border-b last:border-b-0 min-h-[56px]",children:[e($,{className:"w-5 h-5 rounded-md"}),e($,{className:"flex-1 h-4 rounded-md"}),e($,{className:"w-24 h-8 rounded-md"})]},r))}):Q.length===0?l("div",{className:"flex flex-col items-center justify-center py-8 h-full",children:[e(Ie,{className:"w-8 h-8 text-neutral03 mb-2"}),e("div",{className:"text-sm text-neutral03",children:"No folders in this location"})]}):e("div",{className:"space-y-0",children:Q.map(a=>e(Ye,{folder:a,onNavigate:ve,onSelect:Ne,isLoading:J},a.id))})})]})}),l(P,{className:"flex-shrink-0 px-6 pb-6 pt-4 border-t border-border-primary",children:[e(c,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e(c,{onClick:be,disabled:!Ee,children:i.length===0?"Select Root":"Select Folder"})]})]}):D===1?l(N,{children:[e(T,{className:"px-6 pt-6 flex-shrink-0",children:l(M,{children:["Export to ",g]})}),l("div",{className:"px-6 py-4 flex-1 min-h-0 min-w-0 overflow-hidden",children:[l("div",{className:"grid grid-cols-[1fr_140px] gap-3 pb-4",children:[l("div",{className:"space-y-2",children:[e(A,{htmlFor:"drive-artifact-name",className:"text-sm font-medium text-neutral-700",children:"Artifact name"}),e(je,{id:"drive-artifact-name",size:"sm",value:d,onChange:a=>R(a.target.value),placeholder:"Enter artifact name",disabled:n,required:!0,className:"h-10",error:!!j,errorMessage:j||void 0})]}),l("div",{className:"space-y-2",children:[e(A,{htmlFor:"drive-file-type",className:"text-sm font-medium text-neutral-700",children:"Type"}),l(Xe,{value:p,onValueChange:a=>V(a),children:[e(Be,{id:"drive-file-type",disabled:n,className:"h-10 w-full",children:e($e,{placeholder:"Select file type"})}),l(Ae,{children:[!o&&Je.map(a=>e(se,{value:a.value,children:l("div",{className:"flex items-center gap-2",children:[e(a.icon,{className:"h-4 w-4 flex-shrink-0"}),e("span",{children:a.label})]})},a.value)),(w||o)&&Qe.filter(a=>!o||a.value==="EXCEL_SINGLE").map(a=>e(se,{value:a.value,children:l("div",{className:"flex items-center gap-2",children:[e(a.icon,{className:"h-4 w-4 flex-shrink-0"}),e("span",{children:a.label})]})},a.value))]})]})]})]}),e("div",{className:"border-t border-gray-200 my-2"}),l("div",{className:"space-y-2 pt-3",children:[e(A,{htmlFor:"drive-destination-folder",className:"text-sm font-medium text-neutral-700",children:"Destination folder"}),l("div",{className:"flex items-center gap-2",children:[e("div",{className:"flex-1 h-10 px-3 py-2 border border-border-primary rounded-md bg-white flex items-center gap-2",children:G?l(N,{children:[e(U,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm truncate",children:G})]}):l(N,{children:[e(de,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm text-neutral03",children:K})]})}),e(c,{variant:"outline",onClick:()=>{y(!0),v(q??void 0)},disabled:n,className:"h-10",children:"Browse"})]})]})]}),l(P,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[e(c,{variant:"outline",onClick:re,disabled:n,children:"Cancel"}),e(c,{onClick:we,disabled:n||!!j||!d.trim(),children:"Next"})]})]}):D===2?ie?l(N,{children:[e(T,{className:"px-6 py-4 border-b border-border-primary flex-shrink-0",children:e(M,{children:"Export Preview"})}),e(Ke,{markdownContent:f,documentName:d,isActive:t&&D===2,isExporting:n,onGeneratePdfBlobReady:p==="PDF"?Ce:void 0}),l(P,{className:"px-6 py-4 border-t border-border-primary flex-shrink-0",children:[e(c,{variant:"outline",onClick:ee,disabled:n,children:"Back"}),e(c,{onClick:le,disabled:p==="PDF"?!fe:!1,isLoading:n,children:n?"Exporting...":`Export to ${g}`})]})]}):l(N,{children:[e(T,{className:"px-6 pt-6 flex-shrink-0",children:l(M,{children:["Confirm Export to ",g]})}),e("div",{className:"px-6 py-4 flex-1 min-h-0",children:l("div",{className:"space-y-4",children:[e("p",{className:"text-sm text-neutral03",children:"Please review the export details below:"}),l("div",{className:"border border-border-primary rounded-lg p-4 space-y-3 bg-neutral08",children:[l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"File Name"}),l("span",{className:"text-sm text-right",children:[d,".",ae(p)]})]}),l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"File Type"}),e("span",{className:"text-sm",children:ke(p)})]}),e("div",{className:"border-t border-border-primary my-2"}),l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"Destination Folder"}),l("div",{className:"flex items-center gap-2",children:[e(U,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm text-right",children:G||K})]})]})]})]})}),l(P,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[e(c,{variant:"outline",onClick:ee,disabled:n,children:"Back"}),e(c,{onClick:le,isLoading:n,disabled:n,children:"Export"})]})]}):null})})};export{ea as ExportToDriveDialog};
1
+ import{jsx as e,jsxs as l,Fragment as N}from"react/jsx-runtime";import te,{useState as s,useRef as Le,useMemo as B,useCallback as u}from"react";import{cL as De,cK as Fe,cN as ne,d5 as Se,d6 as Te,c1 as Me,c2 as Pe,c8 as T,c3 as M,bD as c,cT as Oe,cU as _e,cV as Ge,cW as $,cX as Ie,ca as P,bN as A,c9 as je,bH as Xe,bI as Be,bJ as $e,bK as Ae,cY as Ue,cZ as ze,bL as se,c_ as ce,d0 as U,d7 as de,aC as Ke,j as oe,d8 as Re,cu as z,d9 as Ve,da as We,d2 as qe}from"./runtime-BifHPIs0.js";import{g as He}from"./exportFileGeneration-jv6-MI8B.js";const Je=[{value:"PDF",label:"PDF",icon:Ue},{value:"DOC",label:"Word Document",icon:ze}],Qe=[{value:"EXCEL_SINGLE",label:"Single Sheet Excel",icon:ce},{value:"EXCEL_MULTI",label:"Multi Sheet Excel",icon:ce}],me=(t,h)=>!t||!t.trim()?h!=null&&h.allowEmpty?null:"Please enter an artifact name":t.includes("/")?"Cannot contain forward slashes (/)":t.includes("\\")?"Cannot contain backslashes (\\)":/[<>:"|?*]/.test(t)?'Cannot contain: < > : " | ? *':null,Ye=({folder:t,onNavigate:h,onSelect:b,isLoading:w})=>{const[O,f]=s(!1),m=t.itemType!=="site",o=t.itemType==="site"?e(Re,{className:"w-5 h-5 text-neutral03"}):t.itemType==="drive"?e(de,{className:"w-5 h-5 text-neutral03"}):e(U,{className:"w-5 h-5 text-neutral03"});return l("div",{className:"flex items-center gap-3 p-3 hover:bg-neutral08 border-b last:border-b-0 min-h-[56px] cursor-pointer",onMouseEnter:()=>!w&&f(!0),onMouseLeave:()=>f(!1),onClick:()=>h(t),children:[e("div",{className:"flex-shrink-0",children:o}),e("div",{className:"flex-1 min-w-0",children:e("div",{className:"text-sm font-medium truncate",children:t.name})}),m&&e("div",{className:"flex items-center gap-2",children:e(c,{size:"sm",onClick:C=>{C.stopPropagation(),b(t)},disabled:w,className:oe("h-8 px-2 text-xs transition-opacity duration-200",O?"opacity-100":"opacity-0"),children:"Select Folder"})})]})},Ze={google_drive:"Google Drive",onedrive:"OneDrive"},ea=({isOpen:t,onClose:h,defaultArtifactName:b="",hasTable:w=!1,fileGenerators:O,artifactContent:f="",provider:m,singleExcelOnly:o=!1})=>{var C;const g=Ze[m]??m,K=m==="onedrive"?"My OneDrive (root)":"My Drive (root)",he=De(),{isExportBlocked:pe,refuseExport:xe}=Fe(),[d,R]=s(ne(b)),[p,V]=s(o?"EXCEL_SINGLE":"PDF"),[n,W]=s(!1),[_,y]=s(!1),[G,k]=s(""),[q,L]=s(null),[D,F]=s(1),[ue,v]=s(void 0),[i,E]=s([]),I=Le(null),[fe,H]=s(!1),j=B(()=>d?me(d,{allowEmpty:!0}):null,[d]),{data:X,isLoading:J}=Se({folderId:ue,foldersOnly:!0,enabled:t&&_,provider:m}),Q=B(()=>(X==null?void 0:X.pages.flatMap(a=>a.files).filter(a=>a.mimeType===Te))??[],[X]);te.useEffect(()=>{t&&(R(ne(b)),V(o?"EXCEL_SINGLE":"PDF"),k(""),L(null),y(!1),E([]),v(void 0),F(1),I.current=null,H(!1))},[t,b,o]);const ve=u(a=>{v(a.id),E(r=>[...r,{id:a.id,name:a.name,itemType:a.itemType}])},[]),Ne=u(a=>{const r=[...i.map(x=>x.name),a.name].join("/");k(r),L(a.id),y(!1)},[i]),be=u(()=>{var a;if(i.length===0)k(""),L(null);else{const r=i.map(x=>x.name).join("/");k(r),L(((a=i[i.length-1])==null?void 0:a.id)??null)}y(!1)},[i]),ge=u(()=>{var a;if(i.length>0){const r=i.slice(0,-1);E(r),v(r.length>0?(a=r[r.length-1])==null?void 0:a.id:void 0)}},[i]),Y=u(()=>{E([]),v(void 0)},[]),Z=u(a=>{var r;if(a===-1)Y();else{const x=i.slice(0,a+1);E(x),v((r=x[x.length-1])==null?void 0:r.id)}},[i,Y]),S=m==="onedrive"?"My OneDrive":"My Drive",ye=B(()=>[{name:S,id:"",index:-1},...i.map((a,r)=>({...a,index:r}))],[i,S]),Ee=(i.length>0?(C=i[i.length-1])==null?void 0:C.itemType:void 0)!=="site",we=()=>{const a=me(d);if(a){z({title:"Validation Error",description:a,variant:"destructive"});return}F(2)},ee=()=>F(1),Ce=u(a=>{I.current=a,H(!0)},[]),ae=a=>{switch(a){case"PDF":return"pdf";case"DOC":return"doc";case"EXCEL_SINGLE":case"EXCEL_MULTI":return"xlsx"}},ke=a=>{switch(a){case"PDF":return"PDF";case"DOC":return"Word Document";case"EXCEL_SINGLE":return"Single Sheet Excel";case"EXCEL_MULTI":return"Multi Sheet Excel"}},le=async()=>{if(pe){xe();return}W(!0);try{const a=await He({fileType:p,artifactContent:f,artifactName:d,pdfBlobGenerator:I.current,fileGenerators:O});if(!a)throw new Error("Failed to generate file");const r=`${d.trim()}.${ae(p)}`;await Ve(a,r,q??void 0,m),he.invalidateQueries({queryKey:[We]}),z({title:`Exported to ${g}`,description:`${r} has been uploaded successfully`,variant:"success"}),h()}catch(a){if(qe(a))return;console.error(`Export to ${g} failed:`,a),z({title:"Export Failed",description:a instanceof Error?a.message:"An unknown error occurred",variant:"destructive"})}finally{W(!1)}},re=()=>{n||(F(1),h())},ie=D===2&&!!f&&!o;return e(Me,{open:t,onOpenChange:re,children:e(Pe,{className:oe("sm:max-w-[650px] transition-all duration-200 w-full",_?"sm:max-w-[650px] w-[70vw] h-[70vh] max-h-[700px] flex flex-col gap-1":"",ie?"sm:max-w-[1400px] w-[90vw] h-[90vh] p-0 gap-0 flex flex-col":""),closeOnOutsideClick:!1,children:_?l(N,{children:[e(T,{className:"flex-shrink-0 px-6 pt-6",children:e(M,{children:"Select destination folder"})}),e("div",{className:"flex-1 flex flex-col gap-1 p-4 min-h-0",children:l("div",{className:"flex-1 flex flex-col border rounded-lg min-h-0 overflow-hidden",children:[e("div",{className:"flex-shrink-0 flex items-center justify-between p-3 border-b bg-neutral08 min-h-[56px]",children:l("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[i.length>0&&e(c,{variant:"ghost",size:"sm",onClick:ge,className:"h-6 w-6 p-0 flex-shrink-0",children:e(Oe,{className:"w-4 h-4"})}),e("button",{onClick:()=>Z(-1),className:"hover:text-primary text-neutral03 flex-shrink-0 p-1 rounded hover:bg-neutral07",title:S,children:e(_e,{className:"w-4 h-4"})}),ye.filter(a=>a.name!==S).map((a,r)=>l(te.Fragment,{children:[e(Ge,{className:"w-4 h-4 text-neutral04 flex-shrink-0"}),e("button",{onClick:()=>Z(a.index),className:"text-sm hover:text-primary truncate",children:a.name})]},a.id||r))]})}),e("div",{className:"flex-1 overflow-y-auto",children:J?e("div",{className:"space-y-0",children:Array(5).fill(0).map((a,r)=>l("div",{className:"flex items-center gap-3 p-3 border-b last:border-b-0 min-h-[56px]",children:[e($,{className:"w-5 h-5 rounded-md"}),e($,{className:"flex-1 h-4 rounded-md"}),e($,{className:"w-24 h-8 rounded-md"})]},r))}):Q.length===0?l("div",{className:"flex flex-col items-center justify-center py-8 h-full",children:[e(Ie,{className:"w-8 h-8 text-neutral03 mb-2"}),e("div",{className:"text-sm text-neutral03",children:"No folders in this location"})]}):e("div",{className:"space-y-0",children:Q.map(a=>e(Ye,{folder:a,onNavigate:ve,onSelect:Ne,isLoading:J},a.id))})})]})}),l(P,{className:"flex-shrink-0 px-6 pb-6 pt-4 border-t border-border-primary",children:[e(c,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e(c,{onClick:be,disabled:!Ee,children:i.length===0?"Select Root":"Select Folder"})]})]}):D===1?l(N,{children:[e(T,{className:"px-6 pt-6 flex-shrink-0",children:l(M,{children:["Export to ",g]})}),l("div",{className:"px-6 py-4 flex-1 min-h-0 min-w-0 overflow-hidden",children:[l("div",{className:"grid grid-cols-[1fr_140px] gap-3 pb-4",children:[l("div",{className:"space-y-2",children:[e(A,{htmlFor:"drive-artifact-name",className:"text-sm font-medium text-neutral-700",children:"Artifact name"}),e(je,{id:"drive-artifact-name",size:"sm",value:d,onChange:a=>R(a.target.value),placeholder:"Enter artifact name",disabled:n,required:!0,className:"h-10",error:!!j,errorMessage:j||void 0})]}),l("div",{className:"space-y-2",children:[e(A,{htmlFor:"drive-file-type",className:"text-sm font-medium text-neutral-700",children:"Type"}),l(Xe,{value:p,onValueChange:a=>V(a),children:[e(Be,{id:"drive-file-type",disabled:n,className:"h-10 w-full",children:e($e,{placeholder:"Select file type"})}),l(Ae,{children:[!o&&Je.map(a=>e(se,{value:a.value,children:l("div",{className:"flex items-center gap-2",children:[e(a.icon,{className:"h-4 w-4 flex-shrink-0"}),e("span",{children:a.label})]})},a.value)),(w||o)&&Qe.filter(a=>!o||a.value==="EXCEL_SINGLE").map(a=>e(se,{value:a.value,children:l("div",{className:"flex items-center gap-2",children:[e(a.icon,{className:"h-4 w-4 flex-shrink-0"}),e("span",{children:a.label})]})},a.value))]})]})]})]}),e("div",{className:"border-t border-gray-200 my-2"}),l("div",{className:"space-y-2 pt-3",children:[e(A,{htmlFor:"drive-destination-folder",className:"text-sm font-medium text-neutral-700",children:"Destination folder"}),l("div",{className:"flex items-center gap-2",children:[e("div",{className:"flex-1 h-10 px-3 py-2 border border-border-primary rounded-md bg-white flex items-center gap-2",children:G?l(N,{children:[e(U,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm truncate",children:G})]}):l(N,{children:[e(de,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm text-neutral03",children:K})]})}),e(c,{variant:"outline",onClick:()=>{y(!0),v(q??void 0)},disabled:n,className:"h-10",children:"Browse"})]})]})]}),l(P,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[e(c,{variant:"outline",onClick:re,disabled:n,children:"Cancel"}),e(c,{onClick:we,disabled:n||!!j||!d.trim(),children:"Next"})]})]}):D===2?ie?l(N,{children:[e(T,{className:"px-6 py-4 border-b border-border-primary flex-shrink-0",children:e(M,{children:"Export Preview"})}),e(Ke,{markdownContent:f,documentName:d,isActive:t&&D===2,isExporting:n,onGeneratePdfBlobReady:p==="PDF"?Ce:void 0}),l(P,{className:"px-6 py-4 border-t border-border-primary flex-shrink-0",children:[e(c,{variant:"outline",onClick:ee,disabled:n,children:"Back"}),e(c,{onClick:le,disabled:p==="PDF"?!fe:!1,isLoading:n,children:n?"Exporting...":`Export to ${g}`})]})]}):l(N,{children:[e(T,{className:"px-6 pt-6 flex-shrink-0",children:l(M,{children:["Confirm Export to ",g]})}),e("div",{className:"px-6 py-4 flex-1 min-h-0",children:l("div",{className:"space-y-4",children:[e("p",{className:"text-sm text-neutral03",children:"Please review the export details below:"}),l("div",{className:"border border-border-primary rounded-lg p-4 space-y-3 bg-neutral08",children:[l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"File Name"}),l("span",{className:"text-sm text-right",children:[d,".",ae(p)]})]}),l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"File Type"}),e("span",{className:"text-sm",children:ke(p)})]}),e("div",{className:"border-t border-border-primary my-2"}),l("div",{className:"flex justify-between items-start",children:[e("span",{className:"text-sm font-medium text-neutral03",children:"Destination Folder"}),l("div",{className:"flex items-center gap-2",children:[e(U,{className:"w-4 h-4 text-neutral03 flex-shrink-0"}),e("span",{className:"text-sm text-right",children:G||K})]})]})]})]})}),l(P,{className:"px-6 pb-6 pt-4 flex-shrink-0 border-t",children:[e(c,{variant:"outline",onClick:ee,disabled:n,children:"Back"}),e(c,{onClick:le,isLoading:n,disabled:n,children:"Export"})]})]}):null})})};export{ea as ExportToDriveDialog};
@@ -1,4 +1,4 @@
1
- import{jsx as n,jsxs as h,Fragment as je}from"react/jsx-runtime";import{useState as x,useEffect as q,useRef as de}from"react";import{by as ze,bz as De,bA as Me,bB as Be,s as We,L as Oe,bC as Y,j as ce,bD as R,bE as me,bF as ue,bG as D,bH as Je,bI as Ve,bJ as _e,bK as qe,bL as Ye,aW as Ze,bM as Ke,bN as Qe,bO as Xe,bP as et,bQ as tt,bR as nt,bS as it,bT as at,bU as ot,bV as rt,bW as st,bX as lt,bY as pe,bZ as dt,b_ as ct,b$ as mt,c0 as ut}from"./runtime-DTft3h2S.js";import"react-dom";import"react-dom/client";import{E as pt,P as ht}from"./pen-tool-Bgn3U1At.js";import{H as ft}from"./highlighter-DXAQAEoS.js";import{g as gt}from"./index-C521BAYE.js";const bt=()=>{const i=navigator.userAgent;let l="Unknown",s="Unknown";if(i.includes("Chrome")&&!i.includes("Edg")){l="Chrome";const t=i.match(/Chrome\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Firefox")){l="Firefox";const t=i.match(/Firefox\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Safari")&&!i.includes("Chrome")){l="Safari";const t=i.match(/Version\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Edg")){l="Edge";const t=i.match(/Edg\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}return{name:l,version:s,userAgent:i,language:navigator.language,platform:navigator.platform,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine}},wt=()=>{const i=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),l=/iPad|Android(?=.*Mobile)/i.test(navigator.userAgent);return{screenResolution:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,devicePixelRatio:window.devicePixelRatio,isMobile:i,isTablet:l,touchSupported:"ontouchstart"in window||navigator.maxTouchPoints>0}},vt=()=>{const i=new Date,l=Intl.DateTimeFormat().resolvedOptions().timeZone;let s;if(window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("navigation");if(t.length>0){const r=t[0];r&&r.loadEventEnd&&(s=Math.round(r.loadEventEnd))}}return{url:window.location.href,title:document.title,referrer:document.referrer,timestamp:i.toISOString(),timezone:l,loadTime:s}},yt=()=>{const i={},l=window.performance;if("memory"in window.performance&&l.memory){const t=l.memory,r=Math.round(t.usedJSHeapSize/(1024*1024)),f=Math.round(t.totalJSHeapSize/(1024*1024)),k=Math.round(t.jsHeapSizeLimit/(1024*1024));r>=0&&f>=0&&k>0&&(i.memoryUsage=r,i.totalJSHeapSize=f,i.jsHeapSizeLimit=k)}if("connection"in navigator){const t=navigator.connection;i.connectionType=(t==null?void 0:t.type)||"unknown",i.effectiveType=(t==null?void 0:t.effectiveType)||"unknown",i.downlink=t==null?void 0:t.downlink,i.rtt=t==null?void 0:t.rtt,i.saveData=t==null?void 0:t.saveData}const s={};if(window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("navigation");if(t.length>0){const r=t[0];r&&r.domContentLoadedEventEnd&&(s.domContentLoaded=Math.round(r.domContentLoadedEventEnd)),r&&r.loadEventEnd&&(s.loadComplete=Math.round(r.loadEventEnd))}window.performance.getEntriesByType("paint").forEach(r=>{r.name==="first-paint"?s.firstPaint=Math.round(r.startTime):r.name==="first-contentful-paint"&&(s.firstContentfulPaint=Math.round(r.startTime))})}if(Object.keys(s).length>0&&(i.navigationTiming=s),window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("resource");if(t.length>0){const r=t.reduce((f,k)=>f+(k.transferSize||0),0);i.resourceTiming={totalResources:t.length,totalTransferSize:Math.round(r/1024)}}}return i},xt=()=>({browser:bt(),device:wt(),page:vt(),performance:yt()}),kt=i=>new Promise((l,s)=>{const t=new FileReader;t.onload=()=>{typeof t.result=="string"?l(t.result):s(new Error("Failed to read file as data URL"))},t.onerror=()=>s(t.error??new Error("Failed to read file")),t.readAsDataURL(i)}),Et=i=>{var l,s;const t=i.split(","),r=((s=(l=t[0])==null?void 0:l.match(/:(.*?);/))==null?void 0:s[1])||"image/png",f=atob(t[1]||"");let k=f.length;const v=new Uint8Array(k);for(;k--;)v[k]=f.charCodeAt(k);return new Blob([v],{type:r})},w={PEN:"pen",HIGHLIGHTER:"highlighter"},Nt="Tell us what happened or what you'd like to see",he=[{value:"bug",label:"Something's broken",icon:n(rt,{className:"w-4 h-4 text-error"}),description:"Something isn't working as expected.",descriptionPlaceholder:"What happened, and what did you expect instead?"},{value:"enhancement",label:"I have an idea",icon:n(st,{className:"w-4 h-4 text-warning"}),description:"An idea to improve what already works.",descriptionPlaceholder:"What would you like to be able to do?"},{value:"other",label:"Something else",icon:n(lt,{className:"w-4 h-4 text-primary-text"}),description:"A question or anything else.",descriptionPlaceholder:"What's on your mind?"}],Ct=i=>{if(typeof i=="string")return i;if(!i||typeof i!="object")return;const{detail:l,error:s}=i;if(typeof l=="string")return l;if(l&&typeof l=="object"){const{message:t,error:r}=l;if(typeof t=="string")return t;if(typeof r=="string")return r}return typeof s=="string"?s:void 0},It=({onClose:i,initialScreenshot:l})=>{var s,t,r;const[f,k]=x(""),[v,Z]=x(""),[F,K]=x(l||null),[L,M]=x([]),[B,fe]=x(w.PEN),[Q,X]=x(!1),[C,$]=x(null),[N,ee]=x(!1),[G,ge]=x(!0),[te,be]=x("p0"),[P,ne]=x([]),[W,O]=x(!1),[we,ve]=x(null),{toast:J}=ze(),{user:a}=De(),{currentPlan:A,commitSha:S}=Me(),{clientInstanceId:ie}=Be(),j=We.getItem(Oe.CONNECTED_TENANT_ID,!0,"");q(()=>{be(v==="bug"?"p0":"p1")},[v]);const ae=de(null),z=de(null);q(()=>{try{const e=xt();ve(e)}catch(e){console.warn("Failed to capture system info:",e)}},[]),q(()=>{const e=o=>{var d;const y=(d=o.clipboardData)==null?void 0:d.items;if(y)for(let c=0;c<y.length;c++){const p=y[c];if(p&&p.type.startsWith("image/")){const u=p.getAsFile();if(!u)continue;const g=new FileReader;g.onload=()=>{typeof g.result=="string"&&K(g.result)},g.readAsDataURL(u),o.preventDefault();return}}};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[]);const ye=e=>{const o=e.target.getStage().getPointerPosition(),d={tool:B,points:[o.x,o.y]};$(d),X(!0)},xe=e=>{if(!Q||!C)return;const o=e.target.getStage().getPointerPosition(),d=C;$({...d,points:[...d.points,o.x,o.y]})},ke=()=>{!Q||!C||(M([...L,C]),$(null),X(!1))},Ee=()=>{M([]),$(null)},oe=async(e,o=!1)=>{var d,y;try{const c=await dt([e],"public/feedback");if(c.statusCode!==200)throw new Error(`Failed to upload ${o?"screenshot":"file"}`);if((d=c.data)!=null&&d.url){const p=c.data.url,u=p.replace("supabase://file-uploads/",""),g=3600*24*180,H=await ct({path:u,expiration:g});if(H.statusCode===200&&(y=H.data)!=null&&y.signedUrl)return{success:!0,name:e.name,rawUrl:p,signedUrl:H.data.signedUrl};throw new Error(`Failed to get signed URL for ${o?"screenshot":e.name}`)}else throw new Error(`No URL returned from upload for ${o?"screenshot":e.name}`)}catch{if(o)try{const c=await kt(e);return{success:!1,name:e.name,dataUrl:c}}catch{return{success:!1,name:e.name}}return{success:!1,name:e.name}}},Ne=async(e,o,d,y=[])=>{var c;let p;try{const g=gt();g&&(await Promise.race([g.flush(),new Promise(H=>setTimeout(H,2e3))]),p=g.getReplayId())}catch{}const u=await mt(`${ut}/feedback/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,body:o,feedbackType:v,priority:te,reporterEmail:(a==null?void 0:a.isImpersonating)&&(a==null?void 0:a.impersonatedBy)||(a==null?void 0:a.email)||"unknown",reporterName:(a==null?void 0:a.name)||"unknown",reporterRole:(a==null?void 0:a.role)||"unknown",clientInstanceId:ie||"unknown",tenantId:j||"unknown",isCustomerIssue:!((c=a==null?void 0:a.email)!=null&&c.includes("outmarket.ai")),feedbackText:f,screenshotUrl:d,additionalFiles:y,isConsentGiven:G,planLabel:(A==null?void 0:A.planLabel)||"unknown",systemInfo:we,sentryReplayId:p,commitSha:S&&S!=="unknown"?S:void 0,latestCommitSha:S&&S!=="unknown"?S:void 0})});if(!u.ok){const g=await u.json().catch(()=>null);throw new Error(Ct(g)||"Failed to submit feedback")}return await u.json()},Ce=async()=>{var e;if(!(!f.trim()||!v)){J({title:"Submitting feedback...",description:"Your feedback is being processed",variant:"default"}),V();try{ee(!0),O(!0);const o=[];let d=null;if(F){const m=ae.current;if(m)try{const b=document.createElement("canvas"),I=z.current;if(I){b.width=I.naturalWidth||I.width,b.height=I.naturalHeight||I.height;const E=b.getContext("2d");if(E){E.drawImage(I,0,0,b.width,b.height);const Le=m.width(),Pe=m.height(),_=b.width/Le,Ue=b.height/Pe;L.forEach(Ae=>{const T=Ae;if(E.beginPath(),E.strokeStyle=T.tool===w.HIGHLIGHTER?"#FFFF00":"#FF0000",E.lineWidth=T.tool===w.HIGHLIGHTER?15*_:2*_,E.globalAlpha=T.tool===w.HIGHLIGHTER?.3:1,E.lineCap="round",E.lineJoin="round",T&&Array.isArray(T.points)&&T.points.length>0)for(let U=0;U<T.points.length;U+=2){const se=(T.points[U]??0)*_,le=(T.points[U+1]??0)*Ue;U===0?E.moveTo(se,le):E.lineTo(se,le)}E.stroke()}),E.globalAlpha=1;const Re=b.toDataURL("image/png"),$e=Et(Re),Ge=new File([$e],"feedback-screenshot.png",{type:"image/png"});d=oe(Ge,!0),o.push(d)}}}catch(b){pe({error:b,extra:{context:"screenshot_preparation",feedbackText:f,feedbackType:v,reporterEmail:(a==null?void 0:a.email)||"unknown",hasAnnotations:L.length>0,annotationsCount:L.length},detailedErrorMessage:"Failed to prepare screenshot with annotations for feedback submission"})}}const y=[];if(P.length>0)for(const m of P){if(!m)continue;const b=oe(m).then(I=>(y.push(I),I));o.push(b)}await Promise.all(o);const c=d?await d:null;O(!1);let p=`[${v.toUpperCase()}] ${f.split(`
1
+ import{jsx as n,jsxs as h,Fragment as je}from"react/jsx-runtime";import{useState as x,useEffect as q,useRef as de}from"react";import{by as ze,bz as De,bA as Me,bB as Be,s as We,L as Oe,bC as Y,j as ce,bD as R,bE as me,bF as ue,bG as D,bH as Je,bI as Ve,bJ as _e,bK as qe,bL as Ye,aW as Ze,bM as Ke,bN as Qe,bO as Xe,bP as et,bQ as tt,bR as nt,bS as it,bT as at,bU as ot,bV as rt,bW as st,bX as lt,bY as pe,bZ as dt,b_ as ct,b$ as mt,c0 as ut}from"./runtime-BifHPIs0.js";import"react-dom";import"react-dom/client";import{E as pt,P as ht}from"./pen-tool-uVg30dx-.js";import{H as ft}from"./highlighter-DAPZ5ZEj.js";import{g as gt}from"./index-CSAs9f_t.js";const bt=()=>{const i=navigator.userAgent;let l="Unknown",s="Unknown";if(i.includes("Chrome")&&!i.includes("Edg")){l="Chrome";const t=i.match(/Chrome\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Firefox")){l="Firefox";const t=i.match(/Firefox\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Safari")&&!i.includes("Chrome")){l="Safari";const t=i.match(/Version\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}else if(i.includes("Edg")){l="Edge";const t=i.match(/Edg\/([0-9.]+)/);s=(t==null?void 0:t[1])??"Unknown"}return{name:l,version:s,userAgent:i,language:navigator.language,platform:navigator.platform,cookieEnabled:navigator.cookieEnabled,onLine:navigator.onLine}},wt=()=>{const i=/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),l=/iPad|Android(?=.*Mobile)/i.test(navigator.userAgent);return{screenResolution:`${screen.width}x${screen.height}`,viewportSize:`${window.innerWidth}x${window.innerHeight}`,devicePixelRatio:window.devicePixelRatio,isMobile:i,isTablet:l,touchSupported:"ontouchstart"in window||navigator.maxTouchPoints>0}},vt=()=>{const i=new Date,l=Intl.DateTimeFormat().resolvedOptions().timeZone;let s;if(window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("navigation");if(t.length>0){const r=t[0];r&&r.loadEventEnd&&(s=Math.round(r.loadEventEnd))}}return{url:window.location.href,title:document.title,referrer:document.referrer,timestamp:i.toISOString(),timezone:l,loadTime:s}},yt=()=>{const i={},l=window.performance;if("memory"in window.performance&&l.memory){const t=l.memory,r=Math.round(t.usedJSHeapSize/(1024*1024)),f=Math.round(t.totalJSHeapSize/(1024*1024)),k=Math.round(t.jsHeapSizeLimit/(1024*1024));r>=0&&f>=0&&k>0&&(i.memoryUsage=r,i.totalJSHeapSize=f,i.jsHeapSizeLimit=k)}if("connection"in navigator){const t=navigator.connection;i.connectionType=(t==null?void 0:t.type)||"unknown",i.effectiveType=(t==null?void 0:t.effectiveType)||"unknown",i.downlink=t==null?void 0:t.downlink,i.rtt=t==null?void 0:t.rtt,i.saveData=t==null?void 0:t.saveData}const s={};if(window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("navigation");if(t.length>0){const r=t[0];r&&r.domContentLoadedEventEnd&&(s.domContentLoaded=Math.round(r.domContentLoadedEventEnd)),r&&r.loadEventEnd&&(s.loadComplete=Math.round(r.loadEventEnd))}window.performance.getEntriesByType("paint").forEach(r=>{r.name==="first-paint"?s.firstPaint=Math.round(r.startTime):r.name==="first-contentful-paint"&&(s.firstContentfulPaint=Math.round(r.startTime))})}if(Object.keys(s).length>0&&(i.navigationTiming=s),window.performance&&window.performance.getEntriesByType){const t=window.performance.getEntriesByType("resource");if(t.length>0){const r=t.reduce((f,k)=>f+(k.transferSize||0),0);i.resourceTiming={totalResources:t.length,totalTransferSize:Math.round(r/1024)}}}return i},xt=()=>({browser:bt(),device:wt(),page:vt(),performance:yt()}),kt=i=>new Promise((l,s)=>{const t=new FileReader;t.onload=()=>{typeof t.result=="string"?l(t.result):s(new Error("Failed to read file as data URL"))},t.onerror=()=>s(t.error??new Error("Failed to read file")),t.readAsDataURL(i)}),Et=i=>{var l,s;const t=i.split(","),r=((s=(l=t[0])==null?void 0:l.match(/:(.*?);/))==null?void 0:s[1])||"image/png",f=atob(t[1]||"");let k=f.length;const v=new Uint8Array(k);for(;k--;)v[k]=f.charCodeAt(k);return new Blob([v],{type:r})},w={PEN:"pen",HIGHLIGHTER:"highlighter"},Nt="Tell us what happened or what you'd like to see",he=[{value:"bug",label:"Something's broken",icon:n(rt,{className:"w-4 h-4 text-error"}),description:"Something isn't working as expected.",descriptionPlaceholder:"What happened, and what did you expect instead?"},{value:"enhancement",label:"I have an idea",icon:n(st,{className:"w-4 h-4 text-warning"}),description:"An idea to improve what already works.",descriptionPlaceholder:"What would you like to be able to do?"},{value:"other",label:"Something else",icon:n(lt,{className:"w-4 h-4 text-primary-text"}),description:"A question or anything else.",descriptionPlaceholder:"What's on your mind?"}],Ct=i=>{if(typeof i=="string")return i;if(!i||typeof i!="object")return;const{detail:l,error:s}=i;if(typeof l=="string")return l;if(l&&typeof l=="object"){const{message:t,error:r}=l;if(typeof t=="string")return t;if(typeof r=="string")return r}return typeof s=="string"?s:void 0},It=({onClose:i,initialScreenshot:l})=>{var s,t,r;const[f,k]=x(""),[v,Z]=x(""),[F,K]=x(l||null),[L,M]=x([]),[B,fe]=x(w.PEN),[Q,X]=x(!1),[C,$]=x(null),[N,ee]=x(!1),[G,ge]=x(!0),[te,be]=x("p0"),[P,ne]=x([]),[W,O]=x(!1),[we,ve]=x(null),{toast:J}=ze(),{user:a}=De(),{currentPlan:A,commitSha:S}=Me(),{clientInstanceId:ie}=Be(),j=We.getItem(Oe.CONNECTED_TENANT_ID,!0,"");q(()=>{be(v==="bug"?"p0":"p1")},[v]);const ae=de(null),z=de(null);q(()=>{try{const e=xt();ve(e)}catch(e){console.warn("Failed to capture system info:",e)}},[]),q(()=>{const e=o=>{var d;const y=(d=o.clipboardData)==null?void 0:d.items;if(y)for(let c=0;c<y.length;c++){const p=y[c];if(p&&p.type.startsWith("image/")){const u=p.getAsFile();if(!u)continue;const g=new FileReader;g.onload=()=>{typeof g.result=="string"&&K(g.result)},g.readAsDataURL(u),o.preventDefault();return}}};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[]);const ye=e=>{const o=e.target.getStage().getPointerPosition(),d={tool:B,points:[o.x,o.y]};$(d),X(!0)},xe=e=>{if(!Q||!C)return;const o=e.target.getStage().getPointerPosition(),d=C;$({...d,points:[...d.points,o.x,o.y]})},ke=()=>{!Q||!C||(M([...L,C]),$(null),X(!1))},Ee=()=>{M([]),$(null)},oe=async(e,o=!1)=>{var d,y;try{const c=await dt([e],"public/feedback");if(c.statusCode!==200)throw new Error(`Failed to upload ${o?"screenshot":"file"}`);if((d=c.data)!=null&&d.url){const p=c.data.url,u=p.replace("supabase://file-uploads/",""),g=3600*24*180,H=await ct({path:u,expiration:g});if(H.statusCode===200&&(y=H.data)!=null&&y.signedUrl)return{success:!0,name:e.name,rawUrl:p,signedUrl:H.data.signedUrl};throw new Error(`Failed to get signed URL for ${o?"screenshot":e.name}`)}else throw new Error(`No URL returned from upload for ${o?"screenshot":e.name}`)}catch{if(o)try{const c=await kt(e);return{success:!1,name:e.name,dataUrl:c}}catch{return{success:!1,name:e.name}}return{success:!1,name:e.name}}},Ne=async(e,o,d,y=[])=>{var c;let p;try{const g=gt();g&&(await Promise.race([g.flush(),new Promise(H=>setTimeout(H,2e3))]),p=g.getReplayId())}catch{}const u=await mt(`${ut}/feedback/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,body:o,feedbackType:v,priority:te,reporterEmail:(a==null?void 0:a.isImpersonating)&&(a==null?void 0:a.impersonatedBy)||(a==null?void 0:a.email)||"unknown",reporterName:(a==null?void 0:a.name)||"unknown",reporterRole:(a==null?void 0:a.role)||"unknown",clientInstanceId:ie||"unknown",tenantId:j||"unknown",isCustomerIssue:!((c=a==null?void 0:a.email)!=null&&c.includes("outmarket.ai")),feedbackText:f,screenshotUrl:d,additionalFiles:y,isConsentGiven:G,planLabel:(A==null?void 0:A.planLabel)||"unknown",systemInfo:we,sentryReplayId:p,commitSha:S&&S!=="unknown"?S:void 0,latestCommitSha:S&&S!=="unknown"?S:void 0})});if(!u.ok){const g=await u.json().catch(()=>null);throw new Error(Ct(g)||"Failed to submit feedback")}return await u.json()},Ce=async()=>{var e;if(!(!f.trim()||!v)){J({title:"Submitting feedback...",description:"Your feedback is being processed",variant:"default"}),V();try{ee(!0),O(!0);const o=[];let d=null;if(F){const m=ae.current;if(m)try{const b=document.createElement("canvas"),I=z.current;if(I){b.width=I.naturalWidth||I.width,b.height=I.naturalHeight||I.height;const E=b.getContext("2d");if(E){E.drawImage(I,0,0,b.width,b.height);const Le=m.width(),Pe=m.height(),_=b.width/Le,Ue=b.height/Pe;L.forEach(Ae=>{const T=Ae;if(E.beginPath(),E.strokeStyle=T.tool===w.HIGHLIGHTER?"#FFFF00":"#FF0000",E.lineWidth=T.tool===w.HIGHLIGHTER?15*_:2*_,E.globalAlpha=T.tool===w.HIGHLIGHTER?.3:1,E.lineCap="round",E.lineJoin="round",T&&Array.isArray(T.points)&&T.points.length>0)for(let U=0;U<T.points.length;U+=2){const se=(T.points[U]??0)*_,le=(T.points[U+1]??0)*Ue;U===0?E.moveTo(se,le):E.lineTo(se,le)}E.stroke()}),E.globalAlpha=1;const Re=b.toDataURL("image/png"),$e=Et(Re),Ge=new File([$e],"feedback-screenshot.png",{type:"image/png"});d=oe(Ge,!0),o.push(d)}}}catch(b){pe({error:b,extra:{context:"screenshot_preparation",feedbackText:f,feedbackType:v,reporterEmail:(a==null?void 0:a.email)||"unknown",hasAnnotations:L.length>0,annotationsCount:L.length},detailedErrorMessage:"Failed to prepare screenshot with annotations for feedback submission"})}}const y=[];if(P.length>0)for(const m of P){if(!m)continue;const b=oe(m).then(I=>(y.push(I),I));o.push(b)}await Promise.all(o);const c=d?await d:null;O(!1);let p=`[${v.toUpperCase()}] ${f.split(`
2
2
  `)[0]}`;p.length>100&&(p=p.slice(0,97)+"..."),a!=null&&a.email.includes("outmarket.ai")||(p=`[Customer Issue] ${p}`,p.length>100&&(p=p.slice(0,97)+"..."));let u=`## Description
3
3
  ${f}
4
4
 
@@ -1 +1 @@
1
- import{jsx as t,jsxs as a}from"react/jsx-runtime";import{c1 as m,c2 as u,c8 as o,c3 as x}from"./runtime-DTft3h2S.js";function l(e){return`$${e.toLocaleString()}`}function g({layer:e,onClose:s}){if(!e)return null;const c=e.coverageType==="excess-follow-form"?"Excess Follow-Form":e.coverageType;return t(m,{open:!!e,onOpenChange:r=>{r||s()},children:a(u,{style:{width:768,maxHeight:"85vh",display:"flex",flexDirection:"column"},children:[a(o,{children:[t(x,{className:"text-base",children:e.carrier}),t("p",{className:"text-sm text-gray-500 mt-0.5 dark:text-neutral-400",children:e.layerName})]}),a("div",{className:"space-y-5 px-5 pb-5 overflow-y-auto",children:[a("div",{className:"grid grid-cols-2 gap-4",children:[t(i,{label:"Attachment Point",value:l(e.attachmentPoint)}),t(i,{label:"Limit",value:l(e.limit),highlight:!0}),e.aggregateLimit!=null&&t(i,{label:"Aggregate Limit",value:l(e.aggregateLimit)}),e.premium!=null&&t(i,{label:"Premium",value:l(e.premium)}),e.deductible!=null&&t(i,{label:"Deductible",value:l(e.deductible)}),e.selfInsuredRetention!=null&&t(i,{label:"Self-Insured Retention",value:l(e.selfInsuredRetention)})]}),a("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Coverage Type"}),t("p",{className:"font-medium text-gray-800 capitalize dark:text-neutral-200",children:c})]}),e.policyNumber&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Policy Number"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.policyNumber})]}),e.effectiveDate&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Effective Date"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.effectiveDate})]}),e.expirationDate&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Expiration Date"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.expirationDate})]}),e.followForm!=null&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Follow Form"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.followForm?"Yes":"No"})]}),e.valuationClause&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Valuation Clause"}),t("p",{className:"font-medium text-gray-800 capitalize dark:text-neutral-200",children:e.valuationClause.replace(/_/g," ")})]}),a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Source Document"}),t("p",{className:"font-medium text-gray-800 truncate dark:text-neutral-200",title:e.sourceDocument,children:e.sourceDocument})]})]}),Array.isArray(e.coinsurance)&&e.coinsurance.length>0&&t(d,{title:"Coinsurance Participants",children:t("div",{className:"space-y-1.5",children:e.coinsurance.map((r,n)=>a("div",{className:"flex items-center justify-between text-sm bg-blue-50 rounded-md px-3 py-2 dark:bg-blue-950/40",children:[t("span",{className:"text-gray-800 font-medium dark:text-neutral-100",children:r.carrier}),a("div",{className:"flex items-center gap-3",children:[r.participationPercentage!=null&&a("span",{className:"text-blue-700 font-semibold dark:text-blue-300",children:[r.participationPercentage,"%"]}),r.participationAmount!=null&&t("span",{className:"text-gray-600 dark:text-neutral-300",children:l(r.participationAmount)})]})]},n))})}),e.sublimits&&e.sublimits.length>0&&t(d,{title:"Sublimits",children:t("div",{className:"grid grid-cols-2 gap-1.5",children:e.sublimits.map((r,n)=>a("div",{className:"flex justify-between text-sm bg-gray-50 rounded-md px-3 py-1.5 dark:bg-neutral-900",children:[t("span",{className:"text-gray-600 dark:text-neutral-400",children:r.name}),t("span",{className:"font-medium text-gray-800 dark:text-neutral-200",children:l(r.limit)})]},n))})}),e.exclusions&&e.exclusions.length>0&&t(d,{title:"Exclusions",children:t("div",{className:"flex flex-wrap gap-1.5",children:e.exclusions.map((r,n)=>t("span",{className:"text-xs bg-red-50 text-red-700 border border-red-200 px-2.5 py-1 rounded-md dark:bg-red-950/40 dark:text-red-300 dark:border-red-900",children:r},n))})}),e.endorsements&&e.endorsements.length>0&&t(d,{title:"Endorsements",children:t("div",{className:"flex flex-wrap gap-1.5",children:e.endorsements.map((r,n)=>t("span",{className:"text-xs bg-green-50 text-green-700 border border-green-200 px-2.5 py-1 rounded-md dark:bg-green-950/40 dark:text-green-300 dark:border-green-900",children:r},n))})})]})]})})}function i({label:e,value:s,highlight:c}){return a("div",{className:"bg-gray-50 rounded-lg px-3 py-2 dark:bg-neutral-900",children:[t("span",{className:"text-xs text-gray-500 dark:text-neutral-400",children:e}),t("p",{className:c?"text-lg font-bold text-gray-900 dark:text-neutral-100":"text-base font-semibold text-gray-800 dark:text-neutral-200",children:s})]})}function d({title:e,children:s}){return a("div",{children:[t("h4",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2 dark:text-neutral-400",children:e}),s]})}export{g as LayerDetailModal};
1
+ import{jsx as t,jsxs as a}from"react/jsx-runtime";import{c1 as m,c2 as u,c8 as o,c3 as x}from"./runtime-BifHPIs0.js";function l(e){return`$${e.toLocaleString()}`}function g({layer:e,onClose:s}){if(!e)return null;const c=e.coverageType==="excess-follow-form"?"Excess Follow-Form":e.coverageType;return t(m,{open:!!e,onOpenChange:r=>{r||s()},children:a(u,{style:{width:768,maxHeight:"85vh",display:"flex",flexDirection:"column"},children:[a(o,{children:[t(x,{className:"text-base",children:e.carrier}),t("p",{className:"text-sm text-gray-500 mt-0.5 dark:text-neutral-400",children:e.layerName})]}),a("div",{className:"space-y-5 px-5 pb-5 overflow-y-auto",children:[a("div",{className:"grid grid-cols-2 gap-4",children:[t(i,{label:"Attachment Point",value:l(e.attachmentPoint)}),t(i,{label:"Limit",value:l(e.limit),highlight:!0}),e.aggregateLimit!=null&&t(i,{label:"Aggregate Limit",value:l(e.aggregateLimit)}),e.premium!=null&&t(i,{label:"Premium",value:l(e.premium)}),e.deductible!=null&&t(i,{label:"Deductible",value:l(e.deductible)}),e.selfInsuredRetention!=null&&t(i,{label:"Self-Insured Retention",value:l(e.selfInsuredRetention)})]}),a("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Coverage Type"}),t("p",{className:"font-medium text-gray-800 capitalize dark:text-neutral-200",children:c})]}),e.policyNumber&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Policy Number"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.policyNumber})]}),e.effectiveDate&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Effective Date"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.effectiveDate})]}),e.expirationDate&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Expiration Date"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.expirationDate})]}),e.followForm!=null&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Follow Form"}),t("p",{className:"font-medium text-gray-800 dark:text-neutral-200",children:e.followForm?"Yes":"No"})]}),e.valuationClause&&a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Valuation Clause"}),t("p",{className:"font-medium text-gray-800 capitalize dark:text-neutral-200",children:e.valuationClause.replace(/_/g," ")})]}),a("div",{children:[t("span",{className:"text-gray-500 text-xs dark:text-neutral-400",children:"Source Document"}),t("p",{className:"font-medium text-gray-800 truncate dark:text-neutral-200",title:e.sourceDocument,children:e.sourceDocument})]})]}),Array.isArray(e.coinsurance)&&e.coinsurance.length>0&&t(d,{title:"Coinsurance Participants",children:t("div",{className:"space-y-1.5",children:e.coinsurance.map((r,n)=>a("div",{className:"flex items-center justify-between text-sm bg-blue-50 rounded-md px-3 py-2 dark:bg-blue-950/40",children:[t("span",{className:"text-gray-800 font-medium dark:text-neutral-100",children:r.carrier}),a("div",{className:"flex items-center gap-3",children:[r.participationPercentage!=null&&a("span",{className:"text-blue-700 font-semibold dark:text-blue-300",children:[r.participationPercentage,"%"]}),r.participationAmount!=null&&t("span",{className:"text-gray-600 dark:text-neutral-300",children:l(r.participationAmount)})]})]},n))})}),e.sublimits&&e.sublimits.length>0&&t(d,{title:"Sublimits",children:t("div",{className:"grid grid-cols-2 gap-1.5",children:e.sublimits.map((r,n)=>a("div",{className:"flex justify-between text-sm bg-gray-50 rounded-md px-3 py-1.5 dark:bg-neutral-900",children:[t("span",{className:"text-gray-600 dark:text-neutral-400",children:r.name}),t("span",{className:"font-medium text-gray-800 dark:text-neutral-200",children:l(r.limit)})]},n))})}),e.exclusions&&e.exclusions.length>0&&t(d,{title:"Exclusions",children:t("div",{className:"flex flex-wrap gap-1.5",children:e.exclusions.map((r,n)=>t("span",{className:"text-xs bg-red-50 text-red-700 border border-red-200 px-2.5 py-1 rounded-md dark:bg-red-950/40 dark:text-red-300 dark:border-red-900",children:r},n))})}),e.endorsements&&e.endorsements.length>0&&t(d,{title:"Endorsements",children:t("div",{className:"flex flex-wrap gap-1.5",children:e.endorsements.map((r,n)=>t("span",{className:"text-xs bg-green-50 text-green-700 border border-green-200 px-2.5 py-1 rounded-md dark:bg-green-950/40 dark:text-green-300 dark:border-green-900",children:r},n))})})]})]})})}function i({label:e,value:s,highlight:c}){return a("div",{className:"bg-gray-50 rounded-lg px-3 py-2 dark:bg-neutral-900",children:[t("span",{className:"text-xs text-gray-500 dark:text-neutral-400",children:e}),t("p",{className:c?"text-lg font-bold text-gray-900 dark:text-neutral-100":"text-base font-semibold text-gray-800 dark:text-neutral-200",children:s})]})}function d({title:e,children:s}){return a("div",{children:[t("h4",{className:"text-xs font-medium text-gray-500 uppercase tracking-wide mb-2 dark:text-neutral-400",children:e}),s]})}export{g as LayerDetailModal};
@@ -1 +1 @@
1
- import{jsxs as N,Fragment as $e,jsx as a}from"react/jsx-runtime";import*as _e from"react";import{useState as U,useMemo as Le,useCallback as D,memo as ge,forwardRef as Be,useEffect as Pt,useRef as fe,useImperativeHandle as St}from"react";import{by as Ie,eT as Ut,iS as Ge,cf as Mt,cL as Et,iT as ne,D as Ae,iU as Qe,iV as zt,iW as Ht,iX as Wt,iY as qt,iZ as _t,i_ as Bt,i$ as Gt,l as Qt,m as Kt,bA as Vt,bz as Jt,eb as Ke,dd as Yt,cJ as Ve,j0 as Zt,j1 as Xt,az as Je,aL as Ye,bC as Ze,fH as ea,eD as De,eC as Xe,dz as ta,j2 as et,j3 as ye,j4 as tt,dp as aa,dE as at,c9 as na,bD as oe,eF as ra,c1 as nt,c2 as rt,c8 as st,ca as sa,cx as ia,cW as la,cX as oa,bT as it,dv as Oe,j5 as da,cV as ca,j6 as lt,j7 as ua,c3 as ma,e8 as pa,e9 as ha,ea as ot,hl as dt,j8 as ga,j9 as fa,ja as ct,hc as ut}from"./runtime-DTft3h2S.js";import"./index-CAd6FKzO.js";import"react-dom";import"react-dom/client";import{I as ya}from"./image-plus-CJraVezv.js";const Te=1e3,mt=25,pt=({folderPath:e="public/document_builder",recursive:n=!0,searchQuery:s="",resultLimit:r,resultOffset:i,sortBy:l="alphabetical",excludeFolders:d=!1,pVersionType:v="thumbnail",enabled:x=!0}={})=>{var k,I;const{toast:j}=Ie(),R=Ut({queryKey:["documentAssets",e,n,s,l,d,v,r??"all",r!==void 0?i??0:0],queryFn:async()=>{var M,O;try{if(r!==void 0){const H=await Ge({folderPath:e,recursive:n,searchQuery:s,resultLimit:r,resultOffset:i,sortBy:l,excludeFolders:d,pVersionType:v});if(H.statusCode!==200)throw new Error("Failed to fetch document assets");return H.data||{data:[],metadata:{query:s,limit:r,offset:i??0,totalCount:0}}}const P=[];let E=0,z=s,q=0,X=!0;for(let H=0;H<mt;H+=1){const G=await Ge({folderPath:e,recursive:n,searchQuery:s,resultLimit:Te,resultOffset:q,sortBy:l,excludeFolders:d,pVersionType:v});if(G.statusCode!==200)throw new Error("Failed to fetch document assets");const F=G.data,_=(F==null?void 0:F.data)??[];P.push(..._);const J=((M=F==null?void 0:F.metadata)==null?void 0:M.totalCount)??0;if(J>0&&(E=J),z=((O=F==null?void 0:F.metadata)==null?void 0:O.query)??s,_.length<Te||E>0&&P.length>=E){X=!1;break}q+=Te}return X&&console.warn(`[useDocumentAssetsList] Hit the ${mt}-page safety cap after ${P.length} assets \u2014 list truncated.`),{data:P,metadata:{query:z,limit:P.length,offset:0,totalCount:Math.max(E,P.length)}}}catch(P){throw j({title:"Error",description:"Failed to fetch document assets. Please try again.",variant:"destructive"}),P}},enabled:x,refetchOnWindowFocus:!1,staleTime:300*1e3,gcTime:600*1e3});return{assets:((k=R.data)==null?void 0:k.data)||[],metadata:(I=R.data)==null?void 0:I.metadata,isLoading:R.isLoading,error:R.error,refetch:R.refetch}};function va(e){const n=e.lastIndexOf("/");return n>=0?e.slice(0,n):""}function ba(e,n){return`${va(e)}/${n.trim()}`}const wa=["image/png","image/jpeg","image/jpg","image/svg+xml"],ht=e=>e.message?`${e.filename} (${e.message})`:e.filename,xa=["thumbnail","original","compressed"],Ca=e=>{for(const n of xa){const s=`${Ae}${e}:${n}`;Gt(s),Qt(Kt(s))}},ke=100,Na=e=>`${e} ${e===1?"item":"items"}`,$a=e=>{const n=e==null?void 0:e.detail;return typeof n=="string"&&n?n:"The items could not be moved."},La=(e={})=>{const{filterPath:n,allowedTypes:s=wa,imagesOnly:r=!0}=e,{captureException:i}=Mt(),{toast:l}=Ie(),d=Et(),[v,x]=U(!1),[k,I]=U(!1),[j,R]=U(!1),[M,O]=U(!1),[P,E]=U(!1),{assets:z,isLoading:q,refetch:X}=pt({}),H=Le(()=>{let g=z.filter(c=>c.type===ne.FILE);return n&&(g=g.filter(c=>c.path.startsWith(n))),r&&(g=g.filter(c=>c.name.toLowerCase().endsWith(".png")||c.name.toLowerCase().endsWith(".jpg")||c.name.toLowerCase().endsWith(".jpeg")||c.name.toLowerCase().endsWith(".svg"))),g.map(c=>({id:c.id||`${c.name}-${c.path}`,src:c.id?`${Ae}${c.id}:thumbnail`:c.path,originalSrc:c.id?`${Ae}${c.id}:original`:c.path,name:c.name,path:c.path,createdAt:c.createdAt,type:c.type})).sort((c,b)=>!c.createdAt||!b.createdAt?0:new Date(c.createdAt).getTime()-new Date(b.createdAt).getTime())},[z,n,r]),G=D(g=>Array.from(g).filter(c=>s.includes(c.type)),[s]),F=D(async(g,c)=>{const b=G(g);if(b.length===0)return l({title:"Invalid file types",description:"Only PNG, JPG, and SVG files are allowed.",variant:"destructive"}),null;try{x(!0);const p=await Qe(b,{path:c});if(p.statusCode===200){const w=p.data,B=(w==null?void 0:w.count)??0,A=((w==null?void 0:w.assets)??[]).filter(ee=>ee.status==="error");return B===0||(w==null?void 0:w.status)==="error"?(l({title:"Upload failed",description:A.length>0?A.map(ht).join(", "):"No files could be uploaded.",variant:"destructive"}),null):(l({title:"Upload successful",description:`${B} file(s) uploaded successfully.`,variant:"success"}),A.length>0&&l({title:"Some files failed to upload",description:A.map(ht).join(", "),variant:"destructive"}),await d.invalidateQueries({queryKey:["documentAssets"]}),(w==null?void 0:w.assets)||null)}else throw new Error("Upload failed")}catch(p){return l({title:"Upload failed",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{filesCount:b.length,path:c}}}),null}finally{x(!1)}},[G,l,i,d]),_=D(async(g,c)=>{try{if(I(!0),(await zt(g)).statusCode===200)return l({title:"Image deleted",description:c?`"${c}" deleted successfully.`:"Image deleted successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),Ca(g),!0;throw new Error("Delete failed")}catch(b){return l({title:"Delete failed",description:b instanceof Error?b.message:"An unknown error occurred",variant:"destructive"}),i({error:b,contexts:{payload:{assetId:g,assetName:c}}}),!1}finally{I(!1)}},[l,i,d]),J=D(async(g,c="public/document_builder")=>{const b=`${c}/${g.trim()}`;try{const p=await Ht({path:b});if(p.statusCode===201||p.statusCode===200)return l({title:"Category created",description:`Category "${g}" created successfully.`,variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Failed to create category")}catch(p){return l({title:"Failed to create category",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{categoryName:g,categoryPath:b}}}),!1}},[l,i,d]),pe=D(async(g,c,b=!0)=>{try{const p=await Wt({path:g,recursive:b});if(p.statusCode===204||p.statusCode===200)return l({title:"Category deleted",description:c?`Category "${c}" and all its contents deleted successfully.`:"Category deleted successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Failed to delete category")}catch(p){return l({title:"Failed to delete category",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{categoryPath:g,categoryName:c}}}),!1}},[l,i,d]),de=D(async(g,c,b)=>{try{if(R(!0),(await qt({assetId:g,newFilename:c})).statusCode===200)return l({title:"Image renamed",description:b?`"${b}" renamed to "${c}" successfully.`:"Image renamed successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Rename failed")}catch(p){return l({title:"Rename failed",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{assetId:g,newFilename:c}}}),!1}finally{R(!1)}},[l,i,d]),Q=D(async(g,c)=>{const b=ba(g,c);try{O(!0);const p=await _t({oldPath:g,newPath:b}),w=p.data;if(p.statusCode===200&&(w==null?void 0:w.success)!==!1)return l({title:"Folder renamed",description:`Folder renamed to "${c}" successfully.`,variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),{success:!0,newPath:(w==null?void 0:w.newPath)??b};const B=(w==null?void 0:w.detail)??(w==null?void 0:w.message)??"A folder with that name already exists.";return l({title:"Rename failed",description:B,variant:"destructive"}),{success:!1,error:B}}catch(p){const w=p instanceof Error?p.message:"An unknown error occurred";return l({title:"Rename failed",description:w,variant:"destructive"}),i({error:p,contexts:{payload:{oldPath:g,newPath:b}}}),{success:!1,error:w}}finally{O(!1)}},[l,i,d]),re=D(async({targetPath:g,targetName:c,assetIds:b,folderPaths:p})=>{var w;const B=b.length+p.length,A=[],ee=new Set;let S=0;try{E(!0);let K=null;for(let V=0;V<B;V+=ke){const Z=p.slice(V,V+ke),ae=Math.max(0,V-p.length),se=b.slice(ae,ae+ke-Z.length),ce=[...se,...Z];if(K===null){const Y=await Bt({targetPath:g,assetIds:se,folderPaths:Z});if(Y.statusCode===200&&Y.data){const he=Y.data;S+=((w=he.moved)==null?void 0:w.length)??0,A.push(...(he.failed??[]).map(({source:ue,message:Ce})=>({source:ue,message:Ce}))),ce.forEach(ue=>ee.add(ue));continue}K=$a(Y.data)}const xe=K;A.push(...ce.map(Y=>({source:Y,message:xe}))),ce.forEach(Y=>ee.add(Y))}if(S>0&&await d.invalidateQueries({queryKey:["documentAssets"]}),K!==null&&S===0)return l({title:"Move failed",description:K,variant:"destructive"}),{success:!1,movedCount:0,failed:A};const te=A[0];return te?(l({title:S>0?"Some items were not moved":"Move failed",description:`Moved ${S} of ${B} \u2014 ${A.length} failed: ${te.message}`,variant:"destructive"}),{success:!1,movedCount:S,failed:A}):(l({title:"Move complete",description:`Moved ${Na(S)} to ${c}`,variant:"success"}),{success:!0,movedCount:S,failed:A})}catch(K){const te=K instanceof Error?K.message:"An unknown error occurred",V=[...b,...p].filter(Z=>!ee.has(Z));return A.push(...V.map(Z=>({source:Z,message:te}))),l({title:S>0?"Some items were not moved":"Move failed",description:S>0?`Moved ${S} of ${B} \u2014 ${A.length} failed: ${te}`:te,variant:"destructive"}),i({error:K,contexts:{payload:{targetPath:g,assetIds:b,folderPaths:p}}}),await d.invalidateQueries({queryKey:["documentAssets"]}),{success:!1,movedCount:S,failed:A}}finally{E(!1)}},[l,i,d]);return{assets:H,rawAssets:z,isLoading:q,isUploading:v,isDeleting:k,isRenaming:j,isRenamingFolder:M,isMoving:P,uploadAssets:F,deleteAsset:_,renameAsset:de,renameFolder:Q,moveItems:re,createCategory:J,deleteCategory:pe,validateFiles:G,refetch:X}};function gt(){const{preferences:e}=Vt(),{user:n,isSuperAdmin:s}=Jt(),r=s||(n==null?void 0:n.role)===Ke.Admin||(n==null?void 0:n.role)===Ke.SuperAdmin,i=e==null?void 0:e[Yt.IMAGE_LIBRARY.RESTRICT_NON_ADMIN_UPDATES],l=i===!0||i==="true";return Le(()=>({canManageImageLibrary:r||!l}),[r,l])}const ve={LOGO:"public/document_builder/logo",BACKGROUND:"public/document_builder/background",PROFILES:"public/document_builder/profiles",CLIPBOARD:"public/document_builder/clipboard-uploads"};Ve.create({name:"fontFamily",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,parseHTML:e=>{var n;return((n=e.style.fontFamily)==null?void 0:n.replace(/['"]+/g,""))||null},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]}}),Ve.create({name:"fontSize",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize||null,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]}}),Zt.create({name:"variable",group:"inline",inline:!0,atom:!0,selectable:!1,draggable:!1,addAttributes(){return{name:{default:null,parseHTML:e=>e.getAttribute("data-variable"),renderHTML:e=>e.name?{"data-variable":e.name}:{}},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name"),renderHTML:e=>e.displayName?{"data-display-name":e.displayName}:{}},value:{default:null,parseHTML:e=>e.getAttribute("data-variable-value"),renderHTML:e=>e.value==null?{}:{"data-variable-value":e.value}},casedValue:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-variable]"}]},renderHTML({node:e,HTMLAttributes:n}){const s=e.attrs.displayName||e.attrs.name||"",r=e.attrs.value!=null&&e.attrs.value!=="";return["span",Xt(n,{class:r?"variable-highlight variable-highlight--bound":"variable-highlight"}),e.attrs.casedValue??(r?String(e.attrs.value):`[${s}]`)]},renderText({node:e}){return`{%${e.attrs.name}%}`}});const Ia={sm:"aspect-square",md:"aspect-square",lg:"aspect-square"},ft=ge(({id:e,src:n,name:s,isUploading:r=!1,isDeleting:i=!1,isRenaming:l=!1,disabled:d=!1,onClick:v,onDelete:x,onRename:k,onDragStart:I,draggable:j=!1,size:R="md",objectFit:M="contain",className:O="",showDeleteButton:P=!0,showRenameButton:E=!0})=>{const z=d||r||i||l,q=F=>{!z&&v&&v(F)},X=F=>{!r&&I&&I(F)},H=F=>{F.stopPropagation(),x&&!i&&x()},G=F=>{F.stopPropagation(),k&&!l&&k()};return N("div",{className:`${Ia[R]} rounded-lg overflow-hidden group transition-all duration-200 border border-neutral06 hover:border-primary02 hover:shadow-md relative bg-neutral07 ${r?"cursor-default":z?"cursor-not-allowed opacity-50":j?"cursor-grab active:cursor-grabbing hover:cursor-pointer":"cursor-pointer"} ${O}`,draggable:j&&!r,onDragStart:X,onClick:q,title:`${s} ${r?"(uploading...)":j?"(drag to canvas)":""}`,children:[r?N($e,{children:[a("img",{src:n,alt:s,className:"w-full h-full object-contain opacity-50",loading:"lazy"}),a("div",{className:"absolute inset-0 bg-neutral07 flex items-center justify-center z-10",children:a(Je,{size:6,className:"text-neutral03"})})]}):a(Ye,{src:n,alt:s,className:"w-full h-full transition-transform duration-200 group-hover:scale-105",objectFit:M,outerClassName:"w-full h-full",lazy:!0}),!r&&E&&k&&a("div",{className:"absolute top-1 left-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-20",children:a(Ze,{variant:"ghost",size:"sm",onClick:G,className:"!p-1 !w-6 !h-6 !min-w-0 bg-white/90 dark:bg-neutral-900/90 !rounded-full shadow-sm",title:"Rename image",disabled:l,icon:a(ea,{className:"h-3 w-3 text-neutral02"}),tooltip:"Rename image"})}),!r&&P&&x&&a("div",{className:"absolute top-1 right-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-20",children:a(Ze,{variant:"ghost",size:"sm",onClick:H,className:"!p-1 !w-6 !h-6 !min-w-0 bg-white/90 dark:bg-neutral-900/90 !rounded-full shadow-sm",title:"Delete image",disabled:i,icon:a(De,{className:"h-3 w-3 text-error"}),tooltip:"Delete image"})})]})},(e,n)=>e.id===n.id&&e.src===n.src&&e.isUploading===n.isUploading&&e.isDeleting===n.isDeleting&&e.isRenaming===n.isRenaming&&e.disabled===n.disabled);ft.displayName="AssetThumbnail";const Aa={sm:"aspect-square",md:"aspect-square",lg:"aspect-square"},Da={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"},yt=ge(({onClick:e,size:n="md",disabled:s=!1,title:r="Upload new image",className:i=""})=>a("div",{onClick:s?void 0:e,className:`${Aa[n]} border-2 border-dashed border-neutral04 rounded-lg flex items-center justify-center transition-colors group ${s?"cursor-not-allowed opacity-50":"cursor-pointer hover:border-primary02 hover:bg-primary05"} ${i}`,title:r,children:a(Xe,{className:`${Da[n]} text-neutral03 ${!s&&"group-hover:text-primary02"} transition-colors`})}));yt.displayName="AddAssetButton";const Oa="image/png,image/jpeg,image/jpg,image/svg+xml",vt=Be(({onFileSelect:e,accept:n=Oa,multiple:s=!0,disabled:r=!1,id:i},l)=>{const d=D(v=>{e(v.target.files),v.target.value=""},[e]);return a("input",{ref:l,id:i,type:"file",multiple:s,accept:n,onChange:d,disabled:r,className:"hidden"})});vt.displayName="AssetUploadInput";const bt=ge(({isOpen:e,onClose:n,onConfirm:s,assetName:r,assetType:i="image",imageCount:l=0,title:d,description:v})=>a(ta,{isOpen:e,onClose:n,onConfirm:s,title:d||(i==="category"?"Delete Category":"Delete Image"),description:v||(i==="category"?l>0?`Are you sure you want to delete the "${r}" category? This will permanently delete all ${l} image${l!==1?"s":""} in this category. This action cannot be undone.`:`Are you sure you want to delete the "${r}" category? This action cannot be undone.`:`Are you sure you want to delete "${r}"? This action cannot be undone.`),confirmText:"Delete",cancelText:"Cancel",modal:!0,closeOnOutsideClick:!1}));bt.displayName="DeleteAssetDialog";const Ta=Object.freeze(Object.defineProperty({__proto__:null,DeleteAssetDialog:bt},Symbol.toStringTag,{value:"Module"})),wt=Oe(()=>import("./runtime-DTft3h2S.js").then(e=>e.oS).then(e=>e.FolderNameDialog),{}),xt=Oe(()=>Promise.resolve().then(()=>Ta).then(e=>e.DeleteAssetDialog),{}),ka=Oe(()=>import("./RenameAssetDialog-B-E9YwOl.js").then(e=>e.RenameAssetDialog),{});function Fa(e,n){const s=`${n}/`,r=[],i=[],l=new Map;for(const d of e){if(d.type!==ne.FILE||!d.path.startsWith(s))continue;const v=d.path.slice(s.length),x=v.indexOf("/");if(x<=0)continue;const k=`${n}/${v.slice(0,x)}`;l.set(k,(l.get(k)??0)+1)}for(const d of e){if(!d.path.startsWith(s))continue;const v=d.path.slice(s.length);v.length===0||v.includes("/")||(d.type===ne.FOLDER?r.push({name:d.name,path:d.path,imageCount:l.get(d.path)??0}):d.type===ne.FILE&&i.push(d))}return r.sort((d,v)=>d.name.localeCompare(v.name)),{folders:r,fileAssets:i}}function Fe(e){const n=e.lastIndexOf("/");return n>=0?e.slice(0,n):""}const ja="Untitled";function je(e){var n,s;return((s=(n=e.assetMetadata)==null?void 0:n.originalFilename)==null?void 0:s.trim())||ja}const be=[{name:"Logo",path:ve.LOGO},{name:"Background",path:ve.BACKGROUND},{name:"Profiles",path:ve.PROFILES},{name:"Clipboard Uploads",path:ve.CLIPBOARD}],Re=Be(({onImageSelect:e,gridColumns:n=3,hideDeleteButton:s,hideHeader:r,pickerMode:i=!1},l)=>{const[d,v]=U("logo"),[x,k]=U(""),{assets:I,isLoading:j}=pt({}),{toast:R}=Ie(),{canManageImageLibrary:M}=gt(),O=!M,{uploadAssets:P,deleteAsset:E,renameAsset:z,createCategory:q,deleteCategory:X,isDeleting:H,isRenaming:G,validateFiles:F}=La(),[_,J]=U(()=>be.map(t=>({id:t.name.toLowerCase(),name:t.name,images:[],isDefault:!0,path:t.path,isFetched:!1,fileCount:0,isCountFetched:!1})));Pt(()=>{if(I.length===0)return;const t="public/document_builder/",u=I.filter(f=>{if(f.type!==ne.FOLDER||!f.path.startsWith(t))return!1;const y=f.path.slice(t.length);return y.length>0&&!y.includes("/")}).map(f=>{const y=I.filter(C=>C.path.startsWith(f.path)&&C.type===ne.FILE),$=be.find(C=>C.path===f.path||C.name.toLowerCase()===f.name.toLowerCase()),L=!!$,ie=L?$.name.toLowerCase():f.id||`${f.name}-${f.path}`;return{id:ie,name:f.name,images:y.map(C=>({id:C.id||`${C.name}-${C.path}`,src:C.id?ye(C.id):C.path,thumbnailSrc:C.id?et(C.id):C.path,name:je(C),category:ie,path:C.path,isLoaded:!1,createdAt:C.createdAt})).sort((C,le)=>!C.createdAt||!le.createdAt?0:new Date(C.createdAt).getTime()-new Date(le.createdAt).getTime()),isDefault:L,path:f.path,isFetched:!0,fileCount:y.length,isCountFetched:!0}}),m=be.map(f=>u.find($=>$.path===f.path||$.name.toLowerCase()===f.name.toLowerCase())||{id:f.name.toLowerCase(),name:f.name,images:[],isDefault:!0,path:f.path,isFetched:!0,fileCount:0,isCountFetched:!0}),h=u.filter(f=>!be.some(y=>f.path===y.path||f.name.toLowerCase()===y.name.toLowerCase())),T=[...m,...h];J(f=>T.map(y=>{const $=f.find(L=>L.id===y.id);return $&&$.images.filter(L=>L.isUploading).forEach(L=>{L.src.startsWith("blob:")&&URL.revokeObjectURL(L.src)}),y}))},[I]);const[pe,de]=U(null),[Q,re]=U(null),[g,c]=U(null),[b,p]=U(null),[w,B]=U({}),[A,ee]=U(null),[S,K]=U(null),te=fe({}),V=fe(_);V.current=_;const Z=D(t=>w[t.id]??t.path??"",[w]);St(l,()=>({createCategory:async t=>{await q(t)},getActiveCategoryPath:()=>{if(!d)return null;const t=V.current.find(u=>u.id===d);return t?w[t.id]??t.path??null:null}}),[q,d,w]);const ae=D(async(t,u)=>{if(!u)return;const m=F(u);if(m.length===0)return;if(O){R({title:"Image library is admin-managed",description:"Only admins can add images to the shared library.",variant:"destructive"});return}const h=V.current.find($=>$.id===t);if(!(h!=null&&h.path))return;const T=w[t]??h.path,f=Date.now(),y=m.map($=>{const L=URL.createObjectURL($);return{id:`temp_${t}_${f}_${Math.random()}`,src:L,thumbnailSrc:L,name:$.name,category:t,path:`${T}/${$.name}`,isUploading:!0,isLoaded:!0,uploadTimestamp:f}});J($=>$.map(L=>L.id===t?{...L,images:[...L.images,...y]}:L)),await P(m,T)||(J($=>$.map(L=>L.id===t?{...L,images:L.images.filter(ie=>!ie.isUploading)}:L)),y.forEach($=>URL.revokeObjectURL($.src)))},[F,P,w,O,R]),se=D(t=>{var u;(u=te.current[t])==null||u.click()},[]),ce=(t,u)=>{t.preventDefault(),t.stopPropagation(),de(u)},xe=t=>{t.preventDefault(),t.stopPropagation(),de(null)},Y=D((t,u)=>{t.preventDefault(),t.stopPropagation(),de(null);const m=t.dataTransfer.files;ae(u,m)},[ae]),he=D(async t=>{if(t.isUploading){J(u=>u.map(m=>m.id===t.category?{...m,images:m.images.filter(h=>h.id!==t.id)}:m)),URL.revokeObjectURL(t.src),c(null),re(null);return}await E(t.id,t.name)&&J(u=>u.map(m=>m.id===t.category?{...m,images:m.images.filter(h=>h.id!==t.id)}:m)),c(null),re(null)},[E]),ue=D(async(t,u)=>{if(!t.id){p(null);return}await z(t.id,u,t.name)&&J(m=>m.map(h=>h.id===t.category?{...h,images:h.images.map(T=>T.id===t.id?{...T,name:u}:T)}:h)),p(null)},[z]),Ce=D(async(t,u)=>{await X(u.path,u.name,!0)&&B(m=>{const h=m[t];if(!h||h!==u.path&&!h.startsWith(`${u.path}/`))return m;const T={...m},f=Fe(u.path),y=V.current.find($=>$.id===t);return!f||y!=null&&y.path&&f===y.path?delete T[t]:T[t]=f,T}),ee(null)},[X]),At=D(async t=>S?await q(t,S.parentPath):!1,[q,S]),Se=D((t,u)=>{const m=t.currentTarget.querySelector("img");let h=u.width,T=u.height;m&&(!h||!T)&&(h=m.naturalWidth,T=m.naturalHeight);const f={type:"image",src:u.src,name:u.name,category:u.category,path:u.path,width:h,height:T};if(t.dataTransfer.setData("application/json",JSON.stringify(f)),t.dataTransfer.effectAllowed="copy",m&&m.src&&!m.src.startsWith(tt)){const y=document.createElement("img");y.src=m.src,y.style.position="absolute",y.style.top="-1000px",y.style.width="80px",y.style.height="80px",y.style.objectFit="contain",y.style.pointerEvents="none",y.style.border="2px solid #000",y.style.borderRadius="4px",y.style.backgroundColor="white",document.body.appendChild(y),t.dataTransfer.setDragImage(y,40,40),setTimeout(()=>{document.body.contains(y)&&document.body.removeChild(y)},0)}},[]),Ue=D((t,u)=>{if(t.isUploading)return;let m=t;if(u){const h=u.currentTarget.querySelector("img");h&&h.naturalWidth&&h.naturalHeight&&(m={...t,width:h.naturalWidth,height:h.naturalHeight})}e?e(m):re(m)},[e]),Dt=D(t=>{const u=j||!t.isFetched,m=Z(t),h=!!t.path&&m!==t.path,T=s||O,{folders:f,fileAssets:y}=m?Fa(I,m):{folders:[],fileAssets:[]},$=y.map(o=>({id:o.id||`${o.name}-${o.path}`,src:o.id?ye(o.id):o.path,thumbnailSrc:o.id?et(o.id):o.path,name:je(o),category:t.id,path:o.path,isLoaded:!1,createdAt:o.createdAt})).sort((o,W)=>!o.createdAt||!W.createdAt?0:new Date(o.createdAt).getTime()-new Date(W.createdAt).getTime()),L=t.images.filter(o=>o.isUploading&&o.path&&Fe(o.path)===m),ie=f.length===0&&$.length===0&&L.length===0,C=x.trim().toLowerCase(),le=o=>o.toLowerCase().includes(C),He=C?f.filter(o=>le(o.name)):f,We=C?$.filter(o=>le(o.name)):$,qe=C?L.filter(o=>le(o.name)):L,kt=!!C&&He.length===0&&We.length===0&&qe.length===0,Ft=()=>{if(!h||!t.path)return;const o=Fe(m);B(W=>{const Ne={...W};return!o||o===t.path?delete Ne[t.id]:Ne[t.id]=o,Ne})},jt=o=>{B(W=>({...W,[t.id]:o}))},Rt=()=>u?a("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:[...Array(n*2)].map((o,W)=>a(la,{className:"aspect-square rounded-lg"},W))}):t.isLoading?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(Je,{size:6,className:"text-neutral03 mb-2"}),a("p",{className:"text-xs text-neutral03",children:"Loading images..."})]}):ie?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(oa,{className:"h-6 w-6 text-neutral03 mb-2"}),a("p",{className:"text-xs text-neutral03 mb-3",children:O?"No images in this folder.":"No images in this folder. Upload or drop images here."}),!O&&a(oe,{variant:"outline",size:"sm",onClick:()=>se(t.id),className:"flex items-center gap-2",leftIcon:a(it,{className:"h-4 w-4"}),children:"Upload Images"})]}):kt?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(at,{className:"h-6 w-6 text-neutral03 mb-2"}),N("p",{className:"text-xs text-neutral03",children:['No images match "',x,'".']})]}):N("div",{className:"grid gap-3 items-start",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:[!C&&!O&&a(yt,{onClick:()=>se(t.id)}),He.map(o=>{const W=o.name.toLowerCase().replace(/\s+/g,"-");return a(Ct,{folder:o,testId:`image-options-folder-${t.id}-${W}`,onOpen:()=>jt(o.path),onDelete:T?void 0:()=>ee({categoryId:t.id,folder:o})},o.path)}),[...We,...qe].map(o=>N("div",{className:"flex flex-col gap-1 min-w-0",children:[a(ft,{id:o.id,src:o.thumbnailSrc,name:o.name,isUploading:o.isUploading,isDeleting:H,isRenaming:G,draggable:!o.isUploading&&!i,onDragStart:i?void 0:W=>Se(W,o),onClick:W=>Ue(o,W),onDelete:T?void 0:()=>c(o),showDeleteButton:!T}),a("p",{title:o.name,className:"text-xs text-neutral01 truncate",children:o.name})]},o.id))]});return N("div",{className:`flex-1 min-h-0 flex flex-col transition-colors duration-200 ${pe===t.id?"bg-primary05/40":""}`,onDragOver:o=>ce(o,t.id),onDragLeave:xe,onDrop:o=>Y(o,t.id),children:[N("div",{className:`flex items-center gap-2 px-4 ${r?"pt-1":"pt-3"} pb-4 shrink-0`,children:[h?N("button",{type:"button","data-testid":`image-options-back-${t.id}`,onClick:Ft,className:"inline-flex items-center gap-1 text-xs text-primary01 hover:underline shrink-0",children:[a(aa,{className:"h-3.5 w-3.5"}),"Back"]}):null,h&&a("span",{"data-testid":`image-options-current-folder-${t.id}`,title:m,className:"text-xs font-medium text-neutral01 capitalize truncate shrink-0",children:m.split("/").pop()}),N("div",{className:"relative flex-1 min-w-0",children:[a(at,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-neutral03"}),a(na,{type:"search",value:x,onChange:o=>k(o.target.value),placeholder:"Search images","data-testid":`image-options-search-${t.id}`,className:"h-8 w-full pl-7 text-xs"})]}),!i&&!O&&a(oe,{size:"sm",variant:"outline","data-testid":`image-options-new-folder-${t.id}`,onClick:()=>K({categoryId:t.id,parentPath:m}),className:"shrink-0 h-8 px-3 text-xs",leftIcon:a(ra,{className:"h-3.5 w-3.5"}),children:"New Folder"})]}),a("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:Rt()}),a(vt,{ref:o=>{o&&(te.current[t.id]=o)},id:`asset-upload-${t.id}`,onFileSelect:o=>ae(t.id,o)})]})},[I,Z,se,Se,Ue,ae,Y,H,G,j,pe,n,s,r,i,x,O]),[Ot,Me]=U(!1),Tt=D(async t=>await q(t),[q]),Ee=_.find(t=>t.id===d)??null,me=x.trim().toLowerCase(),ze=Le(()=>{if(!me)return null;const t=new Map;for(const u of _){if(!u.path)continue;const m=I.filter(h=>h.type===ne.FILE&&h.path.startsWith(`${u.path}/`)&&je(h).toLowerCase().includes(me)).length;t.set(u.id,m)}return t},[me,_,I]);return N($e,{children:[N("div",{"data-testid":"image-options",className:"flex flex-col h-[640px] max-h-[70vh] bg-white overflow-hidden dark:bg-neutral-900",children:[!r&&a("div",{"data-testid":"image-options-header",className:"flex items-center justify-between px-4 py-3 border-b border-neutral06 shrink-0",children:a("span",{className:"text-sm font-semibold text-neutral01",children:"Image Library"})}),N("div",{className:"flex flex-1 min-h-0",children:[N("div",{"data-testid":"image-options-categories",className:`w-[170px] shrink-0 border-r border-neutral06 overflow-y-auto px-2 pb-2 ${r?"pt-1":"pt-2"}`,children:[!i&&!O&&a(oe,{size:"sm",variant:"outline","data-testid":"image-options-new-category",onClick:()=>Me(!0),className:"w-full justify-center mb-3",leftIcon:a(Xe,{className:"h-3.5 w-3.5"}),children:"Add category"}),j&&_.every(t=>!t.isFetched)?a("ul",{className:"flex flex-col gap-1",children:Array.from({length:4}).map((t,u)=>a("li",{className:"h-9 rounded-md bg-neutral07 animate-pulse"},u))}):_.length===0?a("p",{className:"text-[11px] text-neutral03 px-2 py-2",children:"No categories yet."}):a("ul",{className:"flex flex-col gap-0.5",children:_.map(t=>{const u=d===t.id,m=t.name.toLowerCase().replace(/\s+/g,"-"),h=me?(ze==null?void 0:ze.get(t.id))??0:t.fileCount??0,T=me?!0:h>0;return a("li",{children:N("button",{type:"button","data-testid":`image-options-category-${m}`,"aria-current":u?"true":void 0,onClick:()=>v(t.id),className:`w-full flex items-center justify-between gap-2 h-9 px-3 rounded-md text-xs font-medium capitalize transition-colors ${u?"bg-primary05 text-primary01":"text-neutral02 hover:bg-neutral07"}`,children:[a("span",{className:"truncate",children:t.name}),T&&a("span",{className:`shrink-0 text-[11px] font-normal normal-case ${u?"text-primary01":"text-neutral03"}`,children:h})]})},t.id)})})]}),a("div",{"data-testid":"image-options-pane",className:"flex-1 min-w-0 min-h-0 flex flex-col",children:Ee?Dt(Ee):a("div",{className:"h-full flex items-center justify-center text-xs text-neutral03 px-4 text-center",children:"Select or create a category to get started."})})]})]}),Q&&a(nt,{open:!!Q,onOpenChange:()=>re(null),children:N(rt,{className:"w-full max-w-2xl",children:[a(st,{className:"flex flex-row items-center gap-1.5 text-center sm:text-left",children:a("span",{className:"text-lg font-semibold leading-none tracking-tight",children:Q.name})}),a("div",{className:"flex justify-center p-4",children:a("div",{className:"relative w-full",style:{maxHeight:"384px",aspectRatio:Q.width&&Q.height?`${Q.width} / ${Q.height}`:"auto"},children:a(Ye,{src:Q.src,alt:Q.name,className:"w-full h-full object-contain rounded-lg",objectFit:"contain",outerClassName:"w-full h-full"})})}),N(sa,{children:[!O&&a(oe,{variant:"destructive",onClick:()=>c(Q),leftIcon:a(De,{className:"h-4 w-4"}),disabled:H,isLoading:H,children:"Delete"}),a(ia,{asChild:!0,children:a(oe,{variant:"outline",disabled:H,children:"Close"})})]})]})}),a(xt,{isOpen:!!g,onClose:()=>c(null),onConfirm:async()=>{g&&await he(g)},assetName:g==null?void 0:g.name,assetType:"image"}),a(ka,{isOpen:!!b,onClose:()=>p(null),onConfirm:async t=>{b&&await ue(b,t)},currentName:b==null?void 0:b.name,isRenaming:G}),a(wt,{isOpen:Ot,onClose:()=>Me(!1),onSubmit:Tt,title:"Create New Category",inputLabel:"Category Name",placeholder:"Enter category name"}),a(wt,{isOpen:!!S,onClose:()=>K(null),onSubmit:At,title:"Create New Folder"}),a(xt,{isOpen:!!A,onClose:()=>ee(null),onConfirm:async()=>{A&&await Ce(A.categoryId,A.folder)},assetName:A==null?void 0:A.folder.name,assetType:"category",imageCount:A==null?void 0:A.folder.imageCount})]})});Re.displayName="ImageOptions";const Ct=ge(({folder:e,testId:n,onOpen:s,onDelete:r})=>N("div",{className:"relative group",children:[N("button",{type:"button","data-testid":n,onClick:s,title:e.name,className:"aspect-square w-full rounded-lg border border-neutral06 bg-neutral08 hover:border-primary02 hover:bg-primary05/30 focus:outline-none focus:ring-2 focus:ring-primary02 flex flex-col items-center justify-center gap-1 transition-colors p-2",children:[a(da,{className:"h-6 w-6 text-neutral03",strokeWidth:1.5}),a("span",{className:"text-[11px] font-medium text-neutral02 capitalize truncate max-w-full",children:e.name}),N("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-neutral03",children:[e.imageCount,a(ca,{className:"h-3 w-3"})]})]}),r&&a("button",{type:"button","data-testid":`${n}-delete`,"aria-label":`Delete folder ${e.name}`,title:`Delete folder ${e.name}`,onClick:i=>{i.stopPropagation(),r()},className:"absolute top-1.5 right-1.5 w-6 h-6 inline-flex items-center justify-center rounded-md bg-white/90 dark:bg-neutral-900/90 text-neutral02 shadow-sm border border-neutral06 opacity-0 group-hover:opacity-100 hover:text-red-600 focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary02 transition-opacity",children:a(De,{className:"h-3.5 w-3.5"})})]}));Ct.displayName="FolderTile";const Nt="Image library is admin-managed",$t="Only admins can upload new images. Ask your admin for access, or pick an existing image from the library.",Ra=`${Nt}. ${$t}`;function Pa(e){return!Number.isFinite(e)||e<1?1:Math.floor(e)}function Sa(e){const n=Pa(e),s=[];let r=0;const i=()=>{for(;r<n&&s.length>0;)s.shift().execute()};return{run:l=>new Promise((d,v)=>{const x=()=>{r+=1,Promise.resolve().then(l).then(d,v).finally(()=>{r-=1,i()})};s.push({execute:x}),i()}),get activeCount(){return r},get pendingCount(){return s.length}}}const Ua=e=>`${e.userId}/document_builder/document_images/${e.documentScope}`,Ma=e=>new Promise(n=>{const s=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(s),n({width:r.naturalWidth||void 0,height:r.naturalHeight||void 0})},r.onerror=()=>{URL.revokeObjectURL(s),n({})},r.src=s}),Ea=3,za=async(e,n)=>{const s=e.filter(lt),r=async l=>{var d,v,x;const[k,I]=await Promise.all([Ma(l),Qe([l],{path:Ua(n),compress:!0})]),j=ua(I);if(!j){const R=(x=(v=(d=I.data)==null?void 0:d.assets)==null?void 0:v[0])==null?void 0:x.message;throw new Error(R||`Inline image upload failed (${I.statusCode})`)}return{assetId:j.assetId,src:`${tt}${j.assetId}`,...k}},i=Sa(Ea);return Promise.all(s.map(l=>i.run(()=>r(l))))},Pe="Image upload failed \u2014 nothing was inserted.",Ha=`Unsupported image type \u2014 choose a ${ct.map(e=>e.replace("image/","").toUpperCase()).join(", ")} file.`,Wa=ct.join(","),Lt=e=>({assetId:e.id,src:fa(e.src)==="asset-ref"?e.src:ye(e.id),width:e.width,height:e.height});function qa({sessionRef:e,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,gridColumns:l}){const[d,v]=U(!1),{canManageImageLibrary:x}=gt(),k=!x,I=fe(null),j=D(async M=>{const O=Array.from(M.target.files??[]);if(M.target.value="",O.length===0)return;if(k){i==null||i(Ra);return}if(!s){i==null||i(Pe);return}if(!O.some(lt)){i==null||i(Ha);return}const P=e.current.id,E=()=>e.current.open&&e.current.id===P;v(!0);try{const z=await za(O,s);if(!E())return;if(z.length===0){i==null||i(Pe);return}r(z),n(!1)}catch{if(!E())return;i==null||i(Pe)}finally{v(!1)}},[s,k,i,r,n,e]),R=D(M=>{d||(r([Lt(M)]),n(!1))},[d,r,n]);return N($e,{children:[N(pa,{defaultValue:k?"library":"upload",className:"px-6 pb-6",children:[N(ha,{children:[a(ot,{value:"upload","data-testid":"insert-image-tab-upload",children:"Upload"}),a(ot,{value:"library","data-testid":"insert-image-tab-library",children:"Image Library"})]}),a(dt,{value:"upload",children:k?N("div",{className:"flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border py-10 text-center","data-testid":"inline-image-upload-restricted",children:[a(ga,{className:"h-8 w-8 text-muted-foreground"}),a("p",{className:"text-sm font-medium text-foreground",children:Nt}),a("p",{className:"max-w-[380px] text-xs text-muted-foreground",children:$t})]}):N("div",{className:"flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border-primary py-10 text-center",children:[a(ya,{className:"h-8 w-8 text-neutral03"}),a("p",{className:"text-sm text-neutral02",children:"PNG, JPG or WEBP. Images are stored securely with your document."}),a(oe,{variant:"primary",size:"sm",leftIcon:a(it,{className:"h-4 w-4"}),disabled:!s||d,isLoading:d,onClick:()=>{var M;return(M=I.current)==null?void 0:M.click()},"data-testid":"inline-image-upload-trigger",children:d?"Uploading\u2026":"Choose images"}),!s&&a("p",{className:"text-xs text-neutral03",children:"Uploads are unavailable until the document finishes loading."})]})}),a(dt,{value:"library",children:a("div",{className:"max-h-[70vh]",children:a(Re,{pickerMode:!0,hideHeader:!0,hideDeleteButton:!0,gridColumns:l,onImageSelect:R})})})]}),a("input",{ref:I,type:"file",accept:Wa,multiple:!0,className:"hidden","data-testid":"inline-image-file-input",onChange:j})]})}function _a({onOpenChange:e,onInsert:n,gridColumns:s}){const r=D(i=>{n([Lt(i)]),e(!1)},[n,e]);return a("div",{className:"px-6 pb-6",children:a("div",{className:"max-h-[70vh]",children:a(Re,{pickerMode:!0,hideHeader:!0,hideDeleteButton:!0,gridColumns:s,onImageSelect:r})})})}function Ba({open:e,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,title:l="Insert Image",gridColumns:d}){const v=s===void 0,x=fe({open:e,id:0});return x.current.open!==e&&(x.current={open:e,id:x.current.id+1}),a(nt,{open:e,onOpenChange:n,children:N(rt,{className:"w-full sm:max-w-[720px] p-0 overflow-hidden",closeOnOutsideClick:v,children:[a(st,{className:"px-6 pt-6",children:a(ma,{children:l})}),v?a(_a,{onOpenChange:n,onInsert:r,gridColumns:d}):a(qa,{sessionRef:x,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,gridColumns:d})]})})}const we="/images/image-placeholder.svg";function It(e){return e?/^(https?:|data:|blob:|\/)/.test(e):!0}function Ga({src:e,className:n,companyLogo:s}){const[r,i]=_e.useState(()=>It(e)?e:"");return _e.useEffect(()=>{if(It(e)){i(e);return}let l=!1;return ut(e,we,void 0,void 0,{companyLogo:s}).then(d=>{l||i(d)}).catch(()=>{l||i(we)}),()=>{l=!0}},[e,s]),r?a("img",{src:r,alt:"Logo",className:n}):null}function Qa({isOpen:e,onClose:n,onSelect:s}){return a(Ba,{open:e,onOpenChange:r=>{r||n()},title:"Select image",onInsert:r=>{const i=r[0];i&&s(ye(i.assetId))}})}async function Ka(e){try{const n=await ut(e,we);return!n||n===we?null:await new Promise(s=>{const r=new Image;r.onload=()=>{if(!r.naturalWidth||!r.naturalHeight){s(null);return}s({naturalWidth:r.naturalWidth,naturalHeight:r.naturalHeight})},r.onerror=()=>s(null),r.src=n})}catch{return null}}export{Qa as LogoLibraryDialog,Ga as ResolvedLogoImg,Ka as captureImageNaturalSize};
1
+ import{jsxs as N,Fragment as $e,jsx as a}from"react/jsx-runtime";import*as _e from"react";import{useState as U,useMemo as Le,useCallback as D,memo as ge,forwardRef as Be,useEffect as Pt,useRef as fe,useImperativeHandle as St}from"react";import{by as Ie,eT as Ut,iS as Ge,cf as Mt,cL as Et,iT as ne,D as Ae,iU as Qe,iV as zt,iW as Ht,iX as Wt,iY as qt,iZ as _t,i_ as Bt,i$ as Gt,l as Qt,m as Kt,bA as Vt,bz as Jt,eb as Ke,dd as Yt,cJ as Ve,j0 as Zt,j1 as Xt,az as Je,aL as Ye,bC as Ze,fH as ea,eD as De,eC as Xe,dz as ta,j2 as et,j3 as ye,j4 as tt,dp as aa,dE as at,c9 as na,bD as oe,eF as ra,c1 as nt,c2 as rt,c8 as st,ca as sa,cx as ia,cW as la,cX as oa,bT as it,dv as Oe,j5 as da,cV as ca,j6 as lt,j7 as ua,c3 as ma,e8 as pa,e9 as ha,ea as ot,hl as dt,j8 as ga,j9 as fa,ja as ct,hc as ut}from"./runtime-BifHPIs0.js";import"./index-DwvbZ9qn.js";import"react-dom";import"react-dom/client";import{I as ya}from"./image-plus-BcyqmHS0.js";const Te=1e3,mt=25,pt=({folderPath:e="public/document_builder",recursive:n=!0,searchQuery:s="",resultLimit:r,resultOffset:i,sortBy:l="alphabetical",excludeFolders:d=!1,pVersionType:v="thumbnail",enabled:x=!0}={})=>{var k,I;const{toast:j}=Ie(),R=Ut({queryKey:["documentAssets",e,n,s,l,d,v,r??"all",r!==void 0?i??0:0],queryFn:async()=>{var M,O;try{if(r!==void 0){const H=await Ge({folderPath:e,recursive:n,searchQuery:s,resultLimit:r,resultOffset:i,sortBy:l,excludeFolders:d,pVersionType:v});if(H.statusCode!==200)throw new Error("Failed to fetch document assets");return H.data||{data:[],metadata:{query:s,limit:r,offset:i??0,totalCount:0}}}const P=[];let E=0,z=s,q=0,X=!0;for(let H=0;H<mt;H+=1){const G=await Ge({folderPath:e,recursive:n,searchQuery:s,resultLimit:Te,resultOffset:q,sortBy:l,excludeFolders:d,pVersionType:v});if(G.statusCode!==200)throw new Error("Failed to fetch document assets");const F=G.data,_=(F==null?void 0:F.data)??[];P.push(..._);const J=((M=F==null?void 0:F.metadata)==null?void 0:M.totalCount)??0;if(J>0&&(E=J),z=((O=F==null?void 0:F.metadata)==null?void 0:O.query)??s,_.length<Te||E>0&&P.length>=E){X=!1;break}q+=Te}return X&&console.warn(`[useDocumentAssetsList] Hit the ${mt}-page safety cap after ${P.length} assets \u2014 list truncated.`),{data:P,metadata:{query:z,limit:P.length,offset:0,totalCount:Math.max(E,P.length)}}}catch(P){throw j({title:"Error",description:"Failed to fetch document assets. Please try again.",variant:"destructive"}),P}},enabled:x,refetchOnWindowFocus:!1,staleTime:300*1e3,gcTime:600*1e3});return{assets:((k=R.data)==null?void 0:k.data)||[],metadata:(I=R.data)==null?void 0:I.metadata,isLoading:R.isLoading,error:R.error,refetch:R.refetch}};function va(e){const n=e.lastIndexOf("/");return n>=0?e.slice(0,n):""}function ba(e,n){return`${va(e)}/${n.trim()}`}const wa=["image/png","image/jpeg","image/jpg","image/svg+xml"],ht=e=>e.message?`${e.filename} (${e.message})`:e.filename,xa=["thumbnail","original","compressed"],Ca=e=>{for(const n of xa){const s=`${Ae}${e}:${n}`;Gt(s),Qt(Kt(s))}},ke=100,Na=e=>`${e} ${e===1?"item":"items"}`,$a=e=>{const n=e==null?void 0:e.detail;return typeof n=="string"&&n?n:"The items could not be moved."},La=(e={})=>{const{filterPath:n,allowedTypes:s=wa,imagesOnly:r=!0}=e,{captureException:i}=Mt(),{toast:l}=Ie(),d=Et(),[v,x]=U(!1),[k,I]=U(!1),[j,R]=U(!1),[M,O]=U(!1),[P,E]=U(!1),{assets:z,isLoading:q,refetch:X}=pt({}),H=Le(()=>{let g=z.filter(c=>c.type===ne.FILE);return n&&(g=g.filter(c=>c.path.startsWith(n))),r&&(g=g.filter(c=>c.name.toLowerCase().endsWith(".png")||c.name.toLowerCase().endsWith(".jpg")||c.name.toLowerCase().endsWith(".jpeg")||c.name.toLowerCase().endsWith(".svg"))),g.map(c=>({id:c.id||`${c.name}-${c.path}`,src:c.id?`${Ae}${c.id}:thumbnail`:c.path,originalSrc:c.id?`${Ae}${c.id}:original`:c.path,name:c.name,path:c.path,createdAt:c.createdAt,type:c.type})).sort((c,b)=>!c.createdAt||!b.createdAt?0:new Date(c.createdAt).getTime()-new Date(b.createdAt).getTime())},[z,n,r]),G=D(g=>Array.from(g).filter(c=>s.includes(c.type)),[s]),F=D(async(g,c)=>{const b=G(g);if(b.length===0)return l({title:"Invalid file types",description:"Only PNG, JPG, and SVG files are allowed.",variant:"destructive"}),null;try{x(!0);const p=await Qe(b,{path:c});if(p.statusCode===200){const w=p.data,B=(w==null?void 0:w.count)??0,A=((w==null?void 0:w.assets)??[]).filter(ee=>ee.status==="error");return B===0||(w==null?void 0:w.status)==="error"?(l({title:"Upload failed",description:A.length>0?A.map(ht).join(", "):"No files could be uploaded.",variant:"destructive"}),null):(l({title:"Upload successful",description:`${B} file(s) uploaded successfully.`,variant:"success"}),A.length>0&&l({title:"Some files failed to upload",description:A.map(ht).join(", "),variant:"destructive"}),await d.invalidateQueries({queryKey:["documentAssets"]}),(w==null?void 0:w.assets)||null)}else throw new Error("Upload failed")}catch(p){return l({title:"Upload failed",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{filesCount:b.length,path:c}}}),null}finally{x(!1)}},[G,l,i,d]),_=D(async(g,c)=>{try{if(I(!0),(await zt(g)).statusCode===200)return l({title:"Image deleted",description:c?`"${c}" deleted successfully.`:"Image deleted successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),Ca(g),!0;throw new Error("Delete failed")}catch(b){return l({title:"Delete failed",description:b instanceof Error?b.message:"An unknown error occurred",variant:"destructive"}),i({error:b,contexts:{payload:{assetId:g,assetName:c}}}),!1}finally{I(!1)}},[l,i,d]),J=D(async(g,c="public/document_builder")=>{const b=`${c}/${g.trim()}`;try{const p=await Ht({path:b});if(p.statusCode===201||p.statusCode===200)return l({title:"Category created",description:`Category "${g}" created successfully.`,variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Failed to create category")}catch(p){return l({title:"Failed to create category",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{categoryName:g,categoryPath:b}}}),!1}},[l,i,d]),pe=D(async(g,c,b=!0)=>{try{const p=await Wt({path:g,recursive:b});if(p.statusCode===204||p.statusCode===200)return l({title:"Category deleted",description:c?`Category "${c}" and all its contents deleted successfully.`:"Category deleted successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Failed to delete category")}catch(p){return l({title:"Failed to delete category",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{categoryPath:g,categoryName:c}}}),!1}},[l,i,d]),de=D(async(g,c,b)=>{try{if(R(!0),(await qt({assetId:g,newFilename:c})).statusCode===200)return l({title:"Image renamed",description:b?`"${b}" renamed to "${c}" successfully.`:"Image renamed successfully.",variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),!0;throw new Error("Rename failed")}catch(p){return l({title:"Rename failed",description:p instanceof Error?p.message:"An unknown error occurred",variant:"destructive"}),i({error:p,contexts:{payload:{assetId:g,newFilename:c}}}),!1}finally{R(!1)}},[l,i,d]),Q=D(async(g,c)=>{const b=ba(g,c);try{O(!0);const p=await _t({oldPath:g,newPath:b}),w=p.data;if(p.statusCode===200&&(w==null?void 0:w.success)!==!1)return l({title:"Folder renamed",description:`Folder renamed to "${c}" successfully.`,variant:"success"}),await d.invalidateQueries({queryKey:["documentAssets"]}),{success:!0,newPath:(w==null?void 0:w.newPath)??b};const B=(w==null?void 0:w.detail)??(w==null?void 0:w.message)??"A folder with that name already exists.";return l({title:"Rename failed",description:B,variant:"destructive"}),{success:!1,error:B}}catch(p){const w=p instanceof Error?p.message:"An unknown error occurred";return l({title:"Rename failed",description:w,variant:"destructive"}),i({error:p,contexts:{payload:{oldPath:g,newPath:b}}}),{success:!1,error:w}}finally{O(!1)}},[l,i,d]),re=D(async({targetPath:g,targetName:c,assetIds:b,folderPaths:p})=>{var w;const B=b.length+p.length,A=[],ee=new Set;let S=0;try{E(!0);let K=null;for(let V=0;V<B;V+=ke){const Z=p.slice(V,V+ke),ae=Math.max(0,V-p.length),se=b.slice(ae,ae+ke-Z.length),ce=[...se,...Z];if(K===null){const Y=await Bt({targetPath:g,assetIds:se,folderPaths:Z});if(Y.statusCode===200&&Y.data){const he=Y.data;S+=((w=he.moved)==null?void 0:w.length)??0,A.push(...(he.failed??[]).map(({source:ue,message:Ce})=>({source:ue,message:Ce}))),ce.forEach(ue=>ee.add(ue));continue}K=$a(Y.data)}const xe=K;A.push(...ce.map(Y=>({source:Y,message:xe}))),ce.forEach(Y=>ee.add(Y))}if(S>0&&await d.invalidateQueries({queryKey:["documentAssets"]}),K!==null&&S===0)return l({title:"Move failed",description:K,variant:"destructive"}),{success:!1,movedCount:0,failed:A};const te=A[0];return te?(l({title:S>0?"Some items were not moved":"Move failed",description:`Moved ${S} of ${B} \u2014 ${A.length} failed: ${te.message}`,variant:"destructive"}),{success:!1,movedCount:S,failed:A}):(l({title:"Move complete",description:`Moved ${Na(S)} to ${c}`,variant:"success"}),{success:!0,movedCount:S,failed:A})}catch(K){const te=K instanceof Error?K.message:"An unknown error occurred",V=[...b,...p].filter(Z=>!ee.has(Z));return A.push(...V.map(Z=>({source:Z,message:te}))),l({title:S>0?"Some items were not moved":"Move failed",description:S>0?`Moved ${S} of ${B} \u2014 ${A.length} failed: ${te}`:te,variant:"destructive"}),i({error:K,contexts:{payload:{targetPath:g,assetIds:b,folderPaths:p}}}),await d.invalidateQueries({queryKey:["documentAssets"]}),{success:!1,movedCount:S,failed:A}}finally{E(!1)}},[l,i,d]);return{assets:H,rawAssets:z,isLoading:q,isUploading:v,isDeleting:k,isRenaming:j,isRenamingFolder:M,isMoving:P,uploadAssets:F,deleteAsset:_,renameAsset:de,renameFolder:Q,moveItems:re,createCategory:J,deleteCategory:pe,validateFiles:G,refetch:X}};function gt(){const{preferences:e}=Vt(),{user:n,isSuperAdmin:s}=Jt(),r=s||(n==null?void 0:n.role)===Ke.Admin||(n==null?void 0:n.role)===Ke.SuperAdmin,i=e==null?void 0:e[Yt.IMAGE_LIBRARY.RESTRICT_NON_ADMIN_UPDATES],l=i===!0||i==="true";return Le(()=>({canManageImageLibrary:r||!l}),[r,l])}const ve={LOGO:"public/document_builder/logo",BACKGROUND:"public/document_builder/background",PROFILES:"public/document_builder/profiles",CLIPBOARD:"public/document_builder/clipboard-uploads"};Ve.create({name:"fontFamily",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,parseHTML:e=>{var n;return((n=e.style.fontFamily)==null?void 0:n.replace(/['"]+/g,""))||null},renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]}}),Ve.create({name:"fontSize",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize||null,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]}}),Zt.create({name:"variable",group:"inline",inline:!0,atom:!0,selectable:!1,draggable:!1,addAttributes(){return{name:{default:null,parseHTML:e=>e.getAttribute("data-variable"),renderHTML:e=>e.name?{"data-variable":e.name}:{}},displayName:{default:null,parseHTML:e=>e.getAttribute("data-display-name"),renderHTML:e=>e.displayName?{"data-display-name":e.displayName}:{}},value:{default:null,parseHTML:e=>e.getAttribute("data-variable-value"),renderHTML:e=>e.value==null?{}:{"data-variable-value":e.value}},casedValue:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"span[data-variable]"}]},renderHTML({node:e,HTMLAttributes:n}){const s=e.attrs.displayName||e.attrs.name||"",r=e.attrs.value!=null&&e.attrs.value!=="";return["span",Xt(n,{class:r?"variable-highlight variable-highlight--bound":"variable-highlight"}),e.attrs.casedValue??(r?String(e.attrs.value):`[${s}]`)]},renderText({node:e}){return`{%${e.attrs.name}%}`}});const Ia={sm:"aspect-square",md:"aspect-square",lg:"aspect-square"},ft=ge(({id:e,src:n,name:s,isUploading:r=!1,isDeleting:i=!1,isRenaming:l=!1,disabled:d=!1,onClick:v,onDelete:x,onRename:k,onDragStart:I,draggable:j=!1,size:R="md",objectFit:M="contain",className:O="",showDeleteButton:P=!0,showRenameButton:E=!0})=>{const z=d||r||i||l,q=F=>{!z&&v&&v(F)},X=F=>{!r&&I&&I(F)},H=F=>{F.stopPropagation(),x&&!i&&x()},G=F=>{F.stopPropagation(),k&&!l&&k()};return N("div",{className:`${Ia[R]} rounded-lg overflow-hidden group transition-all duration-200 border border-neutral06 hover:border-primary02 hover:shadow-md relative bg-neutral07 ${r?"cursor-default":z?"cursor-not-allowed opacity-50":j?"cursor-grab active:cursor-grabbing hover:cursor-pointer":"cursor-pointer"} ${O}`,draggable:j&&!r,onDragStart:X,onClick:q,title:`${s} ${r?"(uploading...)":j?"(drag to canvas)":""}`,children:[r?N($e,{children:[a("img",{src:n,alt:s,className:"w-full h-full object-contain opacity-50",loading:"lazy"}),a("div",{className:"absolute inset-0 bg-neutral07 flex items-center justify-center z-10",children:a(Je,{size:6,className:"text-neutral03"})})]}):a(Ye,{src:n,alt:s,className:"w-full h-full transition-transform duration-200 group-hover:scale-105",objectFit:M,outerClassName:"w-full h-full",lazy:!0}),!r&&E&&k&&a("div",{className:"absolute top-1 left-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-20",children:a(Ze,{variant:"ghost",size:"sm",onClick:G,className:"!p-1 !w-6 !h-6 !min-w-0 bg-white/90 dark:bg-neutral-900/90 !rounded-full shadow-sm",title:"Rename image",disabled:l,icon:a(ea,{className:"h-3 w-3 text-neutral02"}),tooltip:"Rename image"})}),!r&&P&&x&&a("div",{className:"absolute top-1 right-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-20",children:a(Ze,{variant:"ghost",size:"sm",onClick:H,className:"!p-1 !w-6 !h-6 !min-w-0 bg-white/90 dark:bg-neutral-900/90 !rounded-full shadow-sm",title:"Delete image",disabled:i,icon:a(De,{className:"h-3 w-3 text-error"}),tooltip:"Delete image"})})]})},(e,n)=>e.id===n.id&&e.src===n.src&&e.isUploading===n.isUploading&&e.isDeleting===n.isDeleting&&e.isRenaming===n.isRenaming&&e.disabled===n.disabled);ft.displayName="AssetThumbnail";const Aa={sm:"aspect-square",md:"aspect-square",lg:"aspect-square"},Da={sm:"h-4 w-4",md:"h-6 w-6",lg:"h-8 w-8"},yt=ge(({onClick:e,size:n="md",disabled:s=!1,title:r="Upload new image",className:i=""})=>a("div",{onClick:s?void 0:e,className:`${Aa[n]} border-2 border-dashed border-neutral04 rounded-lg flex items-center justify-center transition-colors group ${s?"cursor-not-allowed opacity-50":"cursor-pointer hover:border-primary02 hover:bg-primary05"} ${i}`,title:r,children:a(Xe,{className:`${Da[n]} text-neutral03 ${!s&&"group-hover:text-primary02"} transition-colors`})}));yt.displayName="AddAssetButton";const Oa="image/png,image/jpeg,image/jpg,image/svg+xml",vt=Be(({onFileSelect:e,accept:n=Oa,multiple:s=!0,disabled:r=!1,id:i},l)=>{const d=D(v=>{e(v.target.files),v.target.value=""},[e]);return a("input",{ref:l,id:i,type:"file",multiple:s,accept:n,onChange:d,disabled:r,className:"hidden"})});vt.displayName="AssetUploadInput";const bt=ge(({isOpen:e,onClose:n,onConfirm:s,assetName:r,assetType:i="image",imageCount:l=0,title:d,description:v})=>a(ta,{isOpen:e,onClose:n,onConfirm:s,title:d||(i==="category"?"Delete Category":"Delete Image"),description:v||(i==="category"?l>0?`Are you sure you want to delete the "${r}" category? This will permanently delete all ${l} image${l!==1?"s":""} in this category. This action cannot be undone.`:`Are you sure you want to delete the "${r}" category? This action cannot be undone.`:`Are you sure you want to delete "${r}"? This action cannot be undone.`),confirmText:"Delete",cancelText:"Cancel",modal:!0,closeOnOutsideClick:!1}));bt.displayName="DeleteAssetDialog";const Ta=Object.freeze(Object.defineProperty({__proto__:null,DeleteAssetDialog:bt},Symbol.toStringTag,{value:"Module"})),wt=Oe(()=>import("./runtime-BifHPIs0.js").then(e=>e.oS).then(e=>e.FolderNameDialog),{}),xt=Oe(()=>Promise.resolve().then(()=>Ta).then(e=>e.DeleteAssetDialog),{}),ka=Oe(()=>import("./RenameAssetDialog-DyTr1q9l.js").then(e=>e.RenameAssetDialog),{});function Fa(e,n){const s=`${n}/`,r=[],i=[],l=new Map;for(const d of e){if(d.type!==ne.FILE||!d.path.startsWith(s))continue;const v=d.path.slice(s.length),x=v.indexOf("/");if(x<=0)continue;const k=`${n}/${v.slice(0,x)}`;l.set(k,(l.get(k)??0)+1)}for(const d of e){if(!d.path.startsWith(s))continue;const v=d.path.slice(s.length);v.length===0||v.includes("/")||(d.type===ne.FOLDER?r.push({name:d.name,path:d.path,imageCount:l.get(d.path)??0}):d.type===ne.FILE&&i.push(d))}return r.sort((d,v)=>d.name.localeCompare(v.name)),{folders:r,fileAssets:i}}function Fe(e){const n=e.lastIndexOf("/");return n>=0?e.slice(0,n):""}const ja="Untitled";function je(e){var n,s;return((s=(n=e.assetMetadata)==null?void 0:n.originalFilename)==null?void 0:s.trim())||ja}const be=[{name:"Logo",path:ve.LOGO},{name:"Background",path:ve.BACKGROUND},{name:"Profiles",path:ve.PROFILES},{name:"Clipboard Uploads",path:ve.CLIPBOARD}],Re=Be(({onImageSelect:e,gridColumns:n=3,hideDeleteButton:s,hideHeader:r,pickerMode:i=!1},l)=>{const[d,v]=U("logo"),[x,k]=U(""),{assets:I,isLoading:j}=pt({}),{toast:R}=Ie(),{canManageImageLibrary:M}=gt(),O=!M,{uploadAssets:P,deleteAsset:E,renameAsset:z,createCategory:q,deleteCategory:X,isDeleting:H,isRenaming:G,validateFiles:F}=La(),[_,J]=U(()=>be.map(t=>({id:t.name.toLowerCase(),name:t.name,images:[],isDefault:!0,path:t.path,isFetched:!1,fileCount:0,isCountFetched:!1})));Pt(()=>{if(I.length===0)return;const t="public/document_builder/",u=I.filter(f=>{if(f.type!==ne.FOLDER||!f.path.startsWith(t))return!1;const y=f.path.slice(t.length);return y.length>0&&!y.includes("/")}).map(f=>{const y=I.filter(C=>C.path.startsWith(f.path)&&C.type===ne.FILE),$=be.find(C=>C.path===f.path||C.name.toLowerCase()===f.name.toLowerCase()),L=!!$,ie=L?$.name.toLowerCase():f.id||`${f.name}-${f.path}`;return{id:ie,name:f.name,images:y.map(C=>({id:C.id||`${C.name}-${C.path}`,src:C.id?ye(C.id):C.path,thumbnailSrc:C.id?et(C.id):C.path,name:je(C),category:ie,path:C.path,isLoaded:!1,createdAt:C.createdAt})).sort((C,le)=>!C.createdAt||!le.createdAt?0:new Date(C.createdAt).getTime()-new Date(le.createdAt).getTime()),isDefault:L,path:f.path,isFetched:!0,fileCount:y.length,isCountFetched:!0}}),m=be.map(f=>u.find($=>$.path===f.path||$.name.toLowerCase()===f.name.toLowerCase())||{id:f.name.toLowerCase(),name:f.name,images:[],isDefault:!0,path:f.path,isFetched:!0,fileCount:0,isCountFetched:!0}),h=u.filter(f=>!be.some(y=>f.path===y.path||f.name.toLowerCase()===y.name.toLowerCase())),T=[...m,...h];J(f=>T.map(y=>{const $=f.find(L=>L.id===y.id);return $&&$.images.filter(L=>L.isUploading).forEach(L=>{L.src.startsWith("blob:")&&URL.revokeObjectURL(L.src)}),y}))},[I]);const[pe,de]=U(null),[Q,re]=U(null),[g,c]=U(null),[b,p]=U(null),[w,B]=U({}),[A,ee]=U(null),[S,K]=U(null),te=fe({}),V=fe(_);V.current=_;const Z=D(t=>w[t.id]??t.path??"",[w]);St(l,()=>({createCategory:async t=>{await q(t)},getActiveCategoryPath:()=>{if(!d)return null;const t=V.current.find(u=>u.id===d);return t?w[t.id]??t.path??null:null}}),[q,d,w]);const ae=D(async(t,u)=>{if(!u)return;const m=F(u);if(m.length===0)return;if(O){R({title:"Image library is admin-managed",description:"Only admins can add images to the shared library.",variant:"destructive"});return}const h=V.current.find($=>$.id===t);if(!(h!=null&&h.path))return;const T=w[t]??h.path,f=Date.now(),y=m.map($=>{const L=URL.createObjectURL($);return{id:`temp_${t}_${f}_${Math.random()}`,src:L,thumbnailSrc:L,name:$.name,category:t,path:`${T}/${$.name}`,isUploading:!0,isLoaded:!0,uploadTimestamp:f}});J($=>$.map(L=>L.id===t?{...L,images:[...L.images,...y]}:L)),await P(m,T)||(J($=>$.map(L=>L.id===t?{...L,images:L.images.filter(ie=>!ie.isUploading)}:L)),y.forEach($=>URL.revokeObjectURL($.src)))},[F,P,w,O,R]),se=D(t=>{var u;(u=te.current[t])==null||u.click()},[]),ce=(t,u)=>{t.preventDefault(),t.stopPropagation(),de(u)},xe=t=>{t.preventDefault(),t.stopPropagation(),de(null)},Y=D((t,u)=>{t.preventDefault(),t.stopPropagation(),de(null);const m=t.dataTransfer.files;ae(u,m)},[ae]),he=D(async t=>{if(t.isUploading){J(u=>u.map(m=>m.id===t.category?{...m,images:m.images.filter(h=>h.id!==t.id)}:m)),URL.revokeObjectURL(t.src),c(null),re(null);return}await E(t.id,t.name)&&J(u=>u.map(m=>m.id===t.category?{...m,images:m.images.filter(h=>h.id!==t.id)}:m)),c(null),re(null)},[E]),ue=D(async(t,u)=>{if(!t.id){p(null);return}await z(t.id,u,t.name)&&J(m=>m.map(h=>h.id===t.category?{...h,images:h.images.map(T=>T.id===t.id?{...T,name:u}:T)}:h)),p(null)},[z]),Ce=D(async(t,u)=>{await X(u.path,u.name,!0)&&B(m=>{const h=m[t];if(!h||h!==u.path&&!h.startsWith(`${u.path}/`))return m;const T={...m},f=Fe(u.path),y=V.current.find($=>$.id===t);return!f||y!=null&&y.path&&f===y.path?delete T[t]:T[t]=f,T}),ee(null)},[X]),At=D(async t=>S?await q(t,S.parentPath):!1,[q,S]),Se=D((t,u)=>{const m=t.currentTarget.querySelector("img");let h=u.width,T=u.height;m&&(!h||!T)&&(h=m.naturalWidth,T=m.naturalHeight);const f={type:"image",src:u.src,name:u.name,category:u.category,path:u.path,width:h,height:T};if(t.dataTransfer.setData("application/json",JSON.stringify(f)),t.dataTransfer.effectAllowed="copy",m&&m.src&&!m.src.startsWith(tt)){const y=document.createElement("img");y.src=m.src,y.style.position="absolute",y.style.top="-1000px",y.style.width="80px",y.style.height="80px",y.style.objectFit="contain",y.style.pointerEvents="none",y.style.border="2px solid #000",y.style.borderRadius="4px",y.style.backgroundColor="white",document.body.appendChild(y),t.dataTransfer.setDragImage(y,40,40),setTimeout(()=>{document.body.contains(y)&&document.body.removeChild(y)},0)}},[]),Ue=D((t,u)=>{if(t.isUploading)return;let m=t;if(u){const h=u.currentTarget.querySelector("img");h&&h.naturalWidth&&h.naturalHeight&&(m={...t,width:h.naturalWidth,height:h.naturalHeight})}e?e(m):re(m)},[e]),Dt=D(t=>{const u=j||!t.isFetched,m=Z(t),h=!!t.path&&m!==t.path,T=s||O,{folders:f,fileAssets:y}=m?Fa(I,m):{folders:[],fileAssets:[]},$=y.map(o=>({id:o.id||`${o.name}-${o.path}`,src:o.id?ye(o.id):o.path,thumbnailSrc:o.id?et(o.id):o.path,name:je(o),category:t.id,path:o.path,isLoaded:!1,createdAt:o.createdAt})).sort((o,W)=>!o.createdAt||!W.createdAt?0:new Date(o.createdAt).getTime()-new Date(W.createdAt).getTime()),L=t.images.filter(o=>o.isUploading&&o.path&&Fe(o.path)===m),ie=f.length===0&&$.length===0&&L.length===0,C=x.trim().toLowerCase(),le=o=>o.toLowerCase().includes(C),He=C?f.filter(o=>le(o.name)):f,We=C?$.filter(o=>le(o.name)):$,qe=C?L.filter(o=>le(o.name)):L,kt=!!C&&He.length===0&&We.length===0&&qe.length===0,Ft=()=>{if(!h||!t.path)return;const o=Fe(m);B(W=>{const Ne={...W};return!o||o===t.path?delete Ne[t.id]:Ne[t.id]=o,Ne})},jt=o=>{B(W=>({...W,[t.id]:o}))},Rt=()=>u?a("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:[...Array(n*2)].map((o,W)=>a(la,{className:"aspect-square rounded-lg"},W))}):t.isLoading?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(Je,{size:6,className:"text-neutral03 mb-2"}),a("p",{className:"text-xs text-neutral03",children:"Loading images..."})]}):ie?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(oa,{className:"h-6 w-6 text-neutral03 mb-2"}),a("p",{className:"text-xs text-neutral03 mb-3",children:O?"No images in this folder.":"No images in this folder. Upload or drop images here."}),!O&&a(oe,{variant:"outline",size:"sm",onClick:()=>se(t.id),className:"flex items-center gap-2",leftIcon:a(it,{className:"h-4 w-4"}),children:"Upload Images"})]}):kt?N("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[a(at,{className:"h-6 w-6 text-neutral03 mb-2"}),N("p",{className:"text-xs text-neutral03",children:['No images match "',x,'".']})]}):N("div",{className:"grid gap-3 items-start",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:[!C&&!O&&a(yt,{onClick:()=>se(t.id)}),He.map(o=>{const W=o.name.toLowerCase().replace(/\s+/g,"-");return a(Ct,{folder:o,testId:`image-options-folder-${t.id}-${W}`,onOpen:()=>jt(o.path),onDelete:T?void 0:()=>ee({categoryId:t.id,folder:o})},o.path)}),[...We,...qe].map(o=>N("div",{className:"flex flex-col gap-1 min-w-0",children:[a(ft,{id:o.id,src:o.thumbnailSrc,name:o.name,isUploading:o.isUploading,isDeleting:H,isRenaming:G,draggable:!o.isUploading&&!i,onDragStart:i?void 0:W=>Se(W,o),onClick:W=>Ue(o,W),onDelete:T?void 0:()=>c(o),showDeleteButton:!T}),a("p",{title:o.name,className:"text-xs text-neutral01 truncate",children:o.name})]},o.id))]});return N("div",{className:`flex-1 min-h-0 flex flex-col transition-colors duration-200 ${pe===t.id?"bg-primary05/40":""}`,onDragOver:o=>ce(o,t.id),onDragLeave:xe,onDrop:o=>Y(o,t.id),children:[N("div",{className:`flex items-center gap-2 px-4 ${r?"pt-1":"pt-3"} pb-4 shrink-0`,children:[h?N("button",{type:"button","data-testid":`image-options-back-${t.id}`,onClick:Ft,className:"inline-flex items-center gap-1 text-xs text-primary01 hover:underline shrink-0",children:[a(aa,{className:"h-3.5 w-3.5"}),"Back"]}):null,h&&a("span",{"data-testid":`image-options-current-folder-${t.id}`,title:m,className:"text-xs font-medium text-neutral01 capitalize truncate shrink-0",children:m.split("/").pop()}),N("div",{className:"relative flex-1 min-w-0",children:[a(at,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-neutral03"}),a(na,{type:"search",value:x,onChange:o=>k(o.target.value),placeholder:"Search images","data-testid":`image-options-search-${t.id}`,className:"h-8 w-full pl-7 text-xs"})]}),!i&&!O&&a(oe,{size:"sm",variant:"outline","data-testid":`image-options-new-folder-${t.id}`,onClick:()=>K({categoryId:t.id,parentPath:m}),className:"shrink-0 h-8 px-3 text-xs",leftIcon:a(ra,{className:"h-3.5 w-3.5"}),children:"New Folder"})]}),a("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:Rt()}),a(vt,{ref:o=>{o&&(te.current[t.id]=o)},id:`asset-upload-${t.id}`,onFileSelect:o=>ae(t.id,o)})]})},[I,Z,se,Se,Ue,ae,Y,H,G,j,pe,n,s,r,i,x,O]),[Ot,Me]=U(!1),Tt=D(async t=>await q(t),[q]),Ee=_.find(t=>t.id===d)??null,me=x.trim().toLowerCase(),ze=Le(()=>{if(!me)return null;const t=new Map;for(const u of _){if(!u.path)continue;const m=I.filter(h=>h.type===ne.FILE&&h.path.startsWith(`${u.path}/`)&&je(h).toLowerCase().includes(me)).length;t.set(u.id,m)}return t},[me,_,I]);return N($e,{children:[N("div",{"data-testid":"image-options",className:"flex flex-col h-[640px] max-h-[70vh] bg-white overflow-hidden dark:bg-neutral-900",children:[!r&&a("div",{"data-testid":"image-options-header",className:"flex items-center justify-between px-4 py-3 border-b border-neutral06 shrink-0",children:a("span",{className:"text-sm font-semibold text-neutral01",children:"Image Library"})}),N("div",{className:"flex flex-1 min-h-0",children:[N("div",{"data-testid":"image-options-categories",className:`w-[170px] shrink-0 border-r border-neutral06 overflow-y-auto px-2 pb-2 ${r?"pt-1":"pt-2"}`,children:[!i&&!O&&a(oe,{size:"sm",variant:"outline","data-testid":"image-options-new-category",onClick:()=>Me(!0),className:"w-full justify-center mb-3",leftIcon:a(Xe,{className:"h-3.5 w-3.5"}),children:"Add category"}),j&&_.every(t=>!t.isFetched)?a("ul",{className:"flex flex-col gap-1",children:Array.from({length:4}).map((t,u)=>a("li",{className:"h-9 rounded-md bg-neutral07 animate-pulse"},u))}):_.length===0?a("p",{className:"text-[11px] text-neutral03 px-2 py-2",children:"No categories yet."}):a("ul",{className:"flex flex-col gap-0.5",children:_.map(t=>{const u=d===t.id,m=t.name.toLowerCase().replace(/\s+/g,"-"),h=me?(ze==null?void 0:ze.get(t.id))??0:t.fileCount??0,T=me?!0:h>0;return a("li",{children:N("button",{type:"button","data-testid":`image-options-category-${m}`,"aria-current":u?"true":void 0,onClick:()=>v(t.id),className:`w-full flex items-center justify-between gap-2 h-9 px-3 rounded-md text-xs font-medium capitalize transition-colors ${u?"bg-primary05 text-primary01":"text-neutral02 hover:bg-neutral07"}`,children:[a("span",{className:"truncate",children:t.name}),T&&a("span",{className:`shrink-0 text-[11px] font-normal normal-case ${u?"text-primary01":"text-neutral03"}`,children:h})]})},t.id)})})]}),a("div",{"data-testid":"image-options-pane",className:"flex-1 min-w-0 min-h-0 flex flex-col",children:Ee?Dt(Ee):a("div",{className:"h-full flex items-center justify-center text-xs text-neutral03 px-4 text-center",children:"Select or create a category to get started."})})]})]}),Q&&a(nt,{open:!!Q,onOpenChange:()=>re(null),children:N(rt,{className:"w-full max-w-2xl",children:[a(st,{className:"flex flex-row items-center gap-1.5 text-center sm:text-left",children:a("span",{className:"text-lg font-semibold leading-none tracking-tight",children:Q.name})}),a("div",{className:"flex justify-center p-4",children:a("div",{className:"relative w-full",style:{maxHeight:"384px",aspectRatio:Q.width&&Q.height?`${Q.width} / ${Q.height}`:"auto"},children:a(Ye,{src:Q.src,alt:Q.name,className:"w-full h-full object-contain rounded-lg",objectFit:"contain",outerClassName:"w-full h-full"})})}),N(sa,{children:[!O&&a(oe,{variant:"destructive",onClick:()=>c(Q),leftIcon:a(De,{className:"h-4 w-4"}),disabled:H,isLoading:H,children:"Delete"}),a(ia,{asChild:!0,children:a(oe,{variant:"outline",disabled:H,children:"Close"})})]})]})}),a(xt,{isOpen:!!g,onClose:()=>c(null),onConfirm:async()=>{g&&await he(g)},assetName:g==null?void 0:g.name,assetType:"image"}),a(ka,{isOpen:!!b,onClose:()=>p(null),onConfirm:async t=>{b&&await ue(b,t)},currentName:b==null?void 0:b.name,isRenaming:G}),a(wt,{isOpen:Ot,onClose:()=>Me(!1),onSubmit:Tt,title:"Create New Category",inputLabel:"Category Name",placeholder:"Enter category name"}),a(wt,{isOpen:!!S,onClose:()=>K(null),onSubmit:At,title:"Create New Folder"}),a(xt,{isOpen:!!A,onClose:()=>ee(null),onConfirm:async()=>{A&&await Ce(A.categoryId,A.folder)},assetName:A==null?void 0:A.folder.name,assetType:"category",imageCount:A==null?void 0:A.folder.imageCount})]})});Re.displayName="ImageOptions";const Ct=ge(({folder:e,testId:n,onOpen:s,onDelete:r})=>N("div",{className:"relative group",children:[N("button",{type:"button","data-testid":n,onClick:s,title:e.name,className:"aspect-square w-full rounded-lg border border-neutral06 bg-neutral08 hover:border-primary02 hover:bg-primary05/30 focus:outline-none focus:ring-2 focus:ring-primary02 flex flex-col items-center justify-center gap-1 transition-colors p-2",children:[a(da,{className:"h-6 w-6 text-neutral03",strokeWidth:1.5}),a("span",{className:"text-[11px] font-medium text-neutral02 capitalize truncate max-w-full",children:e.name}),N("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-neutral03",children:[e.imageCount,a(ca,{className:"h-3 w-3"})]})]}),r&&a("button",{type:"button","data-testid":`${n}-delete`,"aria-label":`Delete folder ${e.name}`,title:`Delete folder ${e.name}`,onClick:i=>{i.stopPropagation(),r()},className:"absolute top-1.5 right-1.5 w-6 h-6 inline-flex items-center justify-center rounded-md bg-white/90 dark:bg-neutral-900/90 text-neutral02 shadow-sm border border-neutral06 opacity-0 group-hover:opacity-100 hover:text-red-600 focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-primary02 transition-opacity",children:a(De,{className:"h-3.5 w-3.5"})})]}));Ct.displayName="FolderTile";const Nt="Image library is admin-managed",$t="Only admins can upload new images. Ask your admin for access, or pick an existing image from the library.",Ra=`${Nt}. ${$t}`;function Pa(e){return!Number.isFinite(e)||e<1?1:Math.floor(e)}function Sa(e){const n=Pa(e),s=[];let r=0;const i=()=>{for(;r<n&&s.length>0;)s.shift().execute()};return{run:l=>new Promise((d,v)=>{const x=()=>{r+=1,Promise.resolve().then(l).then(d,v).finally(()=>{r-=1,i()})};s.push({execute:x}),i()}),get activeCount(){return r},get pendingCount(){return s.length}}}const Ua=e=>`${e.userId}/document_builder/document_images/${e.documentScope}`,Ma=e=>new Promise(n=>{const s=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(s),n({width:r.naturalWidth||void 0,height:r.naturalHeight||void 0})},r.onerror=()=>{URL.revokeObjectURL(s),n({})},r.src=s}),Ea=3,za=async(e,n)=>{const s=e.filter(lt),r=async l=>{var d,v,x;const[k,I]=await Promise.all([Ma(l),Qe([l],{path:Ua(n),compress:!0})]),j=ua(I);if(!j){const R=(x=(v=(d=I.data)==null?void 0:d.assets)==null?void 0:v[0])==null?void 0:x.message;throw new Error(R||`Inline image upload failed (${I.statusCode})`)}return{assetId:j.assetId,src:`${tt}${j.assetId}`,...k}},i=Sa(Ea);return Promise.all(s.map(l=>i.run(()=>r(l))))},Pe="Image upload failed \u2014 nothing was inserted.",Ha=`Unsupported image type \u2014 choose a ${ct.map(e=>e.replace("image/","").toUpperCase()).join(", ")} file.`,Wa=ct.join(","),Lt=e=>({assetId:e.id,src:fa(e.src)==="asset-ref"?e.src:ye(e.id),width:e.width,height:e.height});function qa({sessionRef:e,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,gridColumns:l}){const[d,v]=U(!1),{canManageImageLibrary:x}=gt(),k=!x,I=fe(null),j=D(async M=>{const O=Array.from(M.target.files??[]);if(M.target.value="",O.length===0)return;if(k){i==null||i(Ra);return}if(!s){i==null||i(Pe);return}if(!O.some(lt)){i==null||i(Ha);return}const P=e.current.id,E=()=>e.current.open&&e.current.id===P;v(!0);try{const z=await za(O,s);if(!E())return;if(z.length===0){i==null||i(Pe);return}r(z),n(!1)}catch{if(!E())return;i==null||i(Pe)}finally{v(!1)}},[s,k,i,r,n,e]),R=D(M=>{d||(r([Lt(M)]),n(!1))},[d,r,n]);return N($e,{children:[N(pa,{defaultValue:k?"library":"upload",className:"px-6 pb-6",children:[N(ha,{children:[a(ot,{value:"upload","data-testid":"insert-image-tab-upload",children:"Upload"}),a(ot,{value:"library","data-testid":"insert-image-tab-library",children:"Image Library"})]}),a(dt,{value:"upload",children:k?N("div",{className:"flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border py-10 text-center","data-testid":"inline-image-upload-restricted",children:[a(ga,{className:"h-8 w-8 text-muted-foreground"}),a("p",{className:"text-sm font-medium text-foreground",children:Nt}),a("p",{className:"max-w-[380px] text-xs text-muted-foreground",children:$t})]}):N("div",{className:"flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border-primary py-10 text-center",children:[a(ya,{className:"h-8 w-8 text-neutral03"}),a("p",{className:"text-sm text-neutral02",children:"PNG, JPG or WEBP. Images are stored securely with your document."}),a(oe,{variant:"primary",size:"sm",leftIcon:a(it,{className:"h-4 w-4"}),disabled:!s||d,isLoading:d,onClick:()=>{var M;return(M=I.current)==null?void 0:M.click()},"data-testid":"inline-image-upload-trigger",children:d?"Uploading\u2026":"Choose images"}),!s&&a("p",{className:"text-xs text-neutral03",children:"Uploads are unavailable until the document finishes loading."})]})}),a(dt,{value:"library",children:a("div",{className:"max-h-[70vh]",children:a(Re,{pickerMode:!0,hideHeader:!0,hideDeleteButton:!0,gridColumns:l,onImageSelect:R})})})]}),a("input",{ref:I,type:"file",accept:Wa,multiple:!0,className:"hidden","data-testid":"inline-image-file-input",onChange:j})]})}function _a({onOpenChange:e,onInsert:n,gridColumns:s}){const r=D(i=>{n([Lt(i)]),e(!1)},[n,e]);return a("div",{className:"px-6 pb-6",children:a("div",{className:"max-h-[70vh]",children:a(Re,{pickerMode:!0,hideHeader:!0,hideDeleteButton:!0,gridColumns:s,onImageSelect:r})})})}function Ba({open:e,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,title:l="Insert Image",gridColumns:d}){const v=s===void 0,x=fe({open:e,id:0});return x.current.open!==e&&(x.current={open:e,id:x.current.id+1}),a(nt,{open:e,onOpenChange:n,children:N(rt,{className:"w-full sm:max-w-[720px] p-0 overflow-hidden",closeOnOutsideClick:v,children:[a(st,{className:"px-6 pt-6",children:a(ma,{children:l})}),v?a(_a,{onOpenChange:n,onInsert:r,gridColumns:d}):a(qa,{sessionRef:x,onOpenChange:n,uploadCtx:s,onInsert:r,onError:i,gridColumns:d})]})})}const we="/images/image-placeholder.svg";function It(e){return e?/^(https?:|data:|blob:|\/)/.test(e):!0}function Ga({src:e,className:n,companyLogo:s}){const[r,i]=_e.useState(()=>It(e)?e:"");return _e.useEffect(()=>{if(It(e)){i(e);return}let l=!1;return ut(e,we,void 0,void 0,{companyLogo:s}).then(d=>{l||i(d)}).catch(()=>{l||i(we)}),()=>{l=!0}},[e,s]),r?a("img",{src:r,alt:"Logo",className:n}):null}function Qa({isOpen:e,onClose:n,onSelect:s}){return a(Ba,{open:e,onOpenChange:r=>{r||n()},title:"Select image",onInsert:r=>{const i=r[0];i&&s(ye(i.assetId))}})}async function Ka(e){try{const n=await ut(e,we);return!n||n===we?null:await new Promise(s=>{const r=new Image;r.onload=()=>{if(!r.naturalWidth||!r.naturalHeight){s(null);return}s({naturalWidth:r.naturalWidth,naturalHeight:r.naturalHeight})},r.onerror=()=>s(null),r.src=n})}catch{return null}}export{Qa as LogoLibraryDialog,Ga as ResolvedLogoImg,Ka as captureImageNaturalSize};
@@ -1,4 +1,4 @@
1
- import{jsx as l,jsxs as C}from"react/jsx-runtime";import{useMemo as W,useState as u,useEffect as F,useCallback as d}from"react";import{bA as se,bz as Ve,dd as ce,dB as Ze,e1 as de,e2 as ue,bR as qe,cf as Je,by as Qe,cK as en,e3 as nn,e4 as on,e5 as tn,d3 as ln,e6 as X,d2 as me,e7 as an,cY as pe,c_ as rn,c1 as sn,c2 as cn,c8 as dn,c3 as un,e8 as mn,e9 as pn,ea as fn,aC as xn,ca as hn,bD as gn,bC as yn,cZ as vn}from"./runtime-DTft3h2S.js";const wn=({className:o})=>{const{preferences:t}=se(),{isAdmin:a}=Ve();return t!=null&&t[ce.GLOBAL.COMPANY_LOGO]?null:l(Ze,{variant:"warning",icon:l(qe,{size:18}),message:a?C("p",{className:"text-sm",children:["We noticed that your company logo and theme have not been configured. For most effective use of templates, please configure them in"," ",l(de,{href:ue.company,className:"inline-flex items-center font-medium hover:opacity-70 underline underline-offset-2",children:"Company Settings \u2192"})]}):C("p",{className:"text-sm",children:["We noticed that your company logo and theme have not been configured. For most effective use of templates, please request your admin to configure them in"," ",l(de,{href:ue.company,className:"inline-flex items-center font-medium hover:opacity-70 underline underline-offset-2",children:"Company Settings \u2192"})]}),className:o})};function bn(o){const t=[];return(o.includes("pdf")||o.includes("word"))&&t.push("document"),o.includes("excel_single")&&t.push("excel_single"),o.includes("excel_multiple")&&t.push("excel_multiple"),t}function fe(o){return o==="document"?"pdf":"excel"}function Cn(o){return o==="excel_multiple"?"separate":"single"}function On(o){const t=o.includes("pdf"),a=o.includes("word");return t&&a?"PDF & Word":a?"Word":"PDF"}function En(o){return o.includes("pdf")?l(pe,{size:16}):l(vn,{size:16})}const Sn=({isOpen:o,onClose:t,markdownContent:a,tiptapContent:xe,tiptapContents:he,title:ge="Download Preview",exportButtonText:ye="Download as PDF",documentName:O,pageBreakBetweenItems:ve=!1,exportFormat:P="pdf",excelMode:_="single",excelExportSettings:y,onBlobGenerated:c,onDocxBlobGenerated:G,showDocumentTitleControls:we=!1,seedDocumentTitleFromContent:be=!1,hideDocumentTitle:Ce=!1,emailFormats:i,onAllBlobsGenerated:N,enablePageStyle:Oe=!0,enableOrientationControl:Ee=!1,initialOrientationMode:k,onOrientationModeChange:M})=>{const{captureException:E}=Je(),{toast:v}=Qe(),{isExportBlocked:Se,refuseExport:De}=en(),S=W(()=>i?bn(i):[],[i]),Fe=S.length>1,m=!!i&&i.length>0,[s,z]=u(null);F(()=>{S.length>0?z(S[0]):z(null)},[S]);const L=m&&s?fe(s):P,Ne=m&&s?Cn(s):_,[T,Y]=u(null),[f,K]=u(null),[A,V]=u(null),[p,Z]=u(null),[w,$]=u(!1),[R,q]=u(y);F(()=>{o||(q(y),ne(null))},[o,y]);const[J,ke]=u(!0),[x,Q]=u(O||"");F(()=>{O&&Q(O)},[O]);const Te=d(e=>{Q(e)},[]),[Ae,ee]=u(k??"auto");F(()=>{k!==void 0&&ee(k)},[k]);const $e=d(e=>{ee(e),M==null||M(e)},[M]),[b,ne]=u(null),Be=d(e=>{e.isExcel&&e.logoEnabled!==void 0&&ne({logo:e.sessionLogo,enabled:e.logoEnabled,firstSheetOnly:e.logoOnFirstSheetOnly,switchesTouched:e.logoSwitchesTouched}),q(n=>({componentColors:e.componentColors,documentFont:e.documentFont,logoDataUrl:e.isExcel?e.logoDataUrl:n==null?void 0:n.logoDataUrl,logoOnFirstSheetOnly:e.isExcel?e.logoOnFirstSheetOnly:n==null?void 0:n.logoOnFirstSheetOnly}))},[]),Pe=d(e=>{ke(e)},[]),_e=d(e=>{Y(()=>e)},[]),Ge=d(e=>{K(()=>e)},[]),Me=d(e=>{V(()=>e)},[]),ze=d(e=>{Z(()=>e)},[]),h=L==="excel",g=L==="docx",oe=h?"Excel":g?"DOCX":"PDF",U=h?".xlsx":g?".docx":".pdf";F(()=>{Y(null),K(null),V(null),Z(null)},[s]);const B=W(()=>typeof a=="string"?a:Array.isArray(a)?a.join(`
1
+ import{jsx as l,jsxs as C}from"react/jsx-runtime";import{useMemo as W,useState as u,useEffect as F,useCallback as d}from"react";import{bA as se,bz as Ve,dd as ce,dB as Ze,e1 as de,e2 as ue,bR as qe,cf as Je,by as Qe,cK as en,e3 as nn,e4 as on,e5 as tn,d3 as ln,e6 as X,d2 as me,e7 as an,cY as pe,c_ as rn,c1 as sn,c2 as cn,c8 as dn,c3 as un,e8 as mn,e9 as pn,ea as fn,aC as xn,ca as hn,bD as gn,bC as yn,cZ as vn}from"./runtime-BifHPIs0.js";const wn=({className:o})=>{const{preferences:t}=se(),{isAdmin:a}=Ve();return t!=null&&t[ce.GLOBAL.COMPANY_LOGO]?null:l(Ze,{variant:"warning",icon:l(qe,{size:18}),message:a?C("p",{className:"text-sm",children:["We noticed that your company logo and theme have not been configured. For most effective use of templates, please configure them in"," ",l(de,{href:ue.company,className:"inline-flex items-center font-medium hover:opacity-70 underline underline-offset-2",children:"Company Settings \u2192"})]}):C("p",{className:"text-sm",children:["We noticed that your company logo and theme have not been configured. For most effective use of templates, please request your admin to configure them in"," ",l(de,{href:ue.company,className:"inline-flex items-center font-medium hover:opacity-70 underline underline-offset-2",children:"Company Settings \u2192"})]}),className:o})};function bn(o){const t=[];return(o.includes("pdf")||o.includes("word"))&&t.push("document"),o.includes("excel_single")&&t.push("excel_single"),o.includes("excel_multiple")&&t.push("excel_multiple"),t}function fe(o){return o==="document"?"pdf":"excel"}function Cn(o){return o==="excel_multiple"?"separate":"single"}function On(o){const t=o.includes("pdf"),a=o.includes("word");return t&&a?"PDF & Word":a?"Word":"PDF"}function En(o){return o.includes("pdf")?l(pe,{size:16}):l(vn,{size:16})}const Sn=({isOpen:o,onClose:t,markdownContent:a,tiptapContent:xe,tiptapContents:he,title:ge="Download Preview",exportButtonText:ye="Download as PDF",documentName:O,pageBreakBetweenItems:ve=!1,exportFormat:P="pdf",excelMode:_="single",excelExportSettings:y,onBlobGenerated:c,onDocxBlobGenerated:G,showDocumentTitleControls:we=!1,seedDocumentTitleFromContent:be=!1,hideDocumentTitle:Ce=!1,emailFormats:i,onAllBlobsGenerated:N,enablePageStyle:Oe=!0,enableOrientationControl:Ee=!1,initialOrientationMode:k,onOrientationModeChange:M})=>{const{captureException:E}=Je(),{toast:v}=Qe(),{isExportBlocked:Se,refuseExport:De}=en(),S=W(()=>i?bn(i):[],[i]),Fe=S.length>1,m=!!i&&i.length>0,[s,z]=u(null);F(()=>{S.length>0?z(S[0]):z(null)},[S]);const L=m&&s?fe(s):P,Ne=m&&s?Cn(s):_,[T,Y]=u(null),[f,K]=u(null),[A,V]=u(null),[p,Z]=u(null),[w,$]=u(!1),[R,q]=u(y);F(()=>{o||(q(y),ne(null))},[o,y]);const[J,ke]=u(!0),[x,Q]=u(O||"");F(()=>{O&&Q(O)},[O]);const Te=d(e=>{Q(e)},[]),[Ae,ee]=u(k??"auto");F(()=>{k!==void 0&&ee(k)},[k]);const $e=d(e=>{ee(e),M==null||M(e)},[M]),[b,ne]=u(null),Be=d(e=>{e.isExcel&&e.logoEnabled!==void 0&&ne({logo:e.sessionLogo,enabled:e.logoEnabled,firstSheetOnly:e.logoOnFirstSheetOnly,switchesTouched:e.logoSwitchesTouched}),q(n=>({componentColors:e.componentColors,documentFont:e.documentFont,logoDataUrl:e.isExcel?e.logoDataUrl:n==null?void 0:n.logoDataUrl,logoOnFirstSheetOnly:e.isExcel?e.logoOnFirstSheetOnly:n==null?void 0:n.logoOnFirstSheetOnly}))},[]),Pe=d(e=>{ke(e)},[]),_e=d(e=>{Y(()=>e)},[]),Ge=d(e=>{K(()=>e)},[]),Me=d(e=>{V(()=>e)},[]),ze=d(e=>{Z(()=>e)},[]),h=L==="excel",g=L==="docx",oe=h?"Excel":g?"DOCX":"PDF",U=h?".xlsx":g?".docx":".pdf";F(()=>{Y(null),K(null),V(null),Z(null)},[s]);const B=W(()=>typeof a=="string"?a:Array.isArray(a)?a.join(`
2
2
 
3
3
  `):"",[a]),{companyLogo:j}=nn({}),{preferences:I}=se(),te=d(async e=>{if((b==null?void 0:b.enabled)===!1||b&&b.logo!==void 0||!j||e!=null&&e.logoDataUrl)return e;let n=null;try{const r=I==null?void 0:I[ce.GLOBAL.EXPORT_SETTINGS];n=(typeof r=="string"?JSON.parse(r):r)??null}catch{}if((n==null?void 0:n.logoEnabled)===!1)return e;try{const r=await on(j);return{...e,logoDataUrl:r,logoOnFirstSheetOnly:(e==null?void 0:e.logoOnFirstSheetOnly)??(n==null?void 0:n.logoOnFirstSheetOnly)}}catch(r){return E({error:r,extra:{context:"tabbed export logo fallback"}}),e}},[b,j,I,E]),Le=d(async()=>{var e;if(!(!i||!N)){$(!0);try{const n=x||"document",r=R||y,H=r==null?void 0:r.documentFont,ae=((e=r==null?void 0:r.componentColors)==null?void 0:e.styleFirstColumnAsHeader)??!1,Ye=i.map(async D=>{if(D==="pdf")return{blob:s==="document"&&f?await f():await tn(B,n,void 0,H,ae),filename:`${n}.pdf`,contentType:"application/pdf"};if(D==="word")return{blob:s==="document"&&p?await p():await ln(B,n,ae),filename:`${n}.docx`,contentType:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"};{const re=D==="excel_multiple"?"separate":"single",ie=await X(B,n,re,!0,await te(r));return ie?{blob:ie,filename:`${n}${re==="separate"?"_sheets":""}.xlsx`,contentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}:null}}),Ke=(await Promise.all(Ye)).filter(D=>D!==null);N(Ke),t()}catch(n){if(me(n))return;E({error:n,extra:{emailFormats:i}}),v({title:"Export Failed",description:n instanceof Error?n.message:"An unknown error occurred",variant:"destructive"})}finally{$(!1)}}},[i,N,s,f,p,B,x,R,y,te,t,E,v]),Re=async()=>{if(Se){De();return}if(m&&N){await Le();return}$(!0);try{if(G&&p){const e=await p(),n=`${x||"document"}.docx`;G(e,n)}if(h){const e=typeof a=="string"?a:Array.isArray(a)?a.join(`
4
4