@wildo-ai/application-creation-workbench 1.1.12 → 1.1.14

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 (179) hide show
  1. package/dist/.vite/manifest.json +552 -551
  2. package/dist/assets/{ChartEmptyState-BC4PowrY.js → ChartEmptyState-DOlrd3QL.js} +1 -1
  3. package/dist/assets/ChartLoadingSkeleton-BlVB40sh.js +1 -0
  4. package/dist/assets/{ChartView-Dxhrm4ZQ.js → ChartView-nQvehKAl.js} +2 -2
  5. package/dist/assets/ChartWidget-CZ5NXj5y.js +5 -0
  6. package/dist/assets/{abnfDiagram-VCTEODGH-DAniiSne.js → abnfDiagram-VCTEODGH-BOSMF_iF.js} +1 -1
  7. package/dist/assets/{af-6ARmQGcy.js → af-1WnNPqq-.js} +1 -1
  8. package/dist/assets/{ar-txED5dLR.js → ar-I_OTuA6g.js} +1 -1
  9. package/dist/assets/{architectureDiagram-5GKGNRK7-B3fuQHXi.js → architectureDiagram-5GKGNRK7-F_DICN7K.js} +1 -1
  10. package/dist/assets/badge-tone-B1Pd5hFs.js +5 -0
  11. package/dist/assets/{bg-CeKEO9Mk.js → bg-BNynXrJg.js} +1 -1
  12. package/dist/assets/{blockDiagram-I7D4REHJ-DNUQ2an8.js → blockDiagram-I7D4REHJ-vdakidUW.js} +1 -1
  13. package/dist/assets/{bn-CX09B8uK.js → bn-IoUqFxhs.js} +1 -1
  14. package/dist/assets/{c4Diagram-7LVT6UL2-D1fhMmVz.js → c4Diagram-7LVT6UL2-cnHP-5K7.js} +1 -1
  15. package/dist/assets/{ca-Bhlp9MKF.js → ca-CWN_9uem.js} +1 -1
  16. package/dist/assets/channel-Dn5Kml0R.js +1 -0
  17. package/dist/assets/{chunk-4HAMMTFA-Bujib7vW.js → chunk-4HAMMTFA-C6G-f7n3.js} +1 -1
  18. package/dist/assets/{chunk-75Z2AOVW-3MyZWqz7.js → chunk-75Z2AOVW-DiyJkf0q.js} +1 -1
  19. package/dist/assets/{chunk-DU6HZSFF-D9yFJR5s.js → chunk-DU6HZSFF-Dy7jxNH_.js} +2 -2
  20. package/dist/assets/{chunk-F27PBJKO-DbSVFcZ1.js → chunk-F27PBJKO-CkvHG7F6.js} +1 -1
  21. package/dist/assets/{chunk-GMAD6QVW-DjHRLroQ.js → chunk-GMAD6QVW-DsY6Jtz4.js} +1 -1
  22. package/dist/assets/{chunk-GVQU2GXP-CZSwyKRU.js → chunk-GVQU2GXP-BE5D92zU.js} +1 -1
  23. package/dist/assets/{chunk-IMKFNOWR-hW5t7Qw5.js → chunk-IMKFNOWR-CAwOIW4R.js} +1 -1
  24. package/dist/assets/{chunk-L3NEJ4N5-Bv6xmFwR.js → chunk-L3NEJ4N5-B1mDlHi1.js} +1 -1
  25. package/dist/assets/{chunk-OSK3NFVY-DJUzz194.js → chunk-OSK3NFVY-iylVXGs0.js} +1 -1
  26. package/dist/assets/{chunk-P2QGCYS3-7SeAsW9y.js → chunk-P2QGCYS3-CvcRZ6j9.js} +1 -1
  27. package/dist/assets/{chunk-POPQ4Y6H-CQNafNbB.js → chunk-POPQ4Y6H-CNbcNXVN.js} +1 -1
  28. package/dist/assets/{chunk-PWAF6VOD-jHVX7TMJ.js → chunk-PWAF6VOD-BorA01Hz.js} +1 -1
  29. package/dist/assets/{chunk-SHT3W25Y-F6dBohnU.js → chunk-SHT3W25Y-DNWg7N7_.js} +1 -1
  30. package/dist/assets/{chunk-SVP7TREG-CT22LVkh.js → chunk-SVP7TREG-C_gZGZzY.js} +1 -1
  31. package/dist/assets/{chunk-TICWLB2K-Dr-TnJTR.js → chunk-TICWLB2K-CG8L7csD.js} +1 -1
  32. package/dist/assets/classDiagram-ZZMXUADV-DZBHmNh2.js +1 -0
  33. package/dist/assets/classDiagram-v2-VYDZK3BY-DZBHmNh2.js +1 -0
  34. package/dist/assets/cm6-editor-BrI954sl.js +13 -0
  35. package/dist/assets/{code-block-IT6T5CEO-DeiNc4QM.js → code-block-IT6T5CEO-P8OONT1n.js} +1 -1
  36. package/dist/assets/{context-lL4c0mdb.js → context-BNM55Snb.js} +1 -1
  37. package/dist/assets/{cs-ZvuhFxc7.js → cs-CmgNpjMj.js} +1 -1
  38. package/dist/assets/{cy-P-7_oBM6.js → cy-zQX_QEXD.js} +1 -1
  39. package/dist/assets/{cynefinDiagram-5FMLGOSQ-rrIzisOw.js → cynefinDiagram-5FMLGOSQ-Drk0vtFB.js} +1 -1
  40. package/dist/assets/{da-Ij9mguPT.js → da-CjOdj32R.js} +1 -1
  41. package/dist/assets/{dagre-GXQ25YYZ-BHke2BKR.js → dagre-GXQ25YYZ-CLrGf0om.js} +1 -1
  42. package/dist/assets/{de-AT-pBRQu7rV.js → de-AT-BLeHD7-g.js} +1 -1
  43. package/dist/assets/{de-BvpvTOVk.js → de-CwLcXmDQ.js} +1 -1
  44. package/dist/assets/{diagram-S7CK7UJ4-DSVi59-i.js → diagram-S7CK7UJ4-B-ZdgPTX.js} +1 -1
  45. package/dist/assets/{diagram-UQ7AKVKN-Dzm3EQCI.js → diagram-UQ7AKVKN-BkKvmg4L.js} +1 -1
  46. package/dist/assets/{diagram-VSXAHHWV-C_Cwqxyu.js → diagram-VSXAHHWV-HiaAFHhk.js} +1 -1
  47. package/dist/assets/{diagram-VX7I27RA-j-RbCkFh.js → diagram-VX7I27RA-DwkAZ58D.js} +1 -1
  48. package/dist/assets/{diagram-Z3DM3KII-eU4ZoMfW.js → diagram-Z3DM3KII-D-cMFf4d.js} +1 -1
  49. package/dist/assets/{dist-BJAul1MI.js → dist-5fOMJ27f.js} +1 -1
  50. package/dist/assets/{dist-CYCtpul3.js → dist-7Nz9yNhS.js} +1 -1
  51. package/dist/assets/{dist-Cp0QMixe.js → dist-BCRkZyjz.js} +1 -1
  52. package/dist/assets/{dist-CMt9H2Ew.js → dist-BHvGeTYl.js} +1 -1
  53. package/dist/assets/{dist-BIoddEoP.js → dist-BgSqI6_g.js} +1 -1
  54. package/dist/assets/{dist-BH50WQuC.js → dist-BxwAVf7j.js} +1 -1
  55. package/dist/assets/{dist-C4M0SV8x.js → dist-ByMsVuIk.js} +1 -1
  56. package/dist/assets/{dist-g1q7TkMi.js → dist-CE3k7Kha.js} +1 -1
  57. package/dist/assets/{dist-DEAzYsYo.js → dist-CFrG-Mt_.js} +1 -1
  58. package/dist/assets/{dist-Copqz2Zc.js → dist-CJxRNwMR.js} +1 -1
  59. package/dist/assets/{dist-CIJHcnby.js → dist-CPhv_Fl3.js} +1 -1
  60. package/dist/assets/{dist-BS1Kdsll.js → dist-CPuGLmxI.js} +1 -1
  61. package/dist/assets/{dist-D2x0_5Vw.js → dist-CRpxTWEh.js} +1 -1
  62. package/dist/assets/{dist-DJw851Uo.js → dist-CstXuejQ.js} +1 -1
  63. package/dist/assets/{dist-xdVQ9O1H.js → dist-Cuhv1Fm_.js} +1 -1
  64. package/dist/assets/{dist-BtHXFXvI.js → dist-DJ3oXpIs.js} +1 -1
  65. package/dist/assets/{dist-AwELwF0u.js → dist-DgFx0nHw.js} +1 -1
  66. package/dist/assets/{dist-BCKtn7dL.js → dist-DlNJgHFc.js} +1 -1
  67. package/dist/assets/{dist-CyL1AF6b.js → dist-Dy2TKEdf.js} +1 -1
  68. package/dist/assets/{dist-OAEdfO6o.js → dist-KJ6-32V3.js} +1 -1
  69. package/dist/assets/{dist-B4qlbkDT.js → dist-OpJd06F1.js} +1 -1
  70. package/dist/assets/{dist-DdLKhkto.js → dist-kKXf1Bjx.js} +1 -1
  71. package/dist/assets/{dist-Deso_pi0.js → dist-tfb1xShq.js} +1 -1
  72. package/dist/assets/{dropbox-picker-DKjSUSy7.js → dropbox-picker-C9r5F3kM.js} +1 -1
  73. package/dist/assets/{ebnfDiagram-PWID7BFC-D6kpCTf2.js → ebnfDiagram-PWID7BFC-DrvpEZ_f.js} +1 -1
  74. package/dist/assets/{el-koo0pLJ9.js → el-CWW60iH9.js} +1 -1
  75. package/dist/assets/{en-AU-Bfhd2HUx.js → en-AU-BossA0Rn.js} +1 -1
  76. package/dist/assets/{en-CA-o4msFHUu.js → en-CA-DATw2cVB.js} +1 -1
  77. package/dist/assets/{en-GB-0B3YNqmw.js → en-GB-CUli1ZoP.js} +1 -1
  78. package/dist/assets/{erDiagram-RLTQ6QDP-C4FnvB80.js → erDiagram-RLTQ6QDP-aafi4jCY.js} +1 -1
  79. package/dist/assets/{es-D3vTEBnH.js → es-qp1wsCMr.js} +1 -1
  80. package/dist/assets/{esm-BI55uNP_.js → esm-B3AZ9HP5.js} +1 -1
  81. package/dist/assets/esm-GB9ACU6Q.js +46 -0
  82. package/dist/assets/{et-CuxIGsPb.js → et-CuSdGi0t.js} +1 -1
  83. package/dist/assets/{eu-m6DSB3U4.js → eu-xCnVjdHU.js} +1 -1
  84. package/dist/assets/{fa-IR-nYH-4dE0.js → fa-IR-DZ3ibPOw.js} +1 -1
  85. package/dist/assets/{fi-BtEUoCwT.js → fi-g4XjAI_I.js} +1 -1
  86. package/dist/assets/flowDiagram-HODETNUW-RzRAndm9.js +1 -0
  87. package/dist/assets/{flows-actors-graph-runtime-gROuX0bc.js → flows-actors-graph-runtime-DeTt1QCB.js} +1 -1
  88. package/dist/assets/{fr-C_yCKbUr.js → fr-BhOuGXkV.js} +1 -1
  89. package/dist/assets/{fr-CA-CK6DZ0Y0.js → fr-CA-BYF9Kaol.js} +1 -1
  90. package/dist/assets/{ganttDiagram-EL5Y4UJY-D0jiwOL1.js → ganttDiagram-EL5Y4UJY-CRmnjbyh.js} +1 -1
  91. package/dist/assets/{gitGraphDiagram-WWUBYQGX-D8pPMPkg.js → gitGraphDiagram-WWUBYQGX-C4ebHhmy.js} +1 -1
  92. package/dist/assets/{gl-Eza1ndh4.js → gl-BLfeYzoG.js} +1 -1
  93. package/dist/assets/{google-drive-picker-Ds6m-aGn.js → google-drive-picker-3-SZkSfN.js} +1 -1
  94. package/dist/assets/{graph-runtime-NezJb61g.js → graph-runtime-BbbtydnB.js} +1 -1
  95. package/dist/assets/{he-DmFVpLKY.js → he-BXMp0P82.js} +1 -1
  96. package/dist/assets/{hi-omEXWkim.js → hi-BmH5--Ew.js} +1 -1
  97. package/dist/assets/{hr-BYIhr9zQ.js → hr-CsQDZ0KK.js} +1 -1
  98. package/dist/assets/{hu-S-zl8VEE.js → hu-DiL5YUSE.js} +1 -1
  99. package/dist/assets/{id-BlVfaWlx.js → id-1Vn21CD0.js} +1 -1
  100. package/dist/assets/{index-EhSlDMAI.css → index-Bcdys-EF.css} +1 -1
  101. package/dist/assets/index-TNOEipJX.js +202 -0
  102. package/dist/assets/{infoDiagram-27XIBGKW-D4Z1xJpi.js → infoDiagram-27XIBGKW-CplMaWp5.js} +1 -1
  103. package/dist/assets/{is-kinij3xP.js → is-CByKTwFK.js} +1 -1
  104. package/dist/assets/isSameWeek-Bf15BL-p.js +1 -0
  105. package/dist/assets/{ishikawaDiagram-5VMMS53U-Ciua2PUb.js → ishikawaDiagram-5VMMS53U-BREas_JM.js} +1 -1
  106. package/dist/assets/{it-DAJ9HpEh.js → it-CPNWwvi0.js} +1 -1
  107. package/dist/assets/{ja-CVJ6cRU-.js → ja-D9Jm250G.js} +1 -1
  108. package/dist/assets/{journeyDiagram-3NMN7TZE-D2yd4EpM.js → journeyDiagram-3NMN7TZE-DWHGp6os.js} +1 -1
  109. package/dist/assets/{kanban-definition-UXKFOSKX-D9VhVOLa.js → kanban-definition-UXKFOSKX-CP-1mPST.js} +1 -1
  110. package/dist/assets/katex-Dp9rtsw4.js +1 -0
  111. package/dist/assets/{ko-D4zln2fF.js → ko-CpsoMmES.js} +1 -1
  112. package/dist/assets/{line-CF7aeIX6.js → line-C_Dg3XTF.js} +1 -1
  113. package/dist/assets/{linear-DaBItCqY.js → linear-DMyAYyr-.js} +1 -1
  114. package/dist/assets/{lt-C7az4iaU.js → lt-Ckx9bY2o.js} +1 -1
  115. package/dist/assets/{lv-JpmRbJV_.js → lv-DZt3HT5G.js} +1 -1
  116. package/dist/assets/{markdown-stream-runtime-B89TcLYb.js → markdown-stream-runtime-CMB_Qu0K.js} +4 -4
  117. package/dist/assets/{match-DCIBCbPQ.js → match-CLYNQBt4.js} +1 -1
  118. package/dist/assets/{match-D4V1W1KE.js → match-_OgMbUjy.js} +1 -1
  119. package/dist/assets/mermaid-VLURNSYL-DXNPK6wv.js +1 -0
  120. package/dist/assets/{mermaid.core-DD8EuqGp.js → mermaid.core-D_DICvzX.js} +4 -4
  121. package/dist/assets/{mindmap-definition-YA3MSWOX-DzrVzTT_.js → mindmap-definition-YA3MSWOX-C20ANuWc.js} +1 -1
  122. package/dist/assets/{ms-vf5qJzAc.js → ms-C7UJy830.js} +1 -1
  123. package/dist/assets/{mt-9_qeU9SR.js → mt-8KsNOVwG.js} +1 -1
  124. package/dist/assets/{nb-7TG2076-.js → nb-C7YQIAOB.js} +1 -1
  125. package/dist/assets/{nl-D75P5GG_.js → nl-UadnkhJV.js} +1 -1
  126. package/dist/assets/node-nqfXDpgr.js +2 -0
  127. package/dist/assets/{onedrive-picker-0mB1UsJj.js → onedrive-picker-C_4mWMyM.js} +1 -1
  128. package/dist/assets/{pdf-viewer-DPiwTeTb.js → pdf-viewer-By7fQHYQ.js} +1 -1
  129. package/dist/assets/{pegDiagram-XKGWAZYB-DMK1vOLC.js → pegDiagram-XKGWAZYB-DVbFO1Fa.js} +1 -1
  130. package/dist/assets/{pieDiagram-E7YTZNPT-DBKY7gnL.js → pieDiagram-E7YTZNPT-DWtaagpj.js} +1 -1
  131. package/dist/assets/{pl-BbmlCE_y.js → pl-DaJL5jLd.js} +1 -1
  132. package/dist/assets/{pt-Dwabdb55.js → pt-BHQDKf9o.js} +1 -1
  133. package/dist/assets/{pt-BR-CAga1VvG.js → pt-BR-zn9BrDVb.js} +1 -1
  134. package/dist/assets/{public-runtime-D-EeE8cv.js → public-runtime-f4VjjFok.js} +2 -2
  135. package/dist/assets/{quadrantDiagram-AXDQQJYC-CNthG-7I.js → quadrantDiagram-AXDQQJYC-CJvBFA_c.js} +1 -1
  136. package/dist/assets/{railroadDiagram-O6MQD6OU-_OuV9W5c.js → railroadDiagram-O6MQD6OU-Dygrn5Zv.js} +1 -1
  137. package/dist/assets/{requirementDiagram-BXWQKSXE-D3w49UW4.js → requirementDiagram-BXWQKSXE-BpnohlUt.js} +1 -1
  138. package/dist/assets/{ro-Tme9NXKi.js → ro-BdQOzb6t.js} +1 -1
  139. package/dist/assets/{ru-cw6HYkru.js → ru-BmbP3F22.js} +1 -1
  140. package/dist/assets/{sankeyDiagram-P5KCCOFB-D5uteHCL.js → sankeyDiagram-P5KCCOFB-Cyy3VaYL.js} +1 -1
  141. package/dist/assets/{sequenceDiagram-WJ2MYXX4-9CeFVdiB.js → sequenceDiagram-WJ2MYXX4-GaYcTb-c.js} +1 -1
  142. package/dist/assets/{sk-8VSY23Ma.js → sk-Deobe1dz.js} +1 -1
  143. package/dist/assets/{sl-Dm3eLvz9.js → sl-DDWo-_WQ.js} +1 -1
  144. package/dist/assets/{stateDiagram-D77RDMKH-CZ5Bnsal.js → stateDiagram-D77RDMKH-DGiRCD9r.js} +1 -1
  145. package/dist/assets/stateDiagram-v2-MP3YSRHH-CZRVHb2L.js +1 -0
  146. package/dist/assets/{sv-DpeP710f.js → sv-DQUMehtC.js} +1 -1
  147. package/dist/assets/{swimlanes-42K2YHIH-DY7jTvPb.js → swimlanes-42K2YHIH-D7xJP0pw.js} +1 -1
  148. package/dist/assets/swimlanesDiagram-VR7AAH4N-C2KDCowk.js +8 -0
  149. package/dist/assets/{ta-CpEg7vSC.js → ta-CzkRFNns.js} +1 -1
  150. package/dist/assets/{th-DN9gntTp.js → th-DR6hfS-t.js} +1 -1
  151. package/dist/assets/{timeline-definition-24CTP7MA-DwT8DKFM.js → timeline-definition-24CTP7MA-DTJnlCQe.js} +1 -1
  152. package/dist/assets/{tr-DPUIVSGQ.js → tr-ECW9jg6T.js} +1 -1
  153. package/dist/assets/useI18n-CrrUk_L3.js +171 -0
  154. package/dist/assets/{vennDiagram-4TSXK5OY-BXfI2llp.js → vennDiagram-4TSXK5OY-CFat-M74.js} +1 -1
  155. package/dist/assets/{vi-DT80XNHr.js → vi-D2nRiUXf.js} +1 -1
  156. package/dist/assets/{wardleyDiagram-VM6X3IG4-Dpki9_Se.js → wardleyDiagram-VM6X3IG4-h29SCI73.js} +1 -1
  157. package/dist/assets/{xychartDiagram-S5SC5T6Z-Drkgs_g0.js → xychartDiagram-S5SC5T6Z-B8S8taDj.js} +1 -1
  158. package/dist/assets/{zh-CN-Dcwslx_d.js → zh-CN-Cn0aI883.js} +1 -1
  159. package/dist/assets/{zh-HK-BNu9B5SY.js → zh-HK-DxBG0PaI.js} +1 -1
  160. package/dist/assets/{zh-TW-CeOM54jX.js → zh-TW-DHK1J7Rs.js} +1 -1
  161. package/dist/index.html +10 -10
  162. package/package.json +10 -10
  163. package/dist/assets/ChartLoadingSkeleton-BUfDWMoH.js +0 -1
  164. package/dist/assets/ChartWidget-CjyBqut4.js +0 -5
  165. package/dist/assets/badge-tone-BImBMJx2.js +0 -5
  166. package/dist/assets/channel-KVQ66UuV.js +0 -1
  167. package/dist/assets/classDiagram-ZZMXUADV-Cu2_yr-A.js +0 -1
  168. package/dist/assets/classDiagram-v2-VYDZK3BY-Cu2_yr-A.js +0 -1
  169. package/dist/assets/cm6-editor-zaCDXA9R.js +0 -13
  170. package/dist/assets/esm-DjSVWi2t.js +0 -46
  171. package/dist/assets/flowDiagram-HODETNUW-bt2zzz0X.js +0 -1
  172. package/dist/assets/index-B7eQc9Zm.js +0 -202
  173. package/dist/assets/isSameWeek-BttcEFi5.js +0 -1
  174. package/dist/assets/katex-Dl5hBKq4.js +0 -1
  175. package/dist/assets/mermaid-VLURNSYL-KYomrFRA.js +0 -1
  176. package/dist/assets/node-D1TKeHq4.js +0 -2
  177. package/dist/assets/stateDiagram-v2-MP3YSRHH-DTPx5dUS.js +0 -1
  178. package/dist/assets/swimlanesDiagram-VR7AAH4N-BKfUkABE.js +0 -8
  179. package/dist/assets/useI18n-pnDuUxWI.js +0 -171
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-BWaJ3C7D.js";import{t as n}from"./react-9WV3M1gM.js";import{$ as r,$a as i,$b as a,$i as o,Aa as s,Ar as c,By as l,Db as u,Dt as d,ES as f,En as p,F_ as m,Fb as h,Fr as g,Ft as _,Fx as v,GE as y,Ho as b,I_ as x,Ia as S,It as C,Ja as ee,Jb as w,Jp as T,Jv as E,Kp as te,Kw as ne,La as re,Lp as ie,Lr as ae,Lt as oe,Mr as D,Nn as se,Nr as ce,Nt as le,Ox as O,Px as k,Qi as ue,Ql as de,Qy as fe,R as A,RT as pe,Rp as j,Sa as me,Sd as he,Sg as ge,TS as _e,Tg as ve,UE as ye,Uo as be,Vb as xe,Wp as Se,Xa as Ce,Xb as M,Xi as we,Xp as Te,Za as Ee,Zb as De,Zi as Oe,_E as ke,_a as Ae,_b as je,_t as Me,an as Ne,bb as Pe,bt as Fe,ca as Ie,cm as Le,db as Re,du as ze,eD as Be,ea as Ve,eb as He,em as Ue,eo as We,et as Ge,ft as N,fu as Ke,gb as qe,go as Je,gt as Ye,hf as Xe,ht as Ze,iy as Qe,jr as P,jt as $e,k as F,kr as et,l as tt,lt as nt,ma as rt,mt as it,n as at,nt as ot,ny as st,pa as ct,pn as lt,qS as ut,qo as dt,qp as ft,r as pt,rD as mt,rS as ht,ry as gt,sy as _t,t as vt,ta as yt,uD as bt,vD as xt,vg as St,vh as Ct,vt as wt,w as Tt,wa as Et,wt as Dt,wx as Ot,x as kt,xa as At,yb as I,yt as jt,zr as Mt}from"./useI18n-pnDuUxWI.js";import{Ai as Nt,Br as Pt,Cr as Ft,Fi as It,Pi as L,Si as R,Yr as z,_i as Lt,br as Rt,ci as zt,dr as B,er as V,li as H,or as Bt,sr as U}from"./public-runtime-D-EeE8cv.js";import{t as Vt}from"./jsx-runtime-lTuChwRC.js";function Ht(e){return e?{needsObjectContext:e.needsObjectContext===!0,needsUserContext:e.needsUserContext===!0}:{needsObjectContext:!1,needsUserContext:!1}}function Ut(e){let t=Ht(e.enabledCondition),n=Ht(e.basicPrefixOperation);return{needsObjectContext:t.needsObjectContext||n.needsObjectContext,needsUserContext:t.needsUserContext||n.needsUserContext}}var W=e(n(),1),Wt;(function(e){e.APPLICATION=`application`,e.RESOURCE=`resource`})(Wt||={});var Gt=Ft(`scope`,[H({scope:z(Wt.APPLICATION)}),H({scope:z(Wt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional()})]);function Kt(e){return`app.${e}`}var qt;(function(e){e.RESOURCE=`resource`,e.COMPOSITE_VIEW=`composite-view`,e.APP_VIEW=`app-view`})(qt||={});var Jt;(function(e){e.CHART_VIEW=`chart-view`,e.COMPOSITE_VIEW=`composite-view`,e.EXECUTION_VIEW=`execution-view`})(Jt||={});var Yt;(function(e){e.APP_SCOPE=`app-scope`,e.PARENT_CONTEXT=`parent-context`,e.URL_PARAM=`url-param`,e.FIXED_VALUE=`fixed-value`})(Yt||={});var Xt=H({hostKind:V(qt),hostRef:R().min(1),viewKind:V(Jt),localRef:R().min(1),insertedViewRef:R().min(1)}),Zt=`::`;function Qt(e){return[e.hostKind,e.viewKind,e.hostRef,e.localRef].join(Zt)}function $t(e){return{...e,insertedViewRef:Qt(e)}}function en(e){if(!e)return;let[t,n,r,i,...a]=e.split(Zt);if(!(!t||!n||!r||!i||a.length>0)&&Object.values(qt).includes(t)&&Object.values(Jt).includes(n))return{hostKind:t,hostRef:r,viewKind:n,localRef:i,insertedViewRef:e}}var tn=H({inputRef:R().min(1),source:V(Yt),contextKey:R().min(1).optional(),value:It().optional()}).superRefine((e,t)=>{e.source===Yt.FIXED_VALUE?e.value===void 0&&t.addIssue({code:`custom`,message:"Fixed-value inserted view bindings require `value`.",path:[`value`]}):e.contextKey||t.addIssue({code:`custom`,message:"Context-driven inserted view bindings require `contextKey`.",path:[`contextKey`]})}),nn=H({identity:Xt,contextResourceIdentifiers:Lt(R(),R()),resolvedInputs:Lt(R(),It()).optional()});function rn(e){return Kt(e)}function an(e,t){return`resources.${e}.${t}`}function on(e,t={}){return{viewComponent:e,...t}}var sn=`composite_ctx_`;function cn(e){return e?.isAddressable===!0&&e.scope===Wt.APPLICATION}function ln(e){return e?Object.entries(e).map(([e,t])=>({ref:e,translationRef:rn(e),scope:Wt.APPLICATION,isAddressable:!0,operationLike:M.READ,primaryScope:I.APPLICATION,sectionRefs:t.sectionRefs,labels:t.labels,viewComponent:t.viewComponent,icon:t.icon,adjacentZoneOnEmpty:t.adjacentZoneOnEmpty,zoneContentMaxWidth:t.zoneContentMaxWidth,zoneContentFillsHeight:t.zoneContentFillsHeight})):[]}function un(e){return e?.isAddressable===!0&&e.scope===Wt.RESOURCE}function dn(e){return e?e.scope===Wt.APPLICATION?cn(e):un(e):!1}function fn(e,t){return $t({hostKind:qt.RESOURCE,hostRef:e,viewKind:Jt.COMPOSITE_VIEW,localRef:t.ref})}function pn(e){let{viewRef:t,compositeViews:n,registry:r}=e;if(!t)return;let i=n?.find(e=>e.ref===t);if(i)return i;let a=en(t);if(a&&a.hostKind===qt.RESOURCE&&a.viewKind===Jt.COMPOSITE_VIEW)return r?.resourceConfigurations[a.hostRef]?.frontendConfiguration?.compositeViews?.find(e=>e.ref===a.localRef)}function mn(e){let{viewRef:t,compositeViews:n,registry:r}=e;if(!t)return;let i=n?.find(e=>e.ref===t);if(i?.primaryScope)return i.primaryScope;let a=en(t);if(a&&a.hostKind===qt.RESOURCE&&a.viewKind===Jt.COMPOSITE_VIEW)return r?.resourceConfigurations[a.hostRef]?.frontendConfiguration?.compositeViews?.find(e=>e.ref===a.localRef)?.primaryScope}function hn(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t??{}))r&&n.set(`${sn}${e}`,r);let r=n.toString();return r.length>0?`/composite/${e}?${r}`:`/composite/${e}`}function gn(e){let t={};for(let[n,r]of e.entries())n.startsWith(`composite_ctx_`)&&r&&(t[n.slice(14)]=r);return Object.keys(t).length>0?t:void 0}var _n=H({ref:R().min(1),translationRef:R().min(1),isAddressable:B().default(!1),operationLike:V(M).default(M.READ),primaryScope:V(I).default(I.ORGANIZATIONS),sectionRefs:U(R()).optional(),labels:U(Bt()).optional(),viewComponent:Bt(),requiredFeatures:Le.optional(),icon:Rt().optional(),adjacentZoneOnEmpty:V(xe).optional(),zoneContentMaxWidth:V(f).optional(),zoneContentFillsHeight:B().optional()}),vn=Pt(Gt,_n),yn=vn,bn=Pt(Gt,H({ref:R().min(1),trigger:ge.optional(),options:ve,elements:U(St),requiredFeatures:Le.optional()})),xn=Pt(Gt,H({ref:R().min(1),isAddressable:B().default(!1),operationLike:V(M).default(M.READ),primaryScope:V(I).default(I.ORGANIZATIONS),systemRef:R().min(1),layoutPreset:R().default(`Default`),requiredFeatures:Le.optional(),icon:Rt().optional()})),Sn=Pt(Gt,H({ref:R().min(1),isAddressable:B().default(!1),operationLike:V(M).default(M.READ),primaryScope:V(I).default(I.ORGANIZATIONS),componentRef:R().min(1),requiredFeatures:Le.optional(),icon:Rt().optional(),labels:U(Bt()).optional()})),Cn;(function(e){e.COMMAND_ONLY=`command_only`,e.OMNIBOX=`omnibox`})(Cn||={});var wn;(function(e){e.USER_INFO=`user_info`,e.ORG_SWITCHER=`org_switcher`,e.SETTINGS=`settings`,e.LOGOUT=`logout`})(wn||={});var Tn;(function(e){e.AVATAR_ONLY=`avatar_only`,e.AVATAR_NAME=`avatar_name`,e.AVATAR_ORG=`avatar_org`,e.FULL=`full`})(Tn||={});var En;(function(e){e.CONTROL_ONLY=`control-only`,e.ICON_LED=`icon-led`,e.LABEL_ABOVE=`label-above`})(En||={});var Dn=H({resourceType:R(),fieldIdentifier:R(),position:zt().optional(),dependsOn:R().optional(),persist:B().optional(),label:R().optional(),optionDisplayMode:V([ke.LABEL,ke.SUMMARY]).optional(),presentation:V(En).optional()}),On=999;function kn(e){if(!e||e.length===0)return[];let t=new Map;for(let n of e){let e=t.get(n.resourceType);e?e.push(n.fieldIdentifier):t.set(n.resourceType,[n.fieldIdentifier])}return Array.from(t.entries()).filter(([,e])=>e.length>1).map(([e,t])=>({resourceType:e,fieldIdentifiers:t}))}var An=H({fields:U(Dn).optional()}),jn=L([R(),zt()]),Mn=H({id:R(),label:R(),icon:R().optional(),value:L([R(),zt()]).optional()}),Nn=Mn.extend({type:z(k.TEXT)}),Pn=Mn.extend({type:z(k.LINK),href:R()}),Fn=Mn.extend({type:z(k.BUTTON),onClick:Rt(e=>typeof e==`function`)}),In=Ft(`type`,[Nn,Pn,Fn]),Ln=H({[Ot.MENUBAR]:L([B().default(!0),L([z(`FIXED`),z(`OVERLAY`)]).default(`FIXED`),U(H({breakpoint:V(pe).default(pe.MOBILE),responsivePolicy:L([z(`FIXED`),z(`OVERLAY`)]).default(`FIXED`)})),H({displayPolicy:L([z(`FIXED`),z(`OVERLAY`)]).default(`FIXED`),hostedComponents:U(ct).optional(),items:U(rt).optional(),brandHeader:B().optional(),brandMarkTheme:V(m).optional()})]).default(!0),[Ot.TOOLBAR]:L([B(),H({placement:L([z(`top`),z(`bottom`)]).default(`top`),compact:B().optional(),showSeparator:B().optional(),hideOnMobile:B().optional(),tools:U(S).optional()})]).default(!0),[Ot.HOTKEY]:L([B(),H({bindings:U(Ie).optional(),emitShortcuts:U(O).optional()})]).default(!0),[Ot.NOTIFICATION_CENTER]:B().default(!0),[Ot.SIDEBAR]:L([B(),H({placement:L([z(ut.START),z(ut.END)]),collapsible:B().default(!0),defaultCollapsed:B().optional(),responsiveBreakpoint:V(pe).default(pe.MOBILE),responsivePolicy:V(Et).default(Et.BURGER),defaultSection:R().default(`main`),homeDisplayMode:V(At).optional(),brandMarkTheme:V(m).optional(),contentSections:U(s).optional(),hostedComponents:U(me).optional(),width:zt().optional(),mobileWidth:zt().optional(),collapsedWidth:zt().optional(),mobileCollapsedWidth:zt().optional()})]).default(!0),[Ot.COMMAND_MENU]:L([B(),H({policy:V(Cn).default(Cn.COMMAND_ONLY),showRecent:B().default(!0),maxRecentItems:zt().default(5),showShortcuts:B().default(!0),defaultCategory:R().optional(),openShortcut:R().optional(),commands:U(o).optional(),searchResources:U(Ve).optional(),categoryOrder:U(R()).optional(),dialogWidth:R().optional()})]).default(!0),[Ot.QUICK_ACTION_BUTTON]:L([B(),z(`FLOATING`),H({actions:U(Ae).optional()})]).default(!0),[Ot.QUICK_SWITCHER]:B().default(!0),[Ot.CONTROL_PANEL]:L([B().default(!0),H({items:U(yt).optional()})]).default(!0),[Ot.STATUS_BAR]:L([B().default(!0),v,H({placement:v.optional(),showMemoryUsage:B().default(!1),showNotificationCount:B().default(!0),showConnectionStatus:B().default(!0),showConnectionStatusOnMobile:B().optional(),backgroundClassName:R().optional(),textClassName:R().optional(),showBorder:B().optional(),height:zt().optional(),statusItems:U(In).optional(),style:Lt(R(),jn).optional()})]).default(!0),[Ot.USER_DROPDOWN]:L([B().default(!0),H({avatarDisplay:V(Tn).default(Tn.AVATAR_ONLY),sections:U(V(wn)).optional(),showOrgSwitcher:B().default(!0),showLogout:B().default(!0),settingsEntries:U(R()).optional()})]).default(!0),[Ot.NAVIGATION_CONTROL]:B().default(!0),[Ot.ACTIVITY_BAR]:L([B(),H({desktopRendering:Oe.default(we.VERTICAL_RAIL),mobileRendering:Oe.default(we.BOTTOM_TAB_BAR)})]).default(!1),[Ot.UTILITY_PANEL]:L([B(),H({items:U(re).optional(),icon:R().optional(),position:L([z(ut.START),z(ut.END)]).default(ut.END)})]).default(!1)}),Rn;(function(e){e.TOP_SIDEBAR=`top_sidebar`,e.BOTTOM_SIDEBAR=`bottom_sidebar`,e.MENUBAR_RIGHT=`menubar_right`,e.MENUBAR_LEFT=`menubar_left`,e.FLOATING=`floating`})(Rn||={});var zn;(function(e){e.TOP_SIDEBAR=`top_sidebar`,e.BOTTOM_SIDEBAR=`bottom_sidebar`,e.MENUBAR_RIGHT=`menubar_right`,e.MENUBAR_LEFT=`menubar_left`,e.USER_DROPDOWN=`user_dropdown`,e.SETTINGS_DROPDOWN=`settings_dropdown`})(zn||={});var Bn;(function(e){e.COMPACT=`compact`,e.EXPANDED=`expanded`,e.BOTH=`both`})(Bn||={});var Vn=H({resourceOperationPath:Ee.optional(),compositeViewReference:R().optional()}),Hn;(function(e){e.NAVIGATE=`navigate`,e.RETRY=`retry`,e.EXTERNAL=`external`,e.SUPPORT=`support`})(Hn||={});var Un;(function(e){e.LINK=`link`,e.EMAIL=`email`,e.CHAT=`chat`})(Un||={});var Wn;(function(e){e.PDF=`pdf`,e.LINK=`link`})(Wn||={});var Gn=H({type:V(Hn),target:R().optional(),resourceOperationPath:Ee.optional(),compositeViewReference:R().optional(),icon:R().optional()}).superRefine((e,t)=>{let n=!!e.resourceOperationPath||!!e.compositeViewReference,r=typeof e.target==`string`&&e.target.length>0;e.type===Hn.NAVIGATE?!r&&!n&&t.addIssue({code:`custom`,path:[`target`],message:"Navigate error-page actions require `target`, `resourceOperationPath`, or `compositeViewReference`."}):e.type===Hn.RETRY?(e.target!==void 0&&t.addIssue({code:`custom`,path:[`target`],message:"Retry error-page actions do not accept `target`."}),n&&t.addIssue({code:`custom`,path:[`resourceOperationPath`],message:"Structured navigation targets are only valid for `navigate` error-page actions."})):(r||t.addIssue({code:`custom`,path:[`target`],message:`Error-page action type "${e.type}" requires a string target.`}),n&&t.addIssue({code:`custom`,path:[`resourceOperationPath`],message:"Structured navigation targets are only valid for `navigate` error-page actions."}))}),Kn=H({ref:R(),target:R().optional(),resourceOperationPath:Ee.optional(),compositeViewReference:R().optional(),icon:R().optional()}).superRefine((e,t)=>{let n=!!e.resourceOperationPath||!!e.compositeViewReference;!(typeof e.target==`string`&&e.target.length>0)&&!n&&t.addIssue({code:`custom`,path:[`target`],message:"Feature-guide items require `target`, `resourceOperationPath`, or `compositeViewReference`."})}),qn=H({type:V(Un),target:R()}),Jn=H({primaryAction:Gn.optional(),secondaryActions:U(Gn).optional(),supportAccess:qn.optional(),featureGuide:U(Kn).optional(),leadMagnet:H({type:V(Wn),target:R()}).optional()}),Yn=H({notFound:Jn.optional(),unauthorized:Jn.optional(),forbidden:Jn.optional(),serverError:Jn.optional(),maintenance:Jn.optional()}),Xn=H({name:R().min(1),brandAssets:x.array().optional()}),Zn;(function(e){e.HIDDEN=`hidden`,e.BRAND_HEADER=`brand_header`})(Zn||={});var Qn;(function(e){e.CLIENTS=`clients`})(Qn||={});var $n=H({navigationLayout:h,appComponentsConfiguration:Ln,designSystemConfiguration:ht.optional(),compositeViews:yn.array().optional(),onboardingViews:bn.array().optional(),fullCustomViews:Sn.array().optional(),flowsActorsViews:xn.array().optional(),guidanceFlows:Ue.array().optional(),homeDefinition:Vn.optional(),errorPageConfig:Yn.optional(),appModes:ue.array().optional(),appScope:An.optional(),settingsHub:Rt().optional(),suppressedEngineNavigationEntries:U(V(Qn)).optional(),shellIdentity:Xn.optional(),publicShellIdentityMode:V(Zn).optional()}).superRefine((e,t)=>{let n=kn(e.appScope?.fields??[]);for(let e of n)t.addIssue({code:`custom`,path:[`appScope`,`fields`],message:`Duplicate app-scope resourceType "${e.resourceType}" is not allowed in appScope.fields. Conflicting fieldIdentifiers: ${e.fieldIdentifiers.join(`, `)}`})}),G=Vt(),er=`pane`,tr=H({scope:z(Wt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional(),ref:R().min(1),chartDefinition:ze,isAddressable:B().default(!1),operationLike:V(M).default(M.READ),primaryScope:V(I).default(I.ORGANIZATIONS),inputBindings:U(tn).optional(),icon:Rt().optional()});function nr(e){return!(!e||e.isAddressable!==!0)}var rr=H({identity:Xt,executionChartRef:R().min(1),chartDefinition:ze,contextResourceIdentifiers:Lt(R(),R()),resolvedInputs:Ke.optional()}),ir=`chart_ctx_`,ar=`/chart/`;function or(e,t){return $t({hostKind:qt.RESOURCE,hostRef:e,viewKind:Jt.CHART_VIEW,localRef:t.ref})}function sr(e){return{identity:e.identity,executionChartRef:e.chartView.chartDefinition.ref,chartDefinition:e.chartView.chartDefinition,contextResourceIdentifiers:e.contextResourceIdentifiers,resolvedInputs:e.resolvedInputs}}function cr(e){let{viewRef:t,registry:n}=e,r=en(t);if(!r||r.hostKind!==qt.RESOURCE||r.viewKind!==Jt.CHART_VIEW)return;let i=n?.resourceConfigurations[r.hostRef]?.frontendConfiguration?.chartViews?.find(e=>e.ref===r.localRef);if(i)return{identity:r,chartView:i}}function lr(e){let t=[],n=e.resourceConfigurations??{};for(let[e,r]of Object.entries(n))dr(t,e,r?.frontendConfiguration?.chartViews);return t}function ur(e){let t=[];for(let[n,r]of Object.entries(e??{}))dr(t,n,r?.chartViews);return t}function dr(e,t,n){if(n)for(let r of n)e.push({chartDefinitionRef:r.chartDefinition.ref,resourceType:t,chartViewRef:r.ref})}function fr(e,t,n){let r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n&&r.set(`${ir}${e}`,n);for(let[e,t]of Object.entries(n??{}))t&&!e.startsWith(`chart_ctx_`)&&r.set(e,t);let i=r.toString();return i.length>0?`${ar}${e}?${i}`:`${ar}${e}`}function pr(e){let t={};for(let[n,r]of e.entries())n.startsWith(`chart_ctx_`)&&r&&(t[n.slice(10)]=r);return Object.keys(t).length>0?t:void 0}function mr(e){let t={};for(let[n,r]of e.entries())r&&!n.startsWith(`chart_ctx_`)&&n!==`pane`&&(t[n]=r);return Object.keys(t).length>0?t:void 0}var hr;(function(e){e.ACTION_BAR=`action_bar`,e.RECORD_NAVIGATION=`record_navigation`,e.CONTENT_CARD=`content_card`})(hr||={});var gr=H({placement:V(hr).optional(),emphasized:B().optional(),showLabel:B().optional()}),_r={placement:hr.RECORD_NAVIGATION,emphasized:!1,showLabel:!0};function vr(e){return{placement:e?.placement??_r.placement,emphasized:e?.emphasized??_r.emphasized,showLabel:e?.showLabel??_r.showLabel}}var yr;(function(e){e.PARENT_RESOURCE_REQUIREMENT=`parent-resource-requirement`,e.ADDITIONAL_RESOURCE_REQUIREMENT=`additional-resource-requirement`})(yr||={});var br=H({bindingKey:R().min(1),source:V(yr)}),xr;(function(e){e.ANCHOR=`anchor`,e.PARENT_RESOURCE_REQUIREMENT=`parent-resource-requirement`,e.ADDITIONAL_RESOURCE_REQUIREMENT=`additional-resource-requirement`,e.RELATIONSHIP_PROJECTION=`relationship-projection`})(xr||={});var Sr=H({source:z(xr.ANCHOR)}),Cr=H({source:z(xr.PARENT_RESOURCE_REQUIREMENT),bindingKey:R().min(1)}),wr=H({source:z(xr.ADDITIONAL_RESOURCE_REQUIREMENT),bindingKey:R().min(1)}),Tr=H({source:z(xr.RELATIONSHIP_PROJECTION),fromParticipationRef:R().min(1),targetResourceType:a,foreignKeyField:R().min(1).optional()}),Er=Ft(`source`,[Sr,Cr,wr,Tr]),Dr;(function(e){e.EMBED_LOCALLY=`embed-locally`,e.DELEGATE_TO_ROUTER=`delegate-to-router`})(Dr||={});var Or=L([R().min(1),Nt([R().min(1),R().min(1)])]),kr=H({resourceType:a,operation:Or,handlingMode:V(Dr)}),Ar=H({defaultHandlingMode:V(Dr).default(Dr.DELEGATE_TO_ROUTER),operationHandlingExceptions:kr.array().optional()}),jr=Or,Mr=H({scope:z(Wt.RESOURCE),parentResourcesRequirements:i.array().optional(),additionalResourceRequirements:i.array().optional(),ref:R().min(1),isAddressable:B().default(!1),primaryScope:V(I).default(I.ORGANIZATIONS),anchor:br.optional(),navigationPolicy:Ar.optional(),surfaceInOperations:U(jr).optional(),participations:Lt(R(),Er).optional(),viewComponent:Bt(),launcher:gr.optional(),labels:U(Bt()).optional(),requiredFeatures:Le.optional(),icon:Rt().optional(),zoneContentMaxWidth:V(f).optional(),zoneContentFillsHeight:B().optional()}),Nr=`execution_ctx_`;function Pr(e,t){return{...t,viewComponent:e}}function Fr(e){return typeof e==`string`?e:`${e[0]}::${e[1]}`}function Ir(e){let t=new Map;if(!e)return t;let n=Array.isArray(e)?e.map(e=>[e.ref??``,e]):Object.entries(e);for(let[e,r]of n)if(e)for(let n of r.surfaceInOperations??[]){let r=Fr(n),i=t.get(r)??[];t.set(r,[...i,e])}return t}function Lr(e,t){let n=new Map;if(!e)return n;let r=Array.isArray(e)?e.map(e=>[e.ref??``,e]):Object.entries(e);for(let[e,i]of r){if(!e)continue;let r=Fr(i.operationLike??t),a=n.get(r)??[];n.set(r,[...a,e])}return n}function Rr(e){return e?.isAddressable===!0&&e.scope===Wt.RESOURCE}function zr(e,t){return $t({hostKind:qt.RESOURCE,hostRef:e,viewKind:Jt.EXECUTION_VIEW,localRef:t.ref})}function Br(e){let{viewRef:t,registry:n}=e;if(!t)return;let r=en(t);if(r&&r.hostKind===qt.RESOURCE&&r.viewKind===Jt.EXECUTION_VIEW)return n?.resourceConfigurations[r.hostRef]?.frontendConfiguration?.executionViews?.find(e=>e.ref===r.localRef)}function Vr(e){let t=String(e.operationIdentifier);return e.variantKey&&e.isOperationDefault!==!0?[t,e.variantKey]:t}function Hr(e,t){return Array.isArray(e)&&Array.isArray(t)?e[0]===t[0]&&e[1]===t[1]:!Array.isArray(e)&&!Array.isArray(t)&&e===t}function Ur(e){let t=e.viewDefinition.navigationPolicy?.defaultHandlingMode??Dr.DELEGATE_TO_ROUTER,n=Vr(e.operation);return e.viewDefinition.navigationPolicy?.operationHandlingExceptions?.find(t=>t.resourceType===e.resourceType&&Hr(t.operation,n))?.handlingMode??t}function Wr(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t??{}))r&&n.set(`${Nr}${e}`,r);let r=n.toString();return r.length>0?`/execution/${e}?${r}`:`/execution/${e}`}function Gr(e){let t={};for(let[n,r]of e.entries())n.startsWith(`execution_ctx_`)&&r&&(t[n.slice(14)]=r);return Object.keys(t).length>0?t:void 0}var Kr=Object.create(null);Kr.open=`0`,Kr.close=`1`,Kr.ping=`2`,Kr.pong=`3`,Kr.message=`4`,Kr.upgrade=`5`,Kr.noop=`6`;var qr=Object.create(null);Object.keys(Kr).forEach(e=>{qr[Kr[e]]=e});var Jr={type:`error`,data:`parser error`},Yr=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Xr=typeof ArrayBuffer==`function`,Zr=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Qr=({type:e,data:t},n,r)=>Yr&&t instanceof Blob?n?r(t):$r(t,r):Xr&&(t instanceof ArrayBuffer||Zr(t))?n?r(t):$r(new Blob([t]),r):r(Kr[e]+(t||``)),$r=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function ei(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ti;function ni(e,t){if(Yr&&e.data instanceof Blob)return e.data.arrayBuffer().then(ei).then(t);if(Xr&&(e.data instanceof ArrayBuffer||Zr(e.data)))return t(ei(e.data));Qr(e,!1,e=>{ti||=new TextEncoder,t(ti.encode(e))})}var ri=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,ii=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)ii[ri.charCodeAt(e)]=e;var ai=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=ii[e.charCodeAt(r)],o=ii[e.charCodeAt(r+1)],s=ii[e.charCodeAt(r+2)],c=ii[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},oi=typeof ArrayBuffer==`function`,si=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:li(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:ci(e.substring(1),t)}:qr[n]?e.length>1?{type:qr[n],data:e.substring(1)}:{type:qr[n]}:Jr},ci=(e,t)=>oi?li(ai(e),t):{base64:!0,data:e},li=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},ui=``,di=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Qr(e,!1,e=>{r[a]=e,++i===n&&t(r.join(ui))})})},fi=(e,t)=>{let n=e.split(ui),r=[];for(let e=0;e<n.length;e++){let i=si(n[e],t);if(r.push(i),i.type===`error`)break}return r};function pi(){return new TransformStream({transform(e,t){ni(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var mi;function hi(e){return e.reduce((e,t)=>e+t.length,0)}function gi(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function _i(e,t){mi||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(hi(n)<1)break;let e=gi(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(hi(n)<2)break;let e=gi(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(hi(n)<8)break;let e=gi(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Jr);break}i=a*2**32+t.getUint32(4),r=3}else{if(hi(n)<i)break;let e=gi(n,i);s.enqueue(si(a?e:mi.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Jr);break}}}})}function K(e){if(e)return vi(e)}function vi(e){for(var t in K.prototype)e[t]=K.prototype[t];return e}K.prototype.on=K.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},K.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},K.prototype.off=K.prototype.removeListener=K.prototype.removeAllListeners=K.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},K.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},K.prototype.emitReserved=K.prototype.emit,K.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},K.prototype.hasListeners=function(e){return!!this.listeners(e).length};var yi=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),bi=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),xi=`arraybuffer`;function Si(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var Ci=bi.setTimeout,wi=bi.clearTimeout;function Ti(e,t){t.useNativeTimers?(e.setTimeoutFn=Ci.bind(bi),e.clearTimeoutFn=wi.bind(bi)):(e.setTimeoutFn=bi.setTimeout.bind(bi),e.clearTimeoutFn=bi.clearTimeout.bind(bi))}var Ei=1.33;function Di(e){return typeof e==`string`?Oi(e):Math.ceil((e.byteLength||e.size)*Ei)}function Oi(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function ki(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Ai(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function ji(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var Mi=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},Ni=class extends K{constructor(e){super(),this.writable=!1,Ti(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new Mi(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=si(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=Ai(e);return t.length?`?`+t:``}},Pi=class extends Ni{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){fi(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,di(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=ki()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Fi=!1;try{Fi=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Ii=Fi;function Li(){}var Ri=class extends Pi{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},zi=class e extends K{constructor(e,t,n){super(),this.createRequest=e,Ti(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=Si(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(this._xhr!==void 0&&this._xhr!==null){if(this._xhr.onreadystatechange=Li,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(zi.requestsCount=0,zi.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Bi);else if(typeof addEventListener==`function`){let e=`onpagehide`in bi?`pagehide`:`unload`;addEventListener(e,Bi,!1)}}function Bi(){for(let e in zi.requests)zi.requests.hasOwnProperty(e)&&zi.requests[e].abort()}var Vi=(function(){let e=Ui({xdomain:!1});return e&&e.responseType!==null})(),Hi=class extends Ri{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Vi&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new zi(Ui,this.uri(),e)}};function Ui(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Ii))return new XMLHttpRequest}catch{}if(!t)try{return new bi.ActiveXObject(`Microsoft.XMLHTTP`)}catch{}}var Wi=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Gi=class extends Ni{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Wi?{}:Si(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;Qr(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&yi(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=ki()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Ki=bi.WebSocket||bi.MozWebSocket,qi={websocket:class extends Gi{createSocket(e,t,n){return Wi?new Ki(e,t,n):t?new Ki(e,t):new Ki(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends Ni{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=_i(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=pi();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&yi(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Hi},Ji=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Yi=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function Xi(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=Ji.exec(e||``),a={},o=14;for(;o--;)a[Yi[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Zi(a,a.path),a.queryKey=Qi(a,a.query),a}function Zi(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function Qi(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var $i=typeof addEventListener==`function`&&typeof removeEventListener==`function`,ea=[];$i&&addEventListener(`offline`,()=>{ea.forEach(e=>e())},!1);var ta=class e extends K{constructor(e,t){if(super(),this.binaryType=xi,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=Xi(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=Xi(t.host).host);Ti(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=ji(this.opts.query)),$i&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},ea.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data)}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=Di(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,yi(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),$i&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=ea.indexOf(this._offlineEventListener);e!==-1&&ea.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};ta.protocol=4;var na=class extends ta{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;ta.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n){if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;ta.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},ra=class extends na{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>qi[e]).filter(e=>!!e)),super(e,n)}};ra.protocol;function ia(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=Xi(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var aa=typeof ArrayBuffer==`function`,oa=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,sa=Object.prototype.toString,ca=typeof Blob==`function`||typeof Blob<`u`&&sa.call(Blob)===`[object BlobConstructor]`,la=typeof File==`function`||typeof File<`u`&&sa.call(File)===`[object FileConstructor]`;function ua(e){return aa&&(e instanceof ArrayBuffer||oa(e))||ca&&e instanceof Blob||la&&e instanceof File}function da(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(da(e[t]))return!0;return!1}if(ua(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return da(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&da(e[t]))return!0;return!1}function fa(e){let t=[],n=e.data,r=e;return r.data=pa(n,t),r.attachments=t.length,{packet:r,buffers:t}}function pa(e,t,n){if(!e)return e;if(ua(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=pa(e[r],t);return n}if(typeof e==`object`&&!(e instanceof Date)){if(e.toJSON&&typeof e.toJSON==`function`&&!n)return pa(e.toJSON(),t,!0);let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=pa(e[n],t));return r}return e}function ma(e,t){return e.data=ha(e.data,t),delete e.attachments,e}function ha(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=ha(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=ha(e[n],t));return e}var ga=t({Decoder:()=>ya,Encoder:()=>va,PacketType:()=>q,isPacketValid:()=>Ea,protocol:()=>5}),_a=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],q;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(q||={});var va=class{constructor(e){this.replacer=e}encode(e){return(e.type===q.EVENT||e.type===q.ACK)&&da(e)?this.encodeAsBinary({type:e.type===q.EVENT?q.BINARY_EVENT:q.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===q.BINARY_EVENT||e.type===q.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=fa(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},ya=class e extends K{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===q.BINARY_EVENT;n||t.type===q.BINARY_ACK?(t.type=n?q.EVENT:q.ACK,this.reconstructor=new ba(t)):super.emitReserved(`decoded`,t)}else if(ua(e)||e.base64){if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`)}else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(q[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===q.BINARY_EVENT||r.type===q.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!Sa(a)||a<1)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&t.charAt(n)!==`,`&&n!==t.length;);r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case q.CONNECT:return wa(t);case q.DISCONNECT:return t===void 0;case q.CONNECT_ERROR:return typeof t==`string`||wa(t);case q.EVENT:case q.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&_a.indexOf(t[0])===-1);case q.ACK:case q.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},ba=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=ma(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function xa(e){return typeof e==`string`}var Sa=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function Ca(e){return e===void 0||Sa(e)}function wa(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ta(e,t){switch(e){case q.CONNECT:return t===void 0||wa(t);case q.DISCONNECT:return t===void 0;case q.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&_a.indexOf(t[0])===-1);case q.ACK:return Array.isArray(t);case q.CONNECT_ERROR:return typeof t==`string`||wa(t);default:return!1}}function Ea(e){return xa(e.nsp)&&Ca(e.id)&&Ta(e.type,e.data)}function Da(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Oa=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ka=class extends K{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[Da(e,`open`,this.onopen.bind(this)),Da(e,`packet`,this.onpacket.bind(this)),Da(e,`error`,this.onerror.bind(this)),Da(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(Oa.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:q.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];(!t.pending||e)&&(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:q.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case q.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case q.EVENT:case q.BINARY_EVENT:this.onevent(e);break;case q.ACK:case q.BINARY_ACK:this.onack(e);break;case q.DISCONNECT:this.ondisconnect();break;case q.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t)}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:q.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:q.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function Aa(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Aa.prototype.duration=function(){var e=this.ms*this.factor**+this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},Aa.prototype.reset=function(){this.attempts=0},Aa.prototype.setMin=function(e){this.ms=e},Aa.prototype.setMax=function(e){this.max=e},Aa.prototype.setJitter=function(e){this.jitter=e};var ja=class extends K{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,Ti(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new Aa({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||ga;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new ra(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=Da(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=Da(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(Da(e,`ping`,this.onping.bind(this)),Da(e,`data`,this.ondata.bind(this)),Da(e,`error`,this.onerror.bind(this)),Da(e,`close`,this.onclose.bind(this)),Da(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){yi(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new ka(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},Ma={};function Na(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=ia(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=Ma[i]&&a in Ma[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new ja(r,t):(Ma[i]||(Ma[i]=new ja(r,t)),c=Ma[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Na,{Manager:ja,Socket:ka,io:Na,connect:Na});function Pa(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=`${t}${`=`.repeat(n)}`,i=atob(r),a=Uint8Array.from(i,e=>e.charCodeAt(0));return new TextDecoder().decode(a)}function Fa(e){let t=e.split(`.`);if(t.length!==3)throw Error(`JWT must contain exactly three segments`);return JSON.parse(Pa(t[1]))}function Ia(e){if(e)try{let{exp:t}=Fa(e);return typeof t==`number`?t:void 0}catch{return}}function La(e,t){if(!e||!t)return t;let n=Ia(e),r=Ia(t);return n!==void 0&&r!==void 0&&n>r?e:t}var Ra=5,za=5e3,J;(function(e){e.DISCONNECTED=`disconnected`,e.CONNECTING=`connecting`,e.CONNECTED=`connected`,e.ERROR=`error`,e.RECONNECTING=`reconnecting`})(J||={});function Ba(e){return Dt(e)}function Va(e){return e?Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`):``}function Ha(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.roomName!==i.roomName||r.resourceType!==i.resourceType||r.resourceId!==i.resourceId||r.scopeKey!==i.scopeKey||r.scopeId!==i.scopeId||Va(r.contextResourceIdentifiers)!==Va(i.contextResourceIdentifiers))return!1}return!0}function Ua(e,t){return t?e.scopeId===t||Object.values(e.contextResourceIdentifiers).includes(t):!1}function Wa(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ga(e){return e==null?{}:Wa(e)?e:{errorDetails:e}}var Ka=(0,W.createContext)(void 0),qa=We.getLogger(),Ja=({children:e})=>{let[t,n]=(0,W.useState)(J.DISCONNECTED),[r,i]=(0,W.useState)(0),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)([]),l=(0,W.useRef)(null),u=(0,W.useRef)(null),d=(0,W.useRef)({}),f=(0,W.useRef)(null),m=(0,W.useRef)(!1),h=(0,W.useRef)(0),g=(0,W.useRef)(null),_=(0,W.useRef)(!1),v=(0,W.useRef)(0),y=(0,W.useRef)(null),b=(0,W.useRef)(0),x=(0,W.useRef)(0),S=(0,W.useRef)(null),C=(0,W.useRef)(new Map),ee=(0,W.useRef)(new Map),w=(0,W.useRef)(new Map),E=(0,W.useRef)(0),ne=(0,W.useRef)(null),re=(0,W.useRef)(!1),ae=(0,W.useRef)(!1),oe=(0,W.useCallback)(e=>{if(e.resourceId)return ft(e.resourceType,e.resourceId);if(e.scopeKey&&e.scopeId)return T(e.resourceType,e.scopeKey,e.scopeId);throw Error(`Must provide either resourceId or both scopeKey and scopeId`)},[]),D=(0,W.useCallback)(()=>{let e=Array.from(C.current.values(),e=>({roomName:e.roomName,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers}));c(t=>Ha(t,e)?t:e)},[]),se=(0,W.useCallback)((e,t)=>{let n=w.current.get(e)??new Map;w.current.set(e,n);let r=n.get(t);if(r)return r;let i=n=>{if(e in Se){let r=Te(e,n);if(`data`in r){t(r.data);return}console.warn(`Dropped invalid websocket payload at client ingress boundary`,{event:e,issues:r.error.issues})}else t(n)};return n.set(t,i),i},[]),ce=(0,W.useCallback)(e=>{for(let[t,n]of ee.current.entries())for(let r of n)e.on(t,se(t,r))},[se]),le=(0,W.useCallback)(e=>JSON.stringify({url:e.url,token:e.token??null,organizationId:e.organizationId??null,consumableToken:e.consumableToken??null}),[]),O=(0,W.useCallback)(e=>e.replace(/^ws/,`http`),[]),k=(0,W.useCallback)(async e=>{let t=`${O(e)}/health/ready`,n=Date.now(),r=0;for(console.log(`WebSocket: Waiting for API readiness...`,{healthUrl:t});;){try{let e=await jt.get(t,{timeout:5e3,validateStatus:()=>!0});if(e.status===200&&e.data?.status===`healthy`)return console.log(`WebSocket: API is ready`,{healthUrl:t,attempts:r+1}),!0}catch{}let e=Date.now()-n;if(e>=3e4)return console.warn(`WebSocket: API readiness check timed out, proceeding with connection anyway`,{healthUrl:t,elapsedMs:e,attempts:r+1}),!1;let i=wt(r,100,1e4);console.warn(`WebSocket: API not ready (attempt ${r+1}), retrying in ${i}ms...`,{healthUrl:t,elapsedMs:e}),await new Promise(e=>setTimeout(e,i)),r++}},[O]),ue=(0,W.useCallback)(e=>{f.current&&!m.current&&(h.current>=Ra?console.warn(`WebSocket: Suppressing token renewal (${e}) — a freshly-minted token was rejected ${h.current}× in a row; not looping the refresh endpoint`):(console.log(`WebSocket: Requesting token renewal (${e})`),m.current=!0,h.current+=1,Promise.resolve(f.current()).catch(()=>{h.current=Math.max(0,h.current-1)}).finally(()=>{m.current=!1})))},[]),de=(0,W.useCallback)(e=>{let t={auth:e=>{let{token:t,consumableToken:n,organizationId:r}=d.current,i=nt();e({...t?{token:t}:{},...n?{consumableToken:n}:{},...r?{organizationId:r}:{},...i?{clientInstanceId:i}:{},frontendServiceName:Ce.loadEnvironmentConfig().frontendServiceName})},transports:[`polling`,`websocket`],reconnection:e.autoReconnect??!0,reconnectionDelay:e.reconnectInterval??1e3,reconnectionDelayMax:3e4,randomizationFactor:.5,reconnectionAttempts:e.maxReconnectAttempts??15,timeout:3e4,forceNew:!0,upgradeTimeout:1e4};e.consumableToken&&(t.extraHeaders={[Xe.CONSUMABLE_TOKEN]:e.consumableToken});let r=Na(e.url,t);l.current=r,ce(r);let a=e=>{ae.current||(ae.current=!0,qa.warn(`WebSocket connectivity lost`,{source:`websocket`,reason:e}))};r.on(`connect`,()=>{re.current=!1,n(J.CONNECTED),i(e=>e+1),o(null),b.current=0,x.current=0,m.current=!1,h.current=0,S.current=new Date,ae.current&&=(qa.info(`WebSocket connectivity restored`,{source:`websocket`}),!1),console.log(`Socket.IO connected`);for(let e of C.current.values())r.emit(j.RESOURCE_SUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers})}),r.on(`disconnect`,e=>{re.current=!1,n(J.DISCONNECTED),console.log(`Socket.IO disconnected:`,e);let t=_.current;if(_.current=!1,e===`io server disconnect`&&t){let e=Date.now();e-v.current>=za&&(v.current=e,console.log(`WebSocket: Reconnecting so the server can re-derive this connection's authority`),r.connect())}else e!==`io client disconnect`&&a(e)}),r.on(j.SYSTEM_TOKEN_REFRESHED,()=>{console.log(`WebSocket: Server accepted refreshed socket auth token`),h.current=0}),r.on(j.SYSTEM_ERROR,e=>{if(e?.code===te.AUTH_REFRESH_FAILED)console.warn(`WebSocket: Server rejected refreshed socket auth token`,e),ue(`live refresh rejected`);else if(e?.code===te.AUTHORITY_REEVALUATION_REQUIRED)_.current=!0;else if(e?.code===te.ORGANIZATION_SWITCH_FORBIDDEN){let t=d.current.organizationId;t&&g.current!==t&&(g.current=t,console.warn(`WebSocket: Organization switch refused; re-handshaking into the intended organization`,e),r.disconnect(),r.connect())}else if(e?.code===te.RATE_LIMIT_EXCEEDED){let t=e.message||`Too many real-time requests. Please slow down.`,n=Ga(e.details);console.warn(`WebSocket: Rate limit exceeded`,e),o(t),p.handleError(Error(t),{source:`websocket`,riskLevel:qe.MEDIUM,additionalContext:{...n,errorCode:e.code}})}}),r.on(`connect_error`,e=>{re.current=!1,console.error(`Socket.IO connection error:`,e.message),o(e.message),(e.data?.code===ie.AUTHENTICATION_FAILED||e.message===`Authentication failed`)&&ue(`handshake rejected`),n(b.current>0?J.RECONNECTING:J.ERROR),a(`connect_error:${e.type??e.message}`)}),r.io.on(`reconnect_attempt`,e=>{b.current=e,n(J.RECONNECTING),console.log(`Socket.IO reconnection attempt ${e}`)}),r.io.on(`reconnect`,e=>{console.log(`Socket.IO reconnected after ${e} attempts`),n(J.CONNECTED),o(null),b.current=0,x.current=0}),r.io.on(`reconnect_failed`,()=>{console.error(`Socket.IO reconnection failed`),o(`Failed to reconnect after maximum attempts`),n(J.ERROR),qa.warn(`WebSocket reconnection gave up after maximum attempts`,{source:`websocket`,reconnectAttempts:b.current})})},[ce,ue]),fe=(0,W.useCallback)(async(e,t,n)=>{await k(e.url),E.current!==t||ne.current!==n?console.log(`WebSocket: Skipping stale connect attempt after readiness check`):de(e)},[k,de]),A=(0,W.useCallback)(e=>{if(!e.url){o(`WebSocket URL is not available`),n(J.ERROR),console.error(`WebSocket: Cannot connect - URL is required`);return}let r=le(e);if(ne.current===r&&(re.current||t===J.CONNECTING||t===J.CONNECTED||t===J.RECONNECTING)){console.log(`WebSocket: Reusing active connect lifecycle for identical config`);return}l.current&&=(l.current.connected&&console.log(`Disconnecting existing WebSocket connection before reconnecting`),l.current.disconnect(),l.current.removeAllListeners(),null),E.current+=1,ne.current=r,re.current=!0,u.current=e,f.current=e.onAuthenticationError??null;let i=La(d.current.token,e.token);i!==e.token&&console.log(`WebSocket: Keeping already-stored fresher access token over the staler connect config token`),d.current={token:i,consumableToken:e.consumableToken,organizationId:e.organizationId},n(J.CONNECTING),o(null),fe(e,E.current,r).catch(e=>{console.error(`WebSocket: Connection setup failed`,e),o(`WebSocket connection setup failed`),n(J.ERROR)})},[le,fe,t]),pe=(0,W.useCallback)(()=>{E.current+=1,ne.current=null,re.current=!1,b.current=0,ae.current=!1,y.current&&=(clearTimeout(y.current),null),l.current&&=(l.current.removeAllListeners(),l.current.disconnect(),null),n(J.DISCONNECTED),C.current.clear(),c([]),S.current=null,d.current={},f.current=null,m.current=!1,h.current=0},[]),me=(0,W.useCallback)(e=>{d.current={...d.current,token:e},u.current&&={...u.current,token:e};let t=l.current;t?.connected?(console.log(`WebSocket: Refreshing socket auth with renewed access token`),t.emit(j.AUTH_REFRESH,{token:e})):t&&!t.active?(console.log(`WebSocket: Reviving idle socket to reconnect with renewed access token`),t.connect()):console.log(`WebSocket: Stored renewed access token for next socket handshake`)},[]),he=(0,W.useCallback)(()=>{if(!ne.current)return;let e=l.current;e?e.connected||e.active||(b.current=0,console.log(`WebSocket: Reviving dead socket after connectivity signal`),e.connect()):u.current&&A(u.current)},[A]),ge=(0,W.useRef)(he);ge.current=he,(0,W.useEffect)(()=>{let e=()=>ge.current(),t=()=>{document.visibilityState===`visible`&&ge.current()};window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t);let n=15e3,r=null,i=e=>{r=setTimeout(a,e)};function a(){let e=l.current;if(!ne.current||e?.connected||e?.active){x.current=0,i(n);return}ge.current();let t=Math.max(500,wt(x.current,2e3,3e4));x.current+=1,i(t)}return i(n),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t),r&&clearTimeout(r)}},[]);let _e=(0,W.useCallback)((e,t)=>{let n=t,r=ee.current.get(e)??new Set,i=r.has(n);return r.add(n),ee.current.set(e,r),!i&&l.current&&l.current.on(e,se(e,n)),()=>{ee.current.get(e)?.delete(n),ee.current.get(e)?.size===0&&ee.current.delete(e);let t=w.current.get(e)?.get(n);t&&(l.current?.off(e,t),w.current.get(e)?.delete(n)),w.current.get(e)?.size===0&&w.current.delete(e)}},[se]),ve=(0,W.useCallback)((e,t)=>{ee.current.get(e)?.delete(t),ee.current.get(e)?.size===0&&ee.current.delete(e);let n=w.current.get(e)?.get(t);n&&(l.current?.off(e,n),w.current.get(e)?.delete(t)),w.current.get(e)?.size===0&&w.current.delete(e)},[]),ye=(0,W.useCallback)((e,t)=>{l.current?.connected?l.current.emit(e,t):console.warn(`Cannot emit: not connected`)},[]),be=(0,W.useCallback)(async e=>l.current?.connected?new Promise(t=>{let n=oe(e),r=!1;l.current.emit(j.RESOURCE_SUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.contextResourceIdentifiers});let i=e=>{e.roomName===n&&!r&&(r=!0,l.current.off(j.RESOURCE_SUBSCRIBED,i),t({success:e.success,editingUsers:e.editingUsers}))};l.current.on(j.RESOURCE_SUBSCRIBED,i),setTimeout(()=>{r||(r=!0,l.current?.off(j.RESOURCE_SUBSCRIBED,i),t({success:!1}))},1e4)}):(console.warn(`Cannot subscribe: not connected`),{success:!1}),[oe]),xe=(0,W.useCallback)(async e=>{let t=oe(e),n=Ba(e.contextResourceIdentifiers),r=C.current.get(t);if(r){let t=r.ownerKeys.has(e.ownerKey),i=r.ownerContexts.get(e.ownerKey),a=r.contextResourceIdentifiers,o=Va(a)===Va(n);if(t&&o&&l.current?.connected)return r.ownerContexts.set(e.ownerKey,n),{success:!0,editingUsers:r.editingUsers};if(r.ownerKeys.add(e.ownerKey),r.ownerContexts.set(e.ownerKey,n),r.contextResourceIdentifiers=n,l.current?.connected){let o=await be({resourceType:r.resourceType,resourceId:r.resourceId,scopeKey:r.scopeKey,scopeId:r.scopeId,contextResourceIdentifiers:n});return o.success?(r.editingUsers=o.editingUsers,D(),{success:!0,editingUsers:r.editingUsers}):(t&&i?r.ownerContexts.set(e.ownerKey,i):(r.ownerKeys.delete(e.ownerKey),r.ownerContexts.delete(e.ownerKey)),r.contextResourceIdentifiers=a,D(),o)}return D(),{success:!0,editingUsers:r.editingUsers}}if(!l.current?.connected)return C.current.set(t,{roomName:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n,ownerKeys:new Set([e.ownerKey]),ownerContexts:new Map([[e.ownerKey,n]])}),D(),{success:!1};let i=await be({...e,contextResourceIdentifiers:n});return i.success&&(C.current.set(t,{roomName:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n,ownerKeys:new Set([e.ownerKey]),ownerContexts:new Map([[e.ownerKey,n]]),editingUsers:i.editingUsers}),D()),i},[oe,be,D]),M=(0,W.useCallback)(async e=>{let t=oe(e);return xe({...e,ownerKey:`legacy:${t}`})},[oe,xe]),we=(0,W.useCallback)(async e=>{let t=oe(e),n=Ba(e.contextResourceIdentifiers),r=C.current.get(t);if(r){if(r.ownerKeys.delete(e.ownerKey),r.ownerContexts.delete(e.ownerKey),r.ownerKeys.size>0){let e=r.ownerContexts.values().next().value;if(e&&(r.contextResourceIdentifiers=e,l.current?.connected)){let t=await be({resourceType:r.resourceType,resourceId:r.resourceId,scopeKey:r.scopeKey,scopeId:r.scopeId,contextResourceIdentifiers:e});t.success&&(r.editingUsers=t.editingUsers)}D()}else C.current.delete(t),D(),l.current?.connected&&l.current.emit(j.RESOURCE_UNSUBSCRIBE,{resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:n})}},[oe,D]),Ee=(0,W.useCallback)(async e=>{let t=oe(e);await we({...e,ownerKey:`legacy:${t}`})},[oe,we]),De=(0,W.useCallback)((e,t)=>{d.current={...d.current,organizationId:e},u.current&&={...u.current,organizationId:e},g.current=null;let n=()=>{if(!t)return;let e=Array.from(C.current.values()).filter(e=>Ua(e,t)).flatMap(e=>Array.from(e.ownerKeys).map(t=>({ownerKey:t,resourceType:e.resourceType,resourceId:e.resourceId,scopeKey:e.scopeKey,scopeId:e.scopeId,contextResourceIdentifiers:e.ownerContexts.get(t)??e.contextResourceIdentifiers})));Promise.all(e.map(e=>we(e)))};l.current?.connected?(l.current.emit(j.ORGANIZATION_SWITCH,{organizationId:e,previousOrganizationId:t}),n()):(console.warn(`Organization switch recorded while not connected; the next handshake will carry it`),n())},[we]),Oe=(0,W.useCallback)(async e=>l.current?.connected?new Promise(t=>{let n=!1;l.current.emit(j.RESOURCE_EDITING_START,{resourceType:e.resourceType,resourceId:e.resourceId,contextResourceIdentifiers:Ba(e.contextResourceIdentifiers),timestamp:new Date});let r=i=>{i.resourceType===e.resourceType&&i.resourceId===e.resourceId&&!n&&(n=!0,l.current.off(j.RESOURCE_EDITING_STARTED,r),l.current.off(j.RESOURCE_EDITING_ERROR,r),t(i.success))};l.current.on(j.RESOURCE_EDITING_STARTED,r),l.current.on(j.RESOURCE_EDITING_ERROR,r),setTimeout(()=>{n||(n=!0,l.current?.off(j.RESOURCE_EDITING_STARTED,r),l.current?.off(j.RESOURCE_EDITING_ERROR,r),t(!1))},1e4)}):(console.warn(`Cannot start editing: not connected`),!1),[]),ke=(0,W.useCallback)(e=>{l.current?.connected&&l.current.emit(j.RESOURCE_EDITING_END,{resourceType:e.resourceType,resourceId:e.resourceId,timestamp:new Date})},[]),Ae=(0,W.useCallback)(e=>{l.current?.connected?l.current.emit(j.RESOURCE_CUSTOM,{resourceType:e.resourceType,resourceId:e.resourceId,eventName:e.eventName,data:e.data,contextResourceIdentifiers:Ba(e.contextResourceIdentifiers),includeSelf:e.includeSelf,timestamp:new Date}):console.warn(`Cannot send custom event: not connected`)},[]),je=(0,W.useCallback)(async(e,t,n)=>l.current?.connected?new Promise(r=>{let i=!1,a=setTimeout(()=>{i||(i=!0,r(0))},5e3);l.current.emit(j.BADGE_GET,{identifier:e,scope:t,scopeId:n},e=>{i||(i=!0,clearTimeout(a),r(e?.count??0))})}):0,[]),Me=(0,W.useCallback)(async(e,t)=>l.current?.connected?new Promise(n=>{let r=!1,i=setTimeout(()=>{r||(r=!0,n([]))},5e3);l.current.emit(j.BADGE_GET_ALL,{scope:e,scopeId:t},e=>{r||(r=!0,clearTimeout(i),n(e??[]))})}):[],[]),Ne=(0,W.useCallback)(()=>({status:t,url:u.current?.url||null,connectedAt:S.current}),[t]);(0,W.useEffect)(()=>()=>{pe()},[pe]);let Pe=(0,W.useMemo)(()=>({status:t,connectionCount:r,isConnected:t===J.CONNECTED,error:a,subscribedRooms:s,connect:A,disconnect:pe,refreshAuth:me,switchOrganization:De,on:_e,off:ve,emit:ye,subscribeToResource:M,claimResourceRoom:xe,unsubscribeFromResource:Ee,releaseResourceRoom:we,startEditing:Oe,stopEditing:ke,sendCustomEvent:Ae,getBadge:je,getAllBadges:Me,getConnectionInfo:Ne}),[t,r,a,s,A,pe,me,De,_e,ve,ye,M,xe,Ee,we,Oe,ke,Ae,je,Me,Ne]);return(0,G.jsx)(Ka.Provider,{value:Pe,children:e})},Ya;(function(e){e.NOT_A_SUMMARY_FIELD=`not_a_summary_field`,e.BACKEND_ONLY=`backend_only`})(Ya||={});var Xa=class{static objectContextCache=new Map;static getObjectContextCacheKey(e,t){return`${e}|${Object.entries(t).map(([e,t])=>`${e}:${t.parentType}:${t.parentId}`).sort().join(`|`)}`}static async fetchObjectContextForOperation(e,t,n,r,i){if(!Ut(e).needsObjectContext){let e={};for(let[t,r]of Object.entries(n))e[t]={_id:r.parentId};return{parents:e,children:{}}}if(!i){console.warn(`[OperationEnabledConditionUtils.fetchObjectContextForOperation] needsObjectContext is true but doOperation not provided. Returning IDs only.`);let e={};for(let[t,r]of Object.entries(n))e[t]={_id:r.parentId};return{parents:e,children:{}}}let a=this.getObjectContextCacheKey(t,n),o=this.objectContextCache.get(a);if(o)return o;let s=(async()=>{let e={},t={};for(let[e,i]of Object.entries(n))if(e===i.parentType){let e=r.allResourceFieldIdentifiers?.[i.parentType];e&&(t[e]=i.parentId)}else t[e]=i.parentId;for(let[a,o]of Object.entries(n)){let{parentType:n,parentId:s}=o;try{let o=r.resourceConfigurations[n];if(!o){e[a]={_id:s};continue}let c=o.operations?.find(e=>e.operationIdentifier===M.READ);if(!c){e[a]={_id:s};continue}let l=dt.createOperationPathKey({resourceIdentifier:n,operationIdentifier:M.READ,variantType:je.API_CALL,isOperationDefault:c.isOperationDefault??!0,isBulkOperation:!1}),u=r.allResourceFieldIdentifiers?.[n];e[a]=await i(l,{contextualParameters:{...t,...u?{[u]:String(s)}:{}}})}catch(t){console.warn(`[OperationEnabledConditionUtils.fetchObjectContextForOperation] Failed to fetch parent ${n}:${s}`,t),e[a]={_id:s}}}return{parents:e,children:{}}})();return this.objectContextCache.set(a,s),setTimeout(()=>{this.objectContextCache.delete(a)},6e4),s}static async evaluateEnabledCondition(e){let{operation:t,currentObject:n,inputDto:r,userContext:i,initiatorIds:a,objectContext:o,resourcesRegistry:s,resourceType:c,doOperation:l,subjectDataMode:u}=e;if(!(`enabledCondition`in t)||!t.enabledCondition)return!0;let d=Ht(t.enabledCondition),f=o;if(d.needsObjectContext&&!f&&n){let e=s.resourceConfigurations[c],r={};if(e){let t=e.resourceRelationships?Ct(e.resourceRelationships):[];for(let e of t){if(e.resourceType1===e.resourceType2&&!e.foreignKeyField)continue;let t=e.resourceType2===c?e.resourceType1:e.resourceType2,i=E.tryResolveRelationshipForeignKeyIdentity(e,s.allResourceFieldIdentifiers)?.fieldIdentifier;if(!i){let n=_.buildConfigurationError(fe.FRONTEND_RESOURCE_FIELD_IDENTIFIER_NOT_FOUND,{resourceType:c,parentType:t,relationship:`${e.resourceType1} → ${e.resourceType2}`,component:`operation-enabled-condition`});console.error(n.message,n.wildoError);continue}let a=n?.[i];if(a){let n=e.foreignKeyField??t;r[n]={parentType:t,parentId:String(a)}}}}f=await this.fetchObjectContextForOperation(t,c,r,s,l)}let p=u===w.SUMMARY&&n&&!r?this.recordSummaryUnreachableReads(t,s,c,n):void 0,m=p?.subject??n,h={inputDto:r||m||{},currentObject:m||r||{},objectContext:f||{},initiatorUserContext:i,initiatorIds:a??(i?{userId:i._id}:void 0)};try{return t.enabledCondition(h)===!0}catch(e){return console.warn(`Failed to evaluate enabledCondition`,{resourceType:c,operationIdentifier:t.operationIdentifier,error:e instanceof Error?e.message:`Unknown error`}),!1}finally{p?.report()}}static reportedSummaryUnreachableReads=new Set;static recordSummaryUnreachableReads(e,t,n,r){let i=!1;try{i=Ce.isDevelopment()}catch{}if(!i||typeof r!=`object`||Object.keys(r).length===0)return;let a=this.summaryUnreachableFieldNames(e,t.resourceConfigurations[n]);if(!a||a.size===0)return;let o=new Set,s=e=>{typeof e==`string`&&a.has(e)&&o.add(e)};return{subject:new Proxy(r,{get:(e,t,n)=>(s(t),Reflect.get(e,t,n)),has:(e,t)=>(s(t),Reflect.has(e,t))}),report:()=>{for(let t of o){let r=`${String(n)}::${String(e.operationIdentifier)}::${t}`;if(this.reportedSummaryUnreachableReads.has(r))continue;this.reportedSummaryUnreachableReads.add(r);let i=`[Wildo] The enabledCondition of "${String(n)}.${String(e.operationIdentifier)}" reads "${t}"`;console.warn(a.get(t)===Ya.BACKEND_ONLY?`${i}, which is .isBackendOnly() and reaches no frontend row, so the interface always judges the condition with it undefined. No declaration brings it to the interface: only the server can decide on it, so the condition the interface evaluates should not depend on it.`:`${i}, which a SUMMARY row does not carry, so on a list the condition sees it undefined on every row. Add "${t}" to the operation's enabledConditionFields so list rows carry it, or declare it .isSummaryField() if the list should also show it.`)}}}}static summaryUnreachableFieldNames(e,t){let n=e.summaryDto;if(!n)return;let r=oe.getObjectLikeFieldShape(n,{commonOnly:!1}),i=_.resolveFieldShapeOfAnyVariant(t);if(!r||!i||Object.keys(r).length===0)return;let a=new Map;for(let[e,t]of Object.entries(i))e in r||a.set(e,ne(t)?Ya.BACKEND_ONLY:Ya.NOT_A_SUMMARY_FIELD);return a}static getOperationContextNeeds(e){let t=Ut(e);return{needsObjectContext:t.needsObjectContext===!0,needsUserContext:t.needsUserContext===!0}}static operationNeedsObjectContext(e){return this.getOperationContextNeeds(e).needsObjectContext}static operationNeedsUserContext(e){return this.getOperationContextNeeds(e).needsUserContext}},Za=Xa.evaluateEnabledCondition.bind(Xa);Xa.fetchObjectContextForOperation.bind(Xa);var Qa=Xa.getOperationContextNeeds.bind(Xa);Xa.operationNeedsObjectContext.bind(Xa),Xa.operationNeedsUserContext.bind(Xa);var $a=(0,W.createContext)(void 0),eo=({children:e,resourcesRepository:t})=>{let n=t.getResourcesRegistry(),r=t.getResourcesHttpClient(),i=t.getApplicationHttpClient();(0,W.useEffect)(()=>{if(Ce.isDevelopment())try{let e=be(n.resourceConfigurations);for(let t of e){let e=t.severity===b.FAIL?`FAIL`:`WARN`;console.warn(`[required-fk-fillability:${e}] ${t.kind}: ${t.message}`)}}catch{}},[n]);let a=(0,W.useContext)(tt)?.requestKeys,o=(0,W.useMemo)(()=>_.collectInstanceLabelSectionKeys(n),[n]);(0,W.useEffect)(()=>{a&&o.length!==0&&a(o).catch(()=>void 0)},[a,o]);let s=(0,W.useCallback)(async(e,t,n)=>{let i=typeof e==`string`?e:dt.createOperationPathKey(e),a=r.getOperationDetails(i);return(a?lt(a)===M.SEARCH:dt.parseOperationPathKey(i).operationIdentifier===M.SEARCH)?r.executeSearchOperation(i,t,n):r.doOperation(i,t,n)},[r]),c=(0,W.useCallback)(async e=>Xa.evaluateEnabledCondition({...e,resourcesRegistry:n,doOperation:s}),[n,s]),l=(0,W.useCallback)(e=>Xa.getOperationContextNeeds(e),[]),u=(0,W.useCallback)(e=>e in n.resourceConfigurations,[n]),d=(0,W.useCallback)(e=>n.resourceConfigurations[e],[n]),f=(0,W.useCallback)(()=>n,[n]),p=(0,W.useCallback)(()=>Object.keys(n.resourceConfigurations),[n]),m=(0,W.useCallback)(()=>r.getAvailableOperationPaths(),[r]),h=(0,W.useCallback)(e=>{e?(r.setAuthToken(e),i.setAuthToken(e)):(r.clearAuthToken(),i.clearAuthToken())},[r,i]),g=(0,W.useCallback)(e=>{r.setTokenRenewalHandler(e),i.setTokenRenewalHandler(e)},[r,i]),v=(0,W.useCallback)(e=>{r.setStepUpAuthHandler(e),i.setStepUpAuthHandler(e)},[r,i]),y=(0,W.useCallback)(e=>{r.setConsumableToken(e),i.setConsumableToken(e)},[r,i]),x=(0,W.useCallback)(()=>r.getReadCache(),[r]),S=(0,W.useMemo)(()=>({registry:n,doOperation:s,evaluateOperationEnabled:c,getOperationContextNeeds:l,hasResource:u,getResourceConfiguration:d,getResourcesRegistry:f,getAvailableResourceTypes:p,getAvailableOperationPaths:m,getReadCache:x,setAuthToken:h,setTokenRenewalHandler:g,setStepUpAuthHandler:v,setConsumableToken:y}),[n,s,c,l,u,d,f,p,m,x,h,g,v,y]);return(0,G.jsx)($a.Provider,{value:S,children:e})},to=()=>{let e=(0,W.useContext)($a);if(!e)throw Error(`useResourceRegistry must be used within a ResourceRegistryProvider`);return e},no=()=>(0,W.useContext)($a);function ro(e,t){return e===void 0||e.hasResource(t)}var io=e=>ro(no(),e),ao=()=>{let e=(0,W.useContext)(kt);if(!e)throw Error(`useError must be used within an ErrorProvider`);return e};function oo(e,t){return e===t}function so(e){return e.tComponent(e.componentType,e.key,e.params)}function co(e){let t=e.tComponent(e.componentType,e.key,e.params);return oo(t,`components.${e.componentType}.${e.key}`)?void 0:t}function lo(e,t){return(n,r)=>so({tComponent:e,componentType:t,key:n,params:r})}function uo(e){return e.tResourceHeader(e.resourceType,e.key,e.params)}function fo(e){let t=e.tResourceHeader(e.resourceType,`description`,e.params);return oo(t,`resources.${e.resourceType}.header.description`)?void 0:t}function po(e){return e.t(e.key,e.params)}function mo(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function ho(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function go(){return _o.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var _o={stubThis:e=>e};function vo(e){let{id:t}=e;return{...e,id:ho(t),transports:e.transports}}function yo(e){return e===`localhost`||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}var Y=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function bo({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Y({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new Y({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new Y({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new Y({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new Y({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new Y({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new Y({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new Y({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!yo(t))return new Y({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new Y({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new Y({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new Y({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var xo=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},So=[`cross-platform`,`platform`];function Co(e){if(e&&!(So.indexOf(e)<0))return e}async function wo(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!go())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:ho(t.challenge),user:{...t.user,id:ho(t.user.id)},excludeCredentials:t.excludeCredentials?.map(vo)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=xo.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw bo({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){To(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=mo(e))}catch(e){To(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=mo(c.getAuthenticatorData())}catch(e){To(`getAuthenticatorData()`,e)}return{id:o,rawId:mo(s),response:{attestationObject:mo(c.attestationObject),clientDataJSON:mo(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:Co(a.authenticatorAttachment)}}function To(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Eo(){if(!go())return Do.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?Do.stubThis(new Promise(e=>e(!1))):Do.stubThis(e.isConditionalMediationAvailable())}var Do={stubThis:e=>e};function Oo({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new Y({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new Y({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!yo(t))return new Y({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new Y({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new Y({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ko(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!go())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(vo));let a={...t,challenge:ho(t.challenge),allowCredentials:i},o={};if(n){if(!await Eo())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=xo.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw Oo({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=mo(u.userHandle)),{id:c,rawId:mo(l),response:{authenticatorData:mo(u.authenticatorData),clientDataJSON:mo(u.clientDataJSON),signature:mo(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:Co(s.authenticatorAttachment)}}function Ao(e){return!e||e.accessToken||!e.sessionId?null:e.nextStep===Qe.ONBOARDING||e.state===de.ONBOARDING_PENDING?e.sessionId:null}function jo(e,t){return!e.onboardingSessionId||e.accessToken?null:A(ee.organizationOnboarding,t)}function Mo(e){return e?.wildoError?.customMessageReference===fe.AUTHENTICATION_SESSION_EXPIRED}var No;(function(e){e.SIGNED_IN=`signed_in`,e.MFA_ENROLLMENT_REQUIRED=`mfa_enrollment_required`,e.EMAIL_VERIFICATION_PENDING=`email_verification_pending`,e.SSO_REDIRECT_REQUIRED=`sso_redirect_required`,e.MAGIC_LINK_SENT=`magic_link_sent`,e.PASSKEY_ENROLLMENT_PENDING=`passkey_enrollment_pending`,e.ORGANIZATION_ONBOARDING_REQUIRED=`organization_onboarding_required`,e.UNFINISHED=`unfinished`})(No||={});var Po=new Set([de.COMPLETED,de.MFA_ENROLLMENT_GRACE]);function Fo(e){return e.accessToken&&e.state!==void 0&&Po.has(e.state)?No.SIGNED_IN:e.ssoRedirectHint===!0?No.SSO_REDIRECT_REQUIRED:e.state===de.MFA_ENROLLMENT_REQUIRED?e.sessionId?No.MFA_ENROLLMENT_REQUIRED:No.UNFINISHED:Ao(e)?No.ORGANIZATION_ONBOARDING_REQUIRED:e.nextStep===Qe.MAGIC_LINK_SENT?No.MAGIC_LINK_SENT:e.nextStep===Qe.PASSKEY_ENROLLMENT?No.PASSKEY_ENROLLMENT_PENDING:e.state===void 0&&e.nextStep===void 0&&e.sessionId===void 0&&!e.accessToken?No.EMAIL_VERIFICATION_PENDING:No.UNFINISHED}function Io(){try{return globalThis.sessionStorage??void 0}catch{return}}function Lo(e){try{let t=e.getItem(it.PENDING_MFA_SESSION);if(!t)return null;let n=JSON.parse(t);return!n||typeof n.sessionId!=`string`||!n.sessionId||typeof n.email!=`string`||typeof n.rememberedAt!=`number`?null:{sessionId:n.sessionId,email:n.email,rememberedAt:n.rememberedAt}}catch{return null}}function Ro(e,t=Date.now()){let n=Io();if(!n)return;let r=Lo(n),i=r?.sessionId===e.sessionId,a={sessionId:e.sessionId,email:e.email||(i?r.email:``),rememberedAt:i?r.rememberedAt:t};try{n.setItem(it.PENDING_MFA_SESSION,JSON.stringify(a))}catch{}}function zo(e=Date.now()){let t=Io();if(!t)return null;let n=Lo(t);return!n||e-n.rememberedAt>18e5||n.rememberedAt>e?(Bo(),null):{sessionId:n.sessionId,email:n.email}}function Bo(){try{Io()?.removeItem(it.PENDING_MFA_SESSION)}catch{}}var X;(function(e){e.SURFACE=`SURFACE`,e.REFERENCE=`REFERENCE`})(X||={});var Vo={[l.NETWORK]:X.REFERENCE,[l.AUTHENTICATION]:X.SURFACE,[l.AUTHORIZATION]:X.REFERENCE,[l.VALIDATION]:X.SURFACE,[l.PAYLOAD_TOO_LARGE]:X.REFERENCE,[l.NOT_FOUND]:X.SURFACE,[l.CONFLICT]:X.REFERENCE,[l.RATE_LIMIT]:X.REFERENCE,[l.INTERNAL]:X.SURFACE,[l.DATABASE]:X.SURFACE,[l.EXTERNAL_SERVICE]:X.REFERENCE,[l.UNKNOWN]:X.SURFACE,[l.UNCAUGHT_EXCEPTION]:X.SURFACE,[l.UNHANDLED_REJECTION]:X.SURFACE,[l.BUSINESS_RULE]:X.SURFACE,[l.INFRASTRUCTURE]:X.SURFACE,[l.CONFIGURATION]:X.SURFACE,[l.FEATURE_NOT_AVAILABLE]:X.REFERENCE,[l.FEATURE_LIMIT_EXCEEDED]:X.REFERENCE,[l.INSUFFICIENT_CREDITS]:X.REFERENCE},Ho=(()=>{let e=new Map;for(let t of Object.values(he)){let n=t.defaultCustomMessageReference;e.set(n,[...e.get(n)??[],t.type])}return e})(),Uo=new Set(Object.values(l));function Wo(e,t){if(!t)return;let n=e(t);if(n&&!n.endsWith(`.${t}.msg`))return n}function Go(e,t,n){let r=`${ye.RESOURCES}.${t}.operations.${n}.${Be.UNAVAILABLE_REASON}`,i=e(t,n,Be.UNAVAILABLE_REASON);return i&&i!==r?i:void 0}function Ko(e){let{tErrorMessage:t,tResourceOperation:n,resourceType:r,operationIdentifier:i,customMessageReference:a}=e;if(a===fe.SERVICE_RESOURCE_OPERATION_DISABLED&&r&&i){let e=Go(n,r,i);if(e)return e}return Wo(t,a)}function qo(e,t){if(!t)return;let n=Wo(e.tErrorMessage,t);if(n)return n;let r=`${ye.ERRORS_REFUSALS}.${t}.msg`,i=e.t(r);return i&&i!==r?i:void 0}function Jo(e){return typeof e==`object`&&e?e:void 0}function Yo(e){return typeof e==`string`&&e.trim().length>0?e:void 0}function Xo(e){let t=Jo(e);if(!t)return{};let n=Jo(t.wildoError),r=Jo(Jo(Jo(t.response)?.data)?.error);return{errorType:[n?.type,t.type,t.errorType,r?.type].find(e=>typeof e==`string`&&Uo.has(e)),customMessageReference:Yo(n?.customMessageReference)??Yo(t.customMessageReference)??Yo(r?.customMessageReference)??Yo(r?.code),userGuidance:Jo(n?.userGuidance)??Jo(t.userGuidance)??Jo(r?.userGuidance)}}var Zo=[`explanation`,`resolution`];function Qo(e,t){let n=e.userGuidance,r=n?.guidanceKey??e.customMessageReference;if(n&&r)for(let e of Zo){let i=t.tErrorGuidance(r,e,n.params);if(i)return i}}function $o(e){let t=e.userGuidance;if(t)for(let e of Zo){let n=Yo(t[e]);if(n)return n}}function es(e,t){if(!e)return;let n=Ho.get(e);if(n&&n.length!==0)return t&&n.includes(t)?t:n[0]}function ts(e,t){let{translators:n}=t,r=Xo(e),i=Qo(r,n);if(i)return i;let a=Yo(t.surfaceMessage),o=Wo(n.tErrorMessage,r.customMessageReference);if(o){let e=es(r.customMessageReference,r.errorType);if(e===void 0||Vo[e]!==X.SURFACE||a===void 0)return o}return a||(Wo(n.tErrorMessage,fe.DEFAULT)??$o(r)??n.tErrorMessage(fe.DEFAULT))}function ns(){let{tErrorMessage:e,tErrorGuidance:t}=vt(),n=(0,W.useRef)({tErrorMessage:e,tErrorGuidance:t});return n.current={tErrorMessage:e,tErrorGuidance:t},(0,W.useCallback)((e,t)=>ts(e,{translators:n.current,surfaceMessage:t}),[])}var rs=()=>{let e=(0,W.useContext)(Ka);if(!e)throw Error(`useWebSocket must be used within a WebSocketProvider`);return e},Z=Je;function is(e,t){switch(t.type){case`INIT_SESSION`:return e.status===Z.IDLE?{status:Z.INITIALIZING,anonymousUserId:t.anonymousUserId,sessionToken:null}:e;case`SESSION_TOKEN_RECEIVED`:return e.status!==Z.INITIALIZING&&e.status!==Z.ACTIVE?e:{...e,status:Z.ACTIVE,sessionToken:t.sessionToken};case`RESTORE_SESSION`:return{status:Z.ACTIVE,anonymousUserId:t.anonymousUserId,sessionToken:t.sessionToken};case`START_TRANSPOSITION`:return e.status===Z.ACTIVE?{...e,status:Z.TRANSPOSING}:e;case`CLEAR`:return{status:Z.CLEARED,anonymousUserId:null,sessionToken:null};default:return e}}var as={status:Z.IDLE,anonymousUserId:null,sessionToken:null},os=(0,W.createContext)(void 0);function ss({children:e}){let{httpClient:t}=Tt(),[n,r]=(0,W.useReducer)(is,as),i=(0,W.useMemo)(()=>[t,F()],[t]),a=(0,W.useCallback)((e,t)=>{i.forEach(n=>n.setAnonymousSession(e,t))},[i]),o=(0,W.useCallback)(()=>{i.forEach(e=>e.clearAnonymousSession())},[i]),s=(0,W.useCallback)(e=>{i.forEach(t=>t.updateAnonymousSessionToken(e))},[i]);(0,W.useEffect)(()=>{let e=Ze(N.ANONYMOUS_USER_ID),t=Ze(N.ANONYMOUS_SESSION_TOKEN);e&&t&&(r({type:`RESTORE_SESSION`,anonymousUserId:e,sessionToken:t}),a(e,t));let n=e=>{r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e})};return i.forEach(e=>e.setAnonymousSessionTokenHandler(n)),()=>{i.forEach(e=>e.setAnonymousSessionTokenHandler(null))}},[i,a]),(0,W.useEffect)(()=>{switch(n.status){case Z.INITIALIZING:n.anonymousUserId&&(Me(N.ANONYMOUS_USER_ID,n.anonymousUserId),a(n.anonymousUserId,null));break;case Z.ACTIVE:n.anonymousUserId&&n.sessionToken&&(Me(N.ANONYMOUS_USER_ID,n.anonymousUserId),Me(N.ANONYMOUS_SESSION_TOKEN,n.sessionToken),a(n.anonymousUserId,n.sessionToken));break;case Z.CLEARED:Ye(N.ANONYMOUS_USER_ID),Ye(N.ANONYMOUS_SESSION_TOKEN),o()}},[n.status,n.anonymousUserId,n.sessionToken,a,o]);let c=(0,W.useRef)(n);(0,W.useEffect)(()=>{c.current=n},[n]),(0,W.useEffect)(()=>{let e=e=>{if(e.key===N.ANONYMOUS_USER_ID){if(!e.newValue)r({type:`CLEAR`}),o();else if(e.newValue!==c.current.anonymousUserId){let t=Ze(N.ANONYMOUS_SESSION_TOKEN);t&&(r({type:`RESTORE_SESSION`,anonymousUserId:e.newValue,sessionToken:t}),a(e.newValue,t))}}e.key===N.ANONYMOUS_SESSION_TOKEN&&e.newValue&&e.newValue!==c.current.sessionToken&&(r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e.newValue}),s(e.newValue))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[a,o,s]);let l=(0,W.useCallback)(()=>{if(n.anonymousUserId&&n.status!==Z.IDLE&&n.status!==Z.CLEARED)return n.anonymousUserId;let e=crypto.randomUUID();return r({type:`INIT_SESSION`,anonymousUserId:e}),a(e,null),e},[n.anonymousUserId,n.status,a]),u=(0,W.useCallback)(e=>{r({type:`SESSION_TOKEN_RECEIVED`,sessionToken:e}),s(e)},[s]),d=(0,W.useCallback)(()=>{r({type:`START_TRANSPOSITION`})},[]),f=(0,W.useCallback)(()=>{r({type:`CLEAR`})},[]),p={status:n.status,anonymousUserId:n.anonymousUserId,sessionToken:n.sessionToken,isAnonymousActive:n.status===Z.ACTIVE||n.status===Z.INITIALIZING,initAnonymousSession:l,onSessionTokenReceived:u,startTransposition:d,clearAnonymousSession:f};return(0,G.jsx)(os.Provider,{value:p,children:e})}function cs(){let e=(0,W.useContext)(os);if(!e)throw Error(`useAnonymousSession must be used within AnonymousSessionProvider`);return e}var ls={isLoading:!1,error:null,sessionId:null,accessToken:null,identification:null,sessionState:null,isRestoringSession:!1,sessionRestored:!1,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],onboardingSessionId:null,purpose:null,sessionType:null,oneOffContext:void 0,crossFrontendHandoffContext:void 0};function us(e){return e===`second`?st.SECOND:st.FIRST}var ds;(function(e){e.CONDITIONAL=`conditional`,e.MODAL=`modal`})(ds||={});var fs=class extends Error{constructor(){super(`Passkey autofill challenge expired before a passkey was picked`),this.name=`PasskeyAutofillExpiredError`}},ps=class extends Error{constructor(){super(`Passkey autofill stepped aside for a ceremony the person started`),this.name=`PasskeyAutofillSupersededError`}},ms=!1,hs=class{getAccessToken(){return Ze(N.JWT_TOKEN)}getRefreshToken(){return null}storeTokens(e,t){e?Me(N.JWT_TOKEN,e):Ye(N.JWT_TOKEN),t!==null&&!ms&&(ms=!0,console.warn("[wildo-auth] PersistentSessionTokenStorage.storeTokens() received a non-null refreshToken — argument is ignored. Refresh tokens now travel via the `__wildo_refresh` HttpOnly cookie (Auth-hardening Slice A).")),Ye(N.REFRESH_TOKEN)}getOrganizationId(){return Ze(N.CURRENT_ORGANIZATION_ID)}setOrganizationId(e){e?Me(N.CURRENT_ORGANIZATION_ID,e):Ye(N.CURRENT_ORGANIZATION_ID)}clear(){Ye(N.JWT_TOKEN),Ye(N.REFRESH_TOKEN),Ye(N.CURRENT_ORGANIZATION_ID)}},gs=class{_accessToken=null;_refreshToken=null;_organizationId=null;getAccessToken(){return this._accessToken}getRefreshToken(){return this._refreshToken}storeTokens(e,t){this._accessToken=e,this._refreshToken=t}getOrganizationId(){return this._organizationId}setOrganizationId(e){this._organizationId=e}clear(){this._accessToken=null,this._refreshToken=null,this._organizationId=null}},Q=We.getLogger(),$=Q.debugByType(`AuthSessionContext`),_s=new Set([c.SESSION_ENDED,c.ACCOUNT_NOT_ACTIVE]);Q.setDebugTypeLogging(`AuthSessionContext`,!1);var vs=new Set([de.MFA_REQUIRED,de.MFA_ENROLLMENT_REQUIRED]),ys=(0,W.createContext)(void 0),bs=15e3;function xs(e,t){let n=globalThis.PublicKeyCredential;e&&typeof n?.signalUnknownCredential==`function`&&n.signalUnknownCredential({rpId:e,credentialId:t}).catch(()=>void 0)}var Ss=({children:e,tokenStorage:t})=>{let n=(0,W.useMemo)(()=>t??new hs,[t]),{setAuthToken:i,setTokenRenewalHandler:a,setConsumableToken:o}=to(),{handleError:s}=ao(),{tComponent:l,isReady:u}=vt({component:[xt.PUBLIC_LAYOUTS_USER_AUTH,xt.PUBLIC_LAYOUTS_MFA_CHALLENGE]}),d=ns(),f=(0,W.useCallback)(()=>so({tComponent:l,componentType:xt.PUBLIC_LAYOUTS_MFA_CHALLENGE,key:y.ERROR_GENERIC}),[l]),{appConfig:p}=Tt(),{connect:m,disconnect:h,refreshAuth:g,switchOrganization:_}=rs(),{clearAnonymousSession:v}=cs(),b=(0,W.useRef)(!1),x=(0,W.useRef)(null),S=(0,W.useRef)(null),C=(0,W.useRef)(0),ee=(0,W.useRef)(0);(0,W.useEffect)(()=>()=>{C.current+=1},[]);let w=(0,W.useRef)(null),[T,E]=(0,W.useState)({...ls,accessToken:n.getAccessToken()}),te=(0,W.useRef)(P.RESUMED),ne=(0,W.useRef)(c.SESSION_ENDED),re=(0,W.useCallback)(()=>te.current,[]),ie=(0,W.useCallback)(()=>ne.current,[]),ae=(0,W.useRef)(!1),[oe,D]=(0,W.useState)(null),ce=(0,W.useRef)(null),le=e=>{ce.current=e,D(e)},O=(0,W.useCallback)(()=>ce.current,[]),k=(e,t)=>{n.storeTokens(e,null),te.current=t,ue(),v()},ue=()=>{ae.current=!1,le(null)},fe=e=>{n.storeTokens(e,null),ue(),v()},A=e=>{E(t=>({...t,isLoading:!1,error:null,sessionId:null,onboardingSessionId:e,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]}))},pe=(0,W.useCallback)(()=>{if(!p?.runtime?.endPoints?.main_backend_api)return Q.warn(`WebSocket: Cannot derive URL - appConfig.runtime.endPoints.main_backend_api not available`),null;let e=p.runtime.endPoints.main_backend_api.publicUrl;return e?e.replace(/^http/,`ws`):(Q.warn(`WebSocket: Cannot derive URL - publicUrl not available in main_backend_api config`),null)},[p]),j=(0,W.useCallback)((e,t,n)=>{if(!e){$(`WebSocket: Cannot connect - no token provided`);return}let r=pe();if(!r)$(`WebSocket: Cannot connect - URL is not available`);else try{m({url:r,token:e,organizationId:t||void 0,consumableToken:n||void 0,autoReconnect:!0,reconnectInterval:1e3,maxReconnectAttempts:15,onAuthenticationError:()=>w.current?.()}),$(`WebSocket connection initiated`,{wsUrl:r})}catch(e){Q.warn(`Failed to connect WebSocket`,{error:e})}},[m,pe]),me=(0,W.useCallback)((e,t)=>{_(e,t)},[_]),he=async e=>{let t=++C.current;Bo(),E(e=>({...e,isLoading:!0,error:null,identification:null,sessionId:null,sessionState:null,onboardingSessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),$(`Identifying user by email`,{email:e});try{let n=await F().identifyByEmail(e);return t===C.current&&($(`User identification successful`,{sessionId:n.sessionId}),E(e=>t===C.current?{...e,isLoading:!1,identification:n,sessionId:n.sessionId,purpose:e.purpose??_t.LOGIN}:e)),n}catch(n){if(t!==C.current)throw n;let r=d(n);throw s(n,`Identification failed`,{email:e,message:r}),E(e=>t===C.current?{...e,isLoading:!1,error:r}:e),n}},ge=(e,t)=>{let n=e.accessToken||null;n?(k(n,P.SIGNED_IN),F().setAuthToken(n),i(n),e.success?(E(e=>({...e,isLoading:!1,accessToken:n,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):E(e=>({...e,isLoading:!1,accessToken:n,sessionId:t}))):E(n=>n.accessToken?{...n,isLoading:!1}:{...n,isLoading:!1,sessionId:e.success?null:t})},_e=async(e,t)=>{E(e=>({...e,isLoading:!0,error:null})),$(`Authenticating with password`,{email:e,sessionId:T.sessionId});try{let n=T.sessionId;if(!n){let t=Error(`No active session. Please identify user first.`);throw Q.warn(`Authentication attempted without session`,{email:e}),t}let r={sessionId:n,method:gt.PASSWORD,factorLevel:st.FIRST,password:t},i=await F().authenticate(r),a=Ao(i);return a?(A(a),i):i.requiresMFA&&!i.accessToken?(E(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:i.sessionId||n,availableMfaMethods:i.availableMFAMethods||[],availableEnrollmentMethods:i.availableEnrollmentMethods||[],enrolledSecondFactorMethods:i.enrolledSecondFactorMethods||[],usableSecondFactorMethods:i.usableSecondFactorMethods||[]})),i):($(`Authentication successful`,{success:i.success,hasAccessToken:!!i.accessToken}),ge(i,n),i)}catch(t){let n=d(t);throw s(t,`Authentication failed`,{email:e,message:n}),E(e=>({...e,isLoading:!1,error:n})),t}},ve=async e=>{E(e=>({...e,isLoading:!0,error:null})),$(`Authenticating`,{method:e.method,sessionId:e.sessionId||T.sessionId});try{let t=e.sessionId||T.sessionId;if(!t){let t=Error(`No active session. Please identify user first.`);throw Q.warn(`Authentication attempted without session`,{method:e.method}),t}let n={...e,sessionId:t},r=await F().authenticate(n),i=Ao(r);return i?(A(i),r):r.requiresMFA&&!r.accessToken?(E(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:r.sessionId||t,availableMfaMethods:r.availableMFAMethods||[],availableEnrollmentMethods:r.availableEnrollmentMethods||[],enrolledSecondFactorMethods:r.enrolledSecondFactorMethods||[],usableSecondFactorMethods:r.usableSecondFactorMethods||[]})),r):($(`Authentication successful`,{success:r.success,hasAccessToken:!!r.accessToken,method:e.method}),ge(r,t),r)}catch(t){let n=d(t);throw s(t,`Authentication failed`,{method:e.method,message:n}),E(e=>({...e,isLoading:!1,error:n})),t}},ye=async e=>{$(`Getting session state`,{sessionId:e});try{let t=await F().getSessionState(e);return E(e=>({...e,sessionState:t,purpose:t?.purpose??e.purpose})),$(`Session state retrieved`,{sessionId:e}),t}catch(t){throw s(t,`Failed to get session state`,{sessionId:e}),t}},be=()=>!!T.accessToken,xe=(0,W.useCallback)(async(e,t,n)=>{$(`Initiating OAuth2 login`,{providerRef:e,returnUrl:t}),E(e=>({...e,isLoading:!0,error:null}));try{let{authorizationUrl:r}=await F().getOAuth2AuthorizationUrl(e,t,void 0,n);$(`Redirecting to OAuth2 provider`,{providerRef:e,authorizationUrl:r}),window.location.href=r}catch(t){let n=d(t);throw s(t,`OAuth2 login initiation failed`,{providerRef:e,message:n}),E(e=>({...e,isLoading:!1,error:n})),t}},[s,d]),Se=(0,W.useCallback)(async e=>{$(`Handling AUTH_CODE_EXCHANGE token (OAuth2 callback or cross-frontend handoff)`,{codeLength:e.length}),E(e=>({...e,isLoading:!0,error:null}));try{let t=await F().exchangeAuthCode(e),n=Ao(t);if(n){$(`Code exchange parked the federated sign-in at organization onboarding`),A(n);return}if(!(`accessToken`in t))throw Error(`The code exchange answered with neither a sign-in nor a parked onboarding session.`);let{accessToken:r,returnPath:a,sourceFrontendServiceName:o,targetServiceKey:s}=t;k(r,typeof a==`string`?P.RESUMED:P.SIGNED_IN),F().setAuthToken(r),i(r);let c=typeof a==`string`?{returnPath:a,...o!==void 0&&{sourceFrontendServiceName:o},...s!==void 0&&{targetServiceKey:s}}:void 0;$(`OAuth2 callback successful, tokens stored`,{isCrossFrontendHandoff:c!==void 0}),E(e=>({...e,isLoading:!1,accessToken:r,isRestoringSession:!0,sessionRestored:!1,sessionId:null,crossFrontendHandoffContext:c})),b.current=!0}catch(e){let t=d(e);throw s(e,`OAuth2 callback failed`,{message:t}),E(e=>({...e,isLoading:!1,error:t})),e}},[i,s,d]),Ce=(0,W.useCallback)(async(e,t)=>{$(`Handling email verification`,{tokenLength:e.length,email:t}),E(e=>({...e,isLoading:!0,error:null}));try{let n=await F().verifyEmail(e,t);n.accessToken?(k(n.accessToken,P.SIGNED_IN),F().setAuthToken(n.accessToken),i(n.accessToken),$(`Email verification successful, tokens stored`),E(e=>({...e,isLoading:!1,accessToken:n.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):Ao(n)?($(`Email verification parked the registrant at organization onboarding`,{state:n.state}),A(n.sessionId)):($(`Email verification succeeded but tokens not issued — pipeline requires further steps`,{state:n.state,nextStep:n.nextStep}),E(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:n.requiresMFA??!1,mfaSessionId:n.requiresMFA?n.sessionId??null:null,availableMfaMethods:[],availableEnrollmentMethods:n.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})))}catch(e){let t=d(e);throw s(e,`Email verification failed`,{message:t}),E(e=>({...e,isLoading:!1,error:t})),e}},[i,s,d]),M=(0,W.useCallback)(async e=>{$(`Handling invitation acceptance`,{hasPassword:!!e.password,credentialMethod:e.credentialMethod}),E(e=>({...e,isLoading:!0,error:null}));try{let t=await F().acceptInvitation(e);return t.accessToken?(k(t.accessToken,P.SIGNED_IN),F().setAuthToken(t.accessToken),i(t.accessToken),$(`Invitation acceptance successful, tokens stored`),E(e=>({...e,isLoading:!1,accessToken:t.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0):($(`Invitation acceptance requires further auth steps`,{state:t.state,nextStep:t.nextStep}),E(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:t.requiresMFA??!1,mfaSessionId:t.requiresMFA?t.sessionId??null:null,availableMfaMethods:[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null}))),{passkeyRegistrationOptions:t.passkeyRegistrationOptions,signInRequired:t.nextStep===Qe.SIGN_IN_REQUIRED}}catch(e){let t=d(e);throw s(e,`Invitation acceptance failed`,{message:t}),E(e=>({...e,isLoading:!1,error:t})),e}},[i,s,d]),we=(0,W.useCallback)(async e=>{$(`Handling public registration`,{hasPassword:!!e.password});let t=await F().register(e),n=Fo(t);if(n===No.SIGNED_IN){let e=t.accessToken;k(e,P.SIGNED_IN),F().setAuthToken(e),i(e),$(`Registration signed the registrant in, tokens stored`,{state:t.state}),E(t=>({...t,isLoading:!1,accessToken:e,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0}else n===No.MFA_ENROLLMENT_REQUIRED?($(`Registration owes a second-factor enrollment before sign-in`,{state:t.state,nextStep:t.nextStep}),E(e=>({...e,isLoading:!1,sessionId:null,mfaRequired:!0,mfaSessionId:t.sessionId,availableMfaMethods:[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null}))):n===No.ORGANIZATION_ONBOARDING_REQUIRED?($(`Registration parked the registrant at organization onboarding`,{state:t.state}),A(t.sessionId)):$(`Registration answered without a session to adopt`,{outcome:n,state:t.state,nextStep:t.nextStep});return n},[i]),Te=(0,W.useCallback)(async(e,t)=>{$(`Handling magic link verification`,{tokenLength:e.length,email:t}),E(e=>({...e,isLoading:!0,error:null}));try{let n=await F().magicLinkVerify(e,t),r=Ao(n);return r?(A(r),n):n.requiresMFA&&!n.accessToken?(E(e=>({...e,isLoading:!1,mfaRequired:!0,mfaSessionId:n.sessionId||null,availableMfaMethods:n.availableMFAMethods||[],availableEnrollmentMethods:n.availableEnrollmentMethods||[],enrolledSecondFactorMethods:n.enrolledSecondFactorMethods||[],usableSecondFactorMethods:n.usableSecondFactorMethods||[]})),n):(n.success&&n.accessToken?(k(n.accessToken,P.SIGNED_IN),F().setAuthToken(n.accessToken),i(n.accessToken),$(`Magic link verification successful, tokens stored`),E(e=>({...e,isLoading:!1,accessToken:n.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null})),b.current=!0):E(e=>({...e,isLoading:!1})),n)}catch(e){let t=d(e);throw s(e,`Magic link verification failed`,{message:t}),E(e=>({...e,isLoading:!1,error:t})),e}},[i,s,d]),Ee=(0,W.useCallback)(async(e,t,n)=>{$(`Handling MFA verification`,{sessionId:e,method:t}),E(e=>({...e,isLoading:!0,error:null}));try{let r=F(),a=await r.authenticate({sessionId:e,method:t,factorLevel:st.SECOND,token:n}),o=Ao(a);return o?(A(o),a):(a.success&&a.accessToken?(k(a.accessToken,P.SIGNED_IN),r.setAuthToken(a.accessToken),i(a.accessToken),$(`MFA verification successful, tokens stored`),E(e=>({...e,isLoading:!1,accessToken:a.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),b.current=!0):E(e=>({...e,isLoading:!1,error:d(null,f())})),a)}catch(e){let n=d(e,f());throw s(e,`MFA verification failed`,{method:t,message:n}),E(e=>({...e,isLoading:!1,error:n})),e}},[i,s,d,f]),De=(0,W.useCallback)((e,t)=>!t?.state||!vs.has(t.state)?!1:(E(n=>({...n,mfaRequired:!0,mfaSessionId:e,availableMfaMethods:t.availableSecondFactorMethods||[],availableEnrollmentMethods:t.availableEnrollmentMethods||[],enrolledSecondFactorMethods:t.enrolledSecondFactorMethods||[],usableSecondFactorMethods:t.usableSecondFactorMethods||[]})),!0),[]),Oe=(0,W.useCallback)(e=>{let t=Ao(e);if(t)return $(`Enrollment parked the registration session at organization onboarding`),A(t),!0;if(!e?.accessToken||e.state!==de.COMPLETED)return!1;let n=F();return k(e.accessToken,P.SIGNED_IN),n.setAuthToken(e.accessToken),i(e.accessToken),$(`Enrollment completed the registration session, tokens stored`),E(t=>({...t,isLoading:!1,accessToken:e.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0,!0},[i]),ke=(0,W.useCallback)(async e=>{let t=T.onboardingSessionId;if(!t)throw Error(`No session is parked at onboarding.`);E(e=>({...e,isLoading:!0,error:null}));try{let n=F(),r=await e(t);return r.accessToken?(k(r.accessToken,P.SIGNED_IN),n.setAuthToken(r.accessToken),i(r.accessToken),$(`Onboarding completed, tokens stored`,{organizationId:r.organizationId}),E(e=>({...e,isLoading:!1,accessToken:r.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,onboardingSessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[],error:null})),b.current=!0,{signedIn:!0,pendingObligations:[]}):(E(e=>({...e,isLoading:!1})),$(`Onboarding obligation completed; the session stays parked on the rest`,{pendingObligations:r.pendingObligations}),{signedIn:!1,pendingObligations:r.pendingObligations??[]})}catch(e){throw Mo(e)?Me():E(e=>({...e,isLoading:!1})),e}},[T.onboardingSessionId,i]),Ae=(0,W.useCallback)(e=>ke(t=>F().completeOrgOnboarding(t,e)),[ke]),je=(0,W.useCallback)((e,t)=>ke(n=>F().completeProfileOnboarding(n,e,t)),[ke]),Me=()=>{C.current+=1,Bo(),E(e=>({...e,isLoading:!1,error:null,identification:null,sessionId:null,sessionState:null,onboardingSessionId:null}))},Ne=(0,W.useCallback)(()=>{Me()},[]),Pe=(0,W.useCallback)(async({sessionId:e,factorLevel:t,conditional:n})=>{$(`Handling passkey authentication`,{sessionId:e,factorLevel:t,conditional:n}),n||E(e=>({...e,isLoading:!0,error:null}));let r=!1,a=!1,o=t===`first`?xt.PUBLIC_LAYOUTS_USER_AUTH:xt.PUBLIC_LAYOUTS_MFA_CHALLENGE,c=e=>so({tComponent:l,componentType:o,key:e}),u=t===`first`?mt.PASSKEY_ERROR:y.PASSKEY_ERROR,f=t===`first`?mt.PASSKEY_CANCELLED:y.PASSKEY_CANCELLED;try{let o=F(),s=await o.passkeyAuthOptions(e),l=s.options;if(n&&ee.current>0)throw new ps;let f,p=(s.expiresInSeconds??0)*1e3-bs,m=n&&p>0,h=Date.now()+p,g=()=>{a||(a=!0,xo.cancelCeremony())},_=()=>{Date.now()>=h&&g()};m&&(f=setTimeout(g,p),typeof document<`u`&&document.addEventListener(`visibilitychange`,_),typeof window<`u`&&window.addEventListener(`focus`,_));let v;try{v=await ko({optionsJSON:l,useBrowserAutofill:n})}finally{clearTimeout(f),m&&(typeof document<`u`&&document.removeEventListener(`visibilitychange`,_),typeof window<`u`&&window.removeEventListener(`focus`,_))}r=!0,n&&E(e=>({...e,isLoading:!0,error:null}));let y=await o.passkeyAuthVerify({response:v,sessionId:s.sessionId,factorLevel:us(t)});y.passkeyCredentialUnknown&&xs(l?.rpId,v.id);let x=Ao(y);return x?(A(x),y):y.requiresMFA&&!y.accessToken?(E(t=>({...t,isLoading:!1,mfaRequired:!0,mfaSessionId:y.sessionId||e,availableMfaMethods:y.availableMFAMethods||[],availableEnrollmentMethods:y.availableEnrollmentMethods||[],enrolledSecondFactorMethods:y.enrolledSecondFactorMethods||[],usableSecondFactorMethods:y.usableSecondFactorMethods||[]})),y):(y.success&&y.accessToken?(k(y.accessToken,P.SIGNED_IN),o.setAuthToken(y.accessToken),i(y.accessToken),$(`Passkey authentication successful, tokens stored`),E(e=>({...e,isLoading:!1,accessToken:y.accessToken,isRestoringSession:!0,sessionRestored:!1,sessionId:null,mfaRequired:!1,mfaSessionId:null,availableMfaMethods:[],availableEnrollmentMethods:[],enrolledSecondFactorMethods:[],usableSecondFactorMethods:[]})),b.current=!0):E(e=>({...e,isLoading:!1,error:d(null,c(u))})),y)}catch(t){if(n&&!r)throw a?new fs:t;let i=t?.name===`NotAllowedError`?c(f):d(t,c(u));throw s(t,`Passkey authentication failed`,{sessionId:e,message:i}),E(e=>({...e,isLoading:!1,error:i})),t}},[i,s,l,d]),Fe=(0,W.useCallback)(async e=>{ee.current+=1;try{return await Pe({...e,conditional:!1})}finally{--ee.current}},[Pe]),Ie=(0,W.useCallback)((e,t=`first`)=>Fe({sessionId:e,factorLevel:t}),[Fe]),Le=(0,W.useCallback)((e=ds.MODAL)=>e===ds.CONDITIONAL?Pe({factorLevel:`first`,conditional:!0}):Fe({factorLevel:`first`}),[Pe,Fe]),Re=(0,W.useCallback)(async e=>{$(`Handling one-off token exchange`,{tokenLength:e.length}),E(e=>({...e,isLoading:!0,error:null}));try{let t=F(),{accessToken:r,consumableTokenValue:a,tokenExpiresAt:s,context:c}=await t.exchangeOneOffToken(e);k(r,P.ONE_OFF),t.setAuthToken(r),i(r),a&&(t.setConsumableToken(a),o(a)),c.organizationId&&n.setOrganizationId(c.organizationId),j(r,c.organizationId,a),C.current+=1,E({...ls,accessToken:r,sessionType:He.ONE_OFF,oneOffContext:{originTokenId:c.tokenId,tokenType:c.tokenType,consumableTokenValue:a,tokenExpiresAt:s,scopedInitiatorIds:c.targeting?.initiatorIds,applicationId:c.applicationId},sessionRestored:!0}),b.current=!0,$(`One-off token exchange successful`,{tokenType:c.tokenType})}catch(e){let t=d(e);throw s(e,`One-off token exchange failed`,{message:t}),E(e=>({...e,isLoading:!1,error:t})),e}},[n,i,o,j,s,d]),ze=(0,W.useRef)(null);(0,W.useEffect)(()=>{let e=T.mfaRequired&&!T.accessToken?T.mfaSessionId:null;e?(Ro({sessionId:e,email:T.identification?.email??``}),ze.current=e):(ze.current!==null||T.accessToken)&&(Bo(),ze.current=null)},[T.mfaRequired,T.mfaSessionId,T.accessToken,T.identification?.email]);let Be=(0,W.useCallback)((e,t)=>{$(`Ending session`,{reason:e,revokeOnBackend:t,alreadyEnded:ae.current}),C.current+=1,ae.current||(ae.current=!0,ne.current=e,le(_s.has(e)?e:null)),te.current=P.RESUMED,t&&F().logoutFromBackend().catch(e=>{Q.warn(`Backend logout call failed (token revocation)`,{error:e})}),x.current?.postMessage({type:`LOGOUT`,reason:ne.current}),h(),F().setConsumableToken(null),F().setAuthToken(null),o(null),i(null),n.clear(),Bo(),E(ls),b.current=!1,Q.info(`User logged out successfully`)},[h,n,i,o]),Ve=(0,W.useCallback)(e=>Be(e,!0),[Be]),Ue=(0,W.useCallback)(()=>Ve(c.SIGNED_OUT),[Ve]),We=(0,W.useCallback)(async()=>{await F().logoutAllFromBackend(),Be(c.SIGNED_OUT,!1)},[Be]),N=(0,W.useCallback)(()=>{E(e=>e.crossFrontendHandoffContext===void 0?e:{...e,crossFrontendHandoffContext:void 0})},[]),Ke=(0,W.useCallback)(()=>{E(e=>({...e,sessionRestored:!0,isRestoringSession:!1}))},[]),qe=(0,W.useCallback)(e=>{E(t=>({...t,isRestoringSession:e}))},[]),Je=(0,W.useCallback)(async()=>{if(S.current)return Q.debug(`Auth token renewal already in flight; waiting for shared result`),S.current;let e=n.getAccessToken(),t=()=>{let t=n.getAccessToken();return t&&t!==e?(F().setAuthToken(t),i(t),E(e=>e.accessToken===t?e:{...e,accessToken:t}),g(t),Q.debug(`Auth token renewal short-circuited; adopted token rotated by another tab`),t):null},a=async()=>{Q.debug(`Auth token renewal started`);let e=await F().refreshTokens();return fe(e.accessToken),F().setAuthToken(e.accessToken),i(e.accessToken),E(t=>({...t,accessToken:e.accessToken})),x.current?.postMessage({type:`TOKEN_REFRESHED`,accessToken:e.accessToken}),Q.debug(`Auth token renewal succeeded; frontend clients updated`),g(e.accessToken),e.accessToken};S.current=(async()=>{let e=typeof navigator<`u`?navigator.locks:void 0;return e?.request?e.request(`wildo-auth-refresh`,async()=>t()||a()):a()})().finally(()=>{S.current=null});try{return await S.current}catch(e){let t=r(e),n=Ge();throw t&&!n?(Q.warn(`Auth token renewal failed; refresh token was rejected and logout will follow`,{error:se(e)?e.customMessageReference:e instanceof Error?e.message:`Unknown error`}),Ve(ot(e))):Q.warn(`Auth token renewal failed but session is preserved (will retry on the next request)`,{authoritative:t,devLenient:n,reason:t?`development leniency active — not logging out on an authoritative rejection`:`transient failure (backend unreachable / 5xx / timeout) — not an authoritative rejection`}),e}},[i,Ve,g,n]);(0,W.useEffect)(()=>{w.current=Je,F().setTokenRenewalHandler(Je),a(Je)},[Je,a]),(0,W.useEffect)(()=>{if(typeof BroadcastChannel>`u`)return;let e=new BroadcastChannel(`wildo-auth-tokens`);return x.current=e,e.onmessage=e=>{let{type:t,accessToken:r}=e.data??{};if(t===`TOKEN_REFRESHED`&&r&&(Q.debug(`Auth token renewal received from another tab; frontend clients updated`),fe(r),F().setAuthToken(r),i(r),E(e=>({...e,accessToken:r})),g(r)),t===`LOGOUT`){if($(`Received logout signal from another tab`),C.current+=1,!ae.current){let t=e.data?.reason,n=_s.has(t);ae.current=!0,ne.current=n?t:c.SIGNED_OUT_IN_ANOTHER_TAB,le(n?t:null)}te.current=P.RESUMED,h(),n.clear(),F().setConsumableToken(null),o(null),n.storeTokens(null,null),F().setAuthToken(null),i(null),E(ls)}},()=>{e.close(),x.current=null}},[i,o,h,g,n]),(0,W.useEffect)(()=>{if(b.current)return;let e=n.getAccessToken();e?($(`Found stored access token, initializing auth state`),b.current=!0,E(t=>({...t,accessToken:e,isRestoringSession:!0})),F().setAuthToken(e),i(e)):($(`No stored access token found`),b.current=!0)},[i,n]);let Ye=(0,W.useMemo)(()=>({auth:T,tokenStorage:n,identifyByEmail:he,authenticateWithPassword:_e,authenticate:ve,getSessionState:ye,isAuthenticated:be,logout:Ue,signOutEverywhere:We,endSession:Ve,getSessionEstablishment:re,getSessionEndReason:ie,endedSessionReason:oe,getEndedSessionReason:O,initiateOAuth2Login:xe,handleAuthCodeExchange:Se,handleEmailVerification:Ce,acceptInvitation:M,registerAccount:we,handleMagicLinkVerify:Te,handleMfaVerify:Ee,completeEnrollmentSession:Oe,adoptPendingMfaSession:De,completeOrganizationOnboarding:Ae,completeProfileOnboarding:je,abandonOrganizationOnboarding:Ne,handlePasskeyAuth:Ie,signInWithPasskey:Le,handleOneOffTokenExchange:Re,clearCrossFrontendHandoffContext:N,markSessionRestored:Ke,setSessionRestoring:qe,connectWebSocket:j,notifyOrganizationSwitch:me}),[T,n,Ue,We,Ve,re,ie,oe,O,xe,Se,Ce,M,we,Te,Ee,Oe,De,Ae,je,Ne,Ie,Le,Re,N,Ke,qe,j,me]);return(0,G.jsx)(ys.Provider,{value:Ye,children:e})},Cs=()=>{let e=(0,W.useContext)(ys);if(!e)throw Error(`useAuthSession must be used within an AuthSessionProvider`);return e},ws=new Set(Object.values(Re).flat()),Ts=class e{static DEFAULT_PRIMARY_SCOPE=I.ORGANIZATIONS;static buildPrimaryScopeValues(e){return{organizationId:e.organizationId??null,userId:e.userId??null,applicationId:e.applicationId??null,anonymousUserId:e.anonymousUserId??null}}static buildInitiatorIds(e){let t={};return e.userId&&(t.userId=e.userId),e.organizationId&&(t.organizationId=e.organizationId),e.applicationId&&(t.applicationId=e.applicationId),e.anonymousUserId&&(t.anonymousUserId=e.anonymousUserId),Object.keys(t).length>0?t:null}static primaryScopeToContextIdentifiers(e,t){if(!e)return{};let n={[De.ORGANIZATIONS]:e.organizationId,[De.USERS]:e.userId,[De.APPLICATION]:e.applicationId,[De.ANONYMOUS_USERS]:e.anonymousUserId},r={},i=Re[t]||[];for(let e of i){let t=n[e];t&&(r[e]=t)}return r}static buildResourceOperationContextIdentifiers(t){let n=e.buildInitiatorIds({userId:t.currentUserId,organizationId:t.currentOrganizationId,applicationId:t.currentApplicationId,anonymousUserId:t.currentAnonymousUserId}),r=e.primaryScopeToContextIdentifiers(n,t.primaryScope??e.DEFAULT_PRIMARY_SCOPE),i=e.filterCustomScopeContextResourceIdentifiers(t.liveAppScopeContextResourceIdentifiers);return{...r,...i,...t.explicitContextResourceIdentifiers??{}}}static mergeContextResourceIdentifiers(...e){let t=e.reduce((e,t)=>t?{...e,...t}:e,{});return Object.keys(t).length>0?t:void 0}static filterCustomScopeContextResourceIdentifiers(e){return e?Object.fromEntries(Object.entries(e).filter(([e])=>!ws.has(e))):{}}static getAllowedViewBindingKeys(e){let t=new Set(Re[e.primaryScope]??[]),n=[...e.parentResourcesRequirements??[],...e.additionalResourceRequirements??[]];for(let e of n)t.add(e.resourceType),e.foreignKeyField&&t.add(e.foreignKeyField);return t}static scopeContextToBindingContract(e,t){if(!e)return;let n=Object.fromEntries(Object.entries(e).filter(([e])=>t.has(e)));return Object.keys(n).length>0?n:void 0}static resolveViewContextResourceIdentifiers(t){return e.mergeContextResourceIdentifiers(t.primaryScopeContext,t.customScopeContext,t.explicitContextResourceIdentifiers)}static findViewPrimaryScope(e,t){return!e||!t?null:t.find(t=>t.ref===e)?.primaryScope??null}static extractPrimaryScopeFromContent(t,n,r,i,a){switch(t.contentType){case Mt.RESOURCE_OPERATION:{let r=t.resourceContext?.resourceType;if(r&&n?.resourceConfigurations?.[r])return n.resourceConfigurations[r].resourcePrimaryScope||e.DEFAULT_PRIMARY_SCOPE;let i=t.resourceContext?.operation;return i?.resourcePrimaryScope?i.resourcePrimaryScope:e.DEFAULT_PRIMARY_SCOPE}case Mt.COMPOSITE_VIEW:return pn({viewRef:t.viewRef,compositeViews:r,registry:n})?.primaryScope??e.DEFAULT_PRIMARY_SCOPE;case Mt.CHART_VIEW:return t.viewDefinition?.primaryScope?t.viewDefinition.primaryScope:t.runtimeDescriptor||n?cr({viewRef:t.viewRef,registry:n})?.chartView.primaryScope??e.DEFAULT_PRIMARY_SCOPE:e.DEFAULT_PRIMARY_SCOPE;case Mt.FULL_CUSTOM_VIEW:return e.findViewPrimaryScope(t.viewRef,i)??e.DEFAULT_PRIMARY_SCOPE;case Mt.FLOWS_ACTORS_VIEW:return e.findViewPrimaryScope(t.viewRef,a)??e.DEFAULT_PRIMARY_SCOPE;case Mt.EXECUTION_VIEW:return Br({viewRef:t.viewRef,registry:n})?.primaryScope??e.DEFAULT_PRIMARY_SCOPE;case Mt.CUSTOM_COMPONENT:case Mt.ENGINE_PAGE:case Mt.INLINE_CREATE:case Mt.ERROR_MODAL:return e.DEFAULT_PRIMARY_SCOPE}}static buildStorageKey(e){return`${e.appType}|${e.resourcePrimaryScope}|${e.primaryScopeValue}|${e.fieldIdentifier}`}static getPrimaryScopeValue(e,t){switch(e){case I.ORGANIZATIONS:return t.organizationId??null;case I.USER_SELF:return t.userId??null;case I.APPLICATION:return t.applicationId??null;case I.ANONYMOUS:return t.anonymousUserId??null;default:return null}}static loadAll(){let e=Ze(N.SCOPE_VALUES);if(!e)return{updatedAt:new Date().toISOString(),fields:{}};try{let t=JSON.parse(e);return typeof t!=`object`||!t?{updatedAt:new Date().toISOString(),fields:{}}:t}catch{return{updatedAt:new Date().toISOString(),fields:{}}}}static saveAll(e){let t={...e,updatedAt:new Date().toISOString()};Me(N.SCOPE_VALUES,JSON.stringify(t))}static getValue(t){let n=e.loadAll(),r=e.buildStorageKey(t);return n.fields[r]??null}static setValue(t,n){let r=e.loadAll(),i=e.buildStorageKey(t);n===null?delete r.fields[i]:r.fields[i]=n,e.saveAll(r)}static clearForContext(t,n,r){let i=e.loadAll(),a=`${t}|${n}|${r}|`;for(let e of Object.keys(i.fields))e.startsWith(a)&&delete i.fields[e];e.saveAll(i)}static loadForContext(t,n,r){let i={};for(let a of r){let r=e.getPrimaryScopeValue(a.resourcePrimaryScope,n);if(!r){i[a.fieldIdentifier]=null;continue}let o=e.getValue({appType:t,resourcePrimaryScope:a.resourcePrimaryScope,primaryScopeValue:r,fieldIdentifier:a.fieldIdentifier});i[a.fieldIdentifier]=o}return i}},Es=We.getLogger(),Ds=Es.debugByType(`AppScopeContext`);Es.setDebugTypeLogging(`AppScopeContext`,!1);var Os=(0,W.createContext)(void 0),ks=(0,W.createContext)(void 0);function As(){let e=W.useContext(ks);if(!e)throw Error(`useAppScopeInternal must be used within an AppScopeProvider`);return e}function js(e,t){return e===t?!0:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):!1}function Ms(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0):[]}function Ns(e){return Array.isArray(e)?e[0]??null:e??null}function Ps(e){if(!e)return{userId:null,applicationId:null};try{let t=Fa(e);return{userId:t.userId??null,applicationId:t.applicationId??null}}catch(e){return Es.warn(`Failed to decode access token for AppScope primary values`,{error:e}),{userId:null,applicationId:null}}}var Fs=({children:e})=>{let{emit:t,on:n}=Fe(),{registry:r,doOperation:i}=to(),{frontendConfiguration:a}=Tt(),{auth:o,tokenStorage:s,notifyOrganizationSwitch:c}=Cs(),{status:l,anonymousUserId:d}=cs(),f=Ce.loadEnvironmentConfig().frontendServiceName,p=()=>o.accessToken&&!o.sessionRestored?null:s.getOrganizationId(),[m,h]=(0,W.useState)(()=>p()),[_,v]=(0,W.useState)({}),[y,b]=(0,W.useState)([]),x=(0,W.useRef)({}),[S,ee]=(0,W.useState)([]),[w,T]=(0,W.useState)(!1),[te,ne]=(0,W.useState)(!0),re=(0,W.useRef)(!1),ie=(0,W.useRef)(null),oe=(0,W.useRef)(null),se=(0,W.useRef)(void 0),le=(0,W.useMemo)(()=>Ps(o.accessToken),[o.accessToken]),O=(0,W.useMemo)(()=>Ts.buildPrimaryScopeValues({organizationId:m,userId:le.userId,applicationId:le.applicationId,anonymousUserId:o.accessToken?null:d}),[m,le.userId,le.applicationId,o.accessToken,d]),k=(0,W.useMemo)(()=>{if(o.accessToken)return o.sessionType===He.ONE_OFF?D.AUTHENTICATED_ONE_OFF:D.AUTHENTICATED_PERSISTENT;switch(l){case Z.INITIALIZING:return D.ANONYMOUS_INITIALIZING;case Z.ACTIVE:return D.ANONYMOUS_ACTIVE;case Z.TRANSPOSING:return D.ANONYMOUS_TRANSPOSING;case Z.IDLE:case Z.CLEARED:default:return D.UNAUTHENTICATED}},[o.accessToken,o.sessionType,l]),ue=(0,W.useMemo)(()=>({...O,..._}),[O,_]),de=(0,W.useMemo)(()=>{let e=kn(a?.appScope?.fields??[]);return e.length===0?null:`Duplicate app-scope resourceType declarations are not allowed in appScope.fields. Conflicts: ${e.map(e=>`${e.resourceType} (${e.fieldIdentifiers.join(`, `)})`).join(`; `)}`},[a]),fe=(0,W.useCallback)((e,t)=>{h(n=>n===e?n:(se.current=t,s.setOrganizationId(e),n&&e&&c(e,n),e))},[c,s]),A=!!o.accessToken;(0,W.useEffect)(()=>{let e=!!o.accessToken&&!o.sessionRestored,t=!!o.accessToken;h(n=>{if(e)return null;let r=s.getOrganizationId();return t&&n||n===r?n:r})},[A,o.sessionRestored,o.sessionType,s]),(0,W.useEffect)(()=>{if(!r)return;let e=(a?.appScope?.fields??[]).map(e=>{let t=r.resourceConfigurations[e.resourceType];return t?{...e,resourcePrimaryScope:t.resourcePrimaryScope}:(Es.warn(`App scope field references unknown resource type`,{resourceType:e.resourceType,fieldIdentifier:e.fieldIdentifier}),null)}).filter(e=>e!==null).sort((e,t)=>(e.position??999)-(t.position??999));Ds(`Resolved scope fields from app config`,{count:e.length,fields:e.map(e=>e.fieldIdentifier),source:`appScope.fields`}),b(e),T(!0),ne(!1)},[r,a]),(0,W.useEffect)(()=>{if(!r||y.length===0)return;let e={none:0,soft:1,hard:2},t=new Map,n=(n,r,i)=>{if(!n||!r||n===r||i===`none`)return;let a=`${n}>>${r}`,o=t.get(a);(!o||e[i]>e[o])&&t.set(a,i)},i=e=>u(e)||y.some(t=>t.fieldIdentifier===e);for(let e of y){e.dependsOn&&n(e.dependsOn,e.fieldIdentifier,`hard`);let t=e.resourceType,a=r.resourceConfigurations[t],o=a?.resourceRelationships?Ct(a.resourceRelationships):[];for(let t of o){if(t.isDisabled||t.resourceType1===t.resourceType2&&!t.foreignKeyField)continue;let a=E.tryResolveRelationshipForeignKeyIdentity(t,r.allResourceFieldIdentifiers)?.fieldIdentifier;if(!a||!i(a))continue;let o=`hard`;o=t.accessScopeStrategy===Pe.STANDALONE?`none`:t.accessScopeStrategy===Pe.OPTIONAL_CONTEXT?`soft`:`hard`,n(a,e.fieldIdentifier,o)}}let a=[];for(let[e,n]of t.entries()){let[t,r]=e.split(`>>`);a.push({parentFieldIdentifier:t,childFieldIdentifier:r,strength:n})}Ds(`Built scope dependencies`,{count:a.length}),ee(a)},[r,y]),(0,W.useEffect)(()=>{let e=oe.current;oe.current=O;let n=se.current;if(se.current=void 0,e)for(let r of ce){let i=e[r.fieldIdentifier]??null,a=O[r.fieldIdentifier]??null;if(i===a)continue;let o=r.scopeLevel===I.ORGANIZATIONS?n:void 0;t(et.PRIMARY_SCOPE_CHANGED,{scopeLevel:r.scopeLevel,fieldIdentifier:r.fieldIdentifier,newValue:a,previousValue:i,...o?{initiator:o}:{}})}},[t,O]),(0,W.useEffect)(()=>{if(y.length===0)return;let e=y.filter(e=>e.persist!==!1).map(e=>({fieldIdentifier:e.fieldIdentifier,resourcePrimaryScope:e.resourcePrimaryScope})),n=new Set(y.map(e=>e.fieldIdentifier)),r=Ts.loadForContext(f,O,e);v(e=>{let i={...e},a=[];for(let t of n){let n=e[t]??null,o=r[t]??null;js(n,o)||(i[t]=o,a.push({fieldId:t,previousValue:n,nextValue:o}),Ds(`Reconciled persisted scope value`,{fieldId:t,nextValue:o}))}return a.length>0&&queueMicrotask(()=>{for(let{fieldId:e,previousValue:n,nextValue:r}of a){let i=y.find(t=>t.fieldIdentifier===e);t(et.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:i?.resourceType??``,newValue:r,previousValue:n,initiator:g.RESTORE})}}),a.length>0?i:e})},[y,f,O,t]);let pe=(0,W.useCallback)((e,t=new Set)=>{if(t.has(e))return[];t.add(e);let n=S.filter(t=>t.parentFieldIdentifier===e&&t.strength===`hard`).map(e=>e.childFieldIdentifier),r=[];for(let e of n)r.push(e),r.push(...pe(e,t));return r},[S]),j=(0,W.useCallback)((e,n)=>{if(!re.current){re.current=!0;try{let r=pe(e);if(r.length===0)return;Ds(`Cascading to dependent fields`,{parentFieldIdentifier:e,fieldsToClear:r,reason:n}),v(n=>{let i={...n},a=[];for(let e of r){let t=i[e];t!=null&&(i[e]=null,a.push({fieldId:e,prevValue:t}))}return a.length>0&&queueMicrotask(()=>{for(let{fieldId:n,prevValue:r}of a){let i=y.find(e=>e.fieldIdentifier===n);t(et.APP_SCOPE_CHANGED,{fieldIdentifier:n,resourceType:i?.resourceType??``,newValue:null,previousValue:r,initiator:g.CASCADE,cascadedFrom:e})}}),a.length>0?i:n})}finally{re.current=!1}}},[pe,y,t]);(0,W.useEffect)(()=>{if(!w||y.length===0)return;let e=JSON.stringify(ue);if(ie.current===e)return;let n=y.filter(e=>e.resourceType&&_[e.fieldIdentifier]!==null&&_[e.fieldIdentifier]!==void 0);if(n.length===0){ie.current=e;return}let a=setTimeout(async()=>{Ds(`Starting scope validation`,{fields:n.map(e=>e.fieldIdentifier)});let a={};for(let[e,t]of Object.entries(ue)){let n=Ns(t);n&&(a[e]=n)}for(let e of n){let n=_[e.fieldIdentifier],o=Ms(n),s=o.length>0?o:typeof n==`string`&&n.length>0?[n]:[];if(s.length===0)continue;let c=e.resourceType;if(r?.resourceConfigurations[c])try{let o=(r?.resourceConfigurations?.[c])?.operations?.find(e=>String(e.operationIdentifier)===M.LIST);if(!o)continue;let l=dt.extractOperationPath(o),u=await i(l,{contextualParameters:a,pagination:{limit:100}});if(!u?.data||!Array.isArray(u.data))continue;let d=new Set(u.data.map(e=>String(e._id??``))),f=s.filter(e=>d.has(e)),p=Array.isArray(n)?f.length>0?f:null:f[0]??null;js(n,p)||(Ds(`Clearing invalid scope value`,{fieldIdentifier:e.fieldIdentifier,value:n,nextValue:p}),v(n=>{let r=n[e.fieldIdentifier];return js(r??null,p)?n:(queueMicrotask(()=>{t(et.APP_SCOPE_CHANGED,{fieldIdentifier:e.fieldIdentifier,resourceType:e.resourceType,newValue:p,previousValue:r??null,initiator:g.VALIDATION}),j(e.fieldIdentifier,`validation_cleared`)}),{...n,[e.fieldIdentifier]:p})}))}catch(t){Es.warn(`Error validating scope field`,{fieldIdentifier:e.fieldIdentifier,error:t})}}ie.current=e,Ds(`Scope validation complete`)},500);return()=>clearTimeout(a)},[w,y,_,O,ue,r,i,t,j]),(0,W.useEffect)(()=>n(et.PRIMARY_SCOPE_CHANGED,e=>{Ds(`PRIMARY_SCOPE_CHANGED received`,e);let{fieldIdentifier:t}=e;j(t,`primary_scope_changed`)}),[n,j]);let me=(0,W.useCallback)((e,n,r={})=>{let{initiator:i=g.API,skipPersist:a=!1}=r;if(u(e)){Es.warn(`Cannot set primary scope value via setScopeValue(). Use UserOrgsContext methods instead.`,{fieldIdentifier:e});return}let o=y.find(t=>t.fieldIdentifier===e);o?(Ds(`Setting scope value`,{fieldIdentifier:e,value:n,initiator:i}),v(r=>{let s=r[e]??null;return js(s,n)?r:(queueMicrotask(()=>{if(t(et.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:o.resourceType,newValue:n,previousValue:s,initiator:i}),j(e,`value_changed`),!a&&o.persist!==!1){let t=Ts.getPrimaryScopeValue(o.resourcePrimaryScope,O);t&&(Ts.setValue({appType:f,resourcePrimaryScope:o.resourcePrimaryScope,primaryScopeValue:t,fieldIdentifier:e},n),Ds(`Persisted scope value`,{fieldIdentifier:e,value:n}))}}),{...r,[e]:n})})):Es.warn(`Unknown scope field`,{fieldIdentifier:e})},[y,t,j,f,O]);(0,W.useEffect)(()=>{if(w&&y.length!==0)return n(et.NAVIGATION_ZONE_CHANGED,e=>{if(!ae.includes(e.zone))return;let t=e.currentContent;if(!t||t.contentType!==Mt.RESOURCE_OPERATION)return;let n=t.resourceContext?.contextResourceIdentifiers;if(!n)return;let r=t.resourceContext?.resourceType,i=t.resourceContext?.operation,a=!!i&&!Ne(i);for(let e of y){if(!e.resourceType)continue;if(a&&r===e.resourceType){delete x.current[e.fieldIdentifier],me(e.fieldIdentifier,null,{initiator:g.ROUTER,skipPersist:!0});continue}let t=n[e.resourceType],i=t?C.getResourceId(t):``;i?x.current[e.fieldIdentifier]=i:delete x.current[e.fieldIdentifier],i&&me(e.fieldIdentifier,i,{initiator:g.ROUTER,skipPersist:!0})}})},[y,w,n,me]),(0,W.useEffect)(()=>{if(w&&y.length!==0)return n(et.RESOURCE_COLLECTION_FILTERS_CHANGED,e=>{for(let t of y){if(!Object.prototype.hasOwnProperty.call(e.filterValues,t.fieldIdentifier))continue;let n=e.filterValues[t.fieldIdentifier],r=Array.isArray(n)?n[0]:n,i=typeof r==`string`&&r.length>0?r:null;i===null&&x.current[t.fieldIdentifier]||me(t.fieldIdentifier,i,{initiator:g.SURFACE_FILTER,skipPersist:!0})}})},[y,w,n,me]);let he=(0,W.useCallback)((e={})=>{let{initiator:n=g.API}=e;Ds(`Clearing all custom scope values`,{initiator:n}),v(e=>{let r={},i=[];for(let[t,n]of Object.entries(e))n!==null&&i.push({fieldId:t,prevValue:n}),r[t]=null;return i.length>0&&queueMicrotask(()=>{for(let{fieldId:e,prevValue:r}of i){let i=y.find(t=>t.fieldIdentifier===e);t(et.APP_SCOPE_CHANGED,{fieldIdentifier:e,resourceType:i?.resourceType??``,newValue:null,previousValue:r,initiator:n})}}),i.length>0?r:e})},[y,t]),ge=(0,W.useCallback)(e=>S.filter(t=>t.parentFieldIdentifier===e).map(e=>e.childFieldIdentifier),[S]),_e=(0,W.useCallback)(()=>{let e={};for(let t of ce){let n=O[t.fieldIdentifier];n&&(e[t.resourceType]=n)}for(let t of y){let n=_[t.fieldIdentifier],r=Ns(n);r&&t.resourceType&&(e[t.resourceType]=r)}return e},[O,_,y]),ve=(0,W.useCallback)(()=>{let e={};for(let[t,n]of Object.entries(ue))n!=null&&(!Array.isArray(n)||n.length>0)&&(e[t]=n);return e},[ue]),ye=(0,W.useMemo)(()=>({sessionMode:k,primaryScopeValues:O,customScopeValues:_,allScopeValues:ue,currentOrganizationId:O.organizationId,currentUserId:O.userId,currentApplicationId:O.applicationId,currentAnonymousUserId:O.anonymousUserId,primaryScopeFields:[...ce],customScopeFields:y,setScopeValue:me,clearCustomScopeValues:he,dependencies:S,getDependentFields:ge,buildContextResourceIdentifiers:_e,buildContextualParameters:ve,isReady:w,isLoading:te}),[k,O,_,ue,y,me,he,S,ge,_e,ve,w,te]);if(de)throw Error(de);return(0,G.jsx)(ks.Provider,{value:{commitOrganizationScopeValue:fe},children:(0,G.jsx)(Os.Provider,{value:ye,children:e})})};function Is(){let e=(0,W.useContext)(Os);if(!e)throw Error(`useAppScope must be used within an AppScopeProvider. Ensure AppScopeProvider is included in your provider hierarchy after AuthSessionProvider and above UserOrgsProvider.`);return e}function Ls(){return(0,W.useContext)(Os)}var Rs={list:[`h-4 w-3/4`,`h-4 w-full`,`h-4 w-2/3`],detail:[`h-6 w-1/3`,`h-4 w-full`,`h-4 w-2/3`],table:[`h-8 w-full`,`h-8 w-full`,`h-8 w-full`,`h-8 w-full`],card:[`h-32 w-full`,`h-5 w-2/3`,`h-4 w-full`]};function zs(e){return e!==void 0&&e!==`reset`}function Bs(e){return e!==void 0&&e!==`reset`&&e!==`inherit`}function Vs(e){switch(e){case`sm`:return`space-y-item-xs`;case`lg`:return`space-y-card`;default:return`space-y-field`}}var Hs=8;function Us(e){return e===void 0||!Number.isFinite(e)?1:Math.min(Math.max(Math.trunc(e),1),Hs)}function Ws(e,t){return e===void 0||e===`auto`?zs(t)?t:void 0:e}function Gs(e,t,n){return e===`auto`||e===void 0&&t===void 0&&n===void 0}function Ks(e,t,n){return e&&e!==`auto`&&e!==`inherit`?e:Bs(t)?t:n}function qs({preset:e=bt.DEFAULT,template:t,density:n,count:r,className:i,...a}){let o=W.useContext(d),s=o?.policy,c=at(xt.LOW_LEVEL_SKELETON,`Skeleton`)(e),l=s?.skeleton?.skeletonTemplate,u=s?.skeleton?.skeletonDensity,f=o?_e[o.variant].skeleton?.skeletonDensity:void 0,p=Bs(f)?f:`md`,m=s&&Gs(t,i,a.style)?Ws(t,l):t===`auto`||t===void 0?void 0:t;if(!m||m===`inherit`)return(0,G.jsx)(c,{className:i,...a});if(m===`none`)return(0,G.jsx)(G.Fragment,{});let h=Ks(n,u,p),g=Us(r),_=Rs[m];return(0,G.jsx)(`div`,{"data-slot":`skeleton-template`,"data-skeleton-template":m,"data-skeleton-density":h,"data-skeleton-count":g,className:le(Vs(h),i),...a,children:g===1?_.map((e,t)=>(0,G.jsx)(c,{className:e,"aria-hidden":`true`},`${m}-${t}`)):Array.from({length:g},(e,t)=>(0,G.jsx)(`div`,{className:Vs(h),children:_.map((e,t)=>(0,G.jsx)(c,{className:e,"aria-hidden":`true`},`${m}-${t}`))},`item-${t}`))})}function Js(e){switch(e){case`collapse`:case`hide`:case`render-children`:return e;default:return`placeholder`}}function Ys(e){return e===`collapse`}function Xs(e){return e===`hide`}var Zs=(0,W.forwardRef)(({preset:e=bt.DEFAULT,children:t,hidden:n,style:r,respectSurfaceEmptyDisplay:i=!0,...a},o)=>{let s=$e(),c=i?Js(s.interactiveState?.emptyDisplay):`placeholder`;if(c===`render-children`)return(0,G.jsx)(G.Fragment,{children:t??null});if(Ys(c))return null;let l=pt(xt.LOW_LEVEL_EMPTY_STATE,`EmptyState`)(e);return(0,G.jsx)(l,{...a,hidden:n||Xs(c),style:Xs(c)?{...r,display:`none`}:r,ref:o})});Zs.displayName=`EmptyState`;var Qs=({height:e=400})=>{let{tComponent:t,isReady:n}=vt({component:xt.HIGH_LEVEL_VIEWS_CHART});return n?(0,G.jsxs)(`div`,{role:`status`,"aria-live":`polite`,children:[(0,G.jsx)(qs,{className:`w-full rounded-lg`,style:{height:e}}),(0,G.jsx)(`span`,{className:`sr-only`,children:t(xt.HIGH_LEVEL_VIEWS_CHART,`loading`)})]}):null};export{ao as $,Gt as $n,er as $t,Xo as A,yn as An,Rr as At,Mo as B,un as Bn,ir as Bt,ss as C,wn as Cn,Mr as Ct,ns as D,bn as Dn,Ir as Dt,rs as E,xn as En,zr as Et,ts as F,an as Fn,Fr as Ft,wo as G,Xt as Gn,sr as Gt,Ao as H,pn as Hn,tr as Ht,Bo as I,fn as In,_r as It,so as J,Yt as Jn,ur as Jt,xo as K,Jt as Kn,or as Kt,zo as L,on as Ln,gr as Lt,Wo as M,ln as Mn,Ur as Mt,Ko as N,rn as Nn,Br as Nt,Vo as O,sn as On,Lr as Ot,qo as P,hn as Pn,Pr as Pt,po as Q,en as Qn,cr as Qt,No as R,gn as Rn,hr as Rt,us as S,Tn as Sn,br as St,cs as T,Sn as Tn,Wr as Tt,ko as U,mn as Un,rr as Ut,jo as V,dn as Vn,ar as Vt,Eo as W,qt as Wn,fr as Wt,fo as X,Qt as Xn,mr as Xt,co as Y,nn as Yn,pr as Yt,uo as Z,$t as Zn,nr as Zt,hs as _,En as _n,kr as _t,Xs as a,Gn as an,eo as at,ps as b,Xn as bn,jr as bt,Ls as c,Yn as cn,Qa as ct,As as d,qn as dn,J as dt,On as en,Wt as er,ro as et,Ts as f,Un as fn,Fa as ft,gs as g,Rn as gn,Ar as gt,Ss as h,Zn as hn,Dr as ht,Ys as i,Qn as in,$a as it,Go as j,_n as jn,Hr as jt,X as k,vn as kn,Gr as kt,Os as l,Kn as ln,Ka as lt,ys as m,Bn as mn,Or as mt,Zs as n,Ln as nn,to as nt,qs as o,Hn as on,Xa as ot,Cs as p,Vn as pn,Nr as pt,lo as q,tn as qn,lr as qt,Js as r,Cn as rn,no as rt,Is as s,Jn as sn,Za as st,Qs as t,$n as tn,Kt as tr,io as tt,Fs as u,Wn as un,Ja as ut,ls as v,zn as vn,Er as vt,Z as w,kn as wn,Vr as wt,ds as x,In as xn,yr as xt,fs as y,Dn as yn,xr as yt,Fo as z,cn as zn,vr as zt};