@glodon-aiot/chat-app-sdk 0.0.16 → 0.0.18

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 (3) hide show
  1. package/es/index.esm.js +1534 -395
  2. package/libs/cn/index.js +206 -19
  3. package/package.json +2 -2
package/es/index.esm.js CHANGED
@@ -10547,6 +10547,250 @@ ___CSS_LOADER_EXPORT___.locals = {
10547
10547
  /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10548
10548
 
10549
10549
 
10550
+ }),
10551
+ 94148: (function (module, __webpack_exports__, __webpack_require__) {
10552
+ __webpack_require__.d(__webpack_exports__, {
10553
+ A: () => (__WEBPACK_DEFAULT_EXPORT__)
10554
+ });
10555
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58623);
10556
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
10557
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34688);
10558
+ /* ESM import */var _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
10559
+ // Imports
10560
+
10561
+
10562
+ var ___CSS_LOADER_EXPORT___ = _common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_common_temp_default_node_modules_pnpm_css_loader_6_11_0_rspack_core_1_5_8_webpack_5_91_0_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
10563
+ // Module
10564
+ ___CSS_LOADER_EXPORT___.push([module.id, `/* Comment Message Container */
10565
+ .ffe867e2c235a0c5 {
10566
+ display: flex;
10567
+ align-items: center;
10568
+ gap: 4px;
10569
+ }
10570
+ /* Icon selected state */
10571
+ .d07fb38c947809f8 {
10572
+ color: #b752ea !important;
10573
+ }
10574
+ /* IconButton selected state - ensure background doesn't highlight */
10575
+ .d9418402ebdc6c0f {
10576
+ background-color: transparent !important;
10577
+ }
10578
+ .d9418402ebdc6c0f:hover {
10579
+ background-color: transparent !important;
10580
+ }
10581
+ /* Feedback Dialog Styles */
10582
+ .b29fb4268fffc847 {
10583
+ position: absolute;
10584
+ top: 0;
10585
+ left: 0;
10586
+ right: 0;
10587
+ bottom: 0;
10588
+ background-color: rgba(0, 0, 0, 0.5);
10589
+ display: flex;
10590
+ align-items: center;
10591
+ justify-content: center;
10592
+ z-index: 10000;
10593
+ }
10594
+ /* 当容器是 document.body 时,使用 fixed 定位 */
10595
+ .b29fb4268fffc847[data-container-is-body="true"] {
10596
+ position: fixed;
10597
+ top: 0;
10598
+ left: 0;
10599
+ right: 0;
10600
+ bottom: 0;
10601
+ }
10602
+ .a82c68467fbd9ba4 {
10603
+ background: #fff;
10604
+ border-radius: 8px;
10605
+ width: 90%;
10606
+ max-width: 480px;
10607
+ min-width: 320px;
10608
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
10609
+ display: flex;
10610
+ flex-direction: column;
10611
+ max-height: 90vh;
10612
+ }
10613
+ .a82c68467fbd9ba4 .fe9b5896dd607d27 {
10614
+ display: flex;
10615
+ align-items: center;
10616
+ justify-content: space-between;
10617
+ padding: 16px 20px;
10618
+ border-bottom: 1px solid #e8e8e8;
10619
+ }
10620
+ .a82c68467fbd9ba4 .f15e6e77acfff31a {
10621
+ margin: 0;
10622
+ font-size: 16px;
10623
+ font-weight: 600;
10624
+ color: #333;
10625
+ }
10626
+ .a82c68467fbd9ba4 .ec213d35312b7d7e {
10627
+ background: none;
10628
+ border: none;
10629
+ font-size: 24px;
10630
+ line-height: 1;
10631
+ color: #999;
10632
+ cursor: pointer;
10633
+ padding: 0;
10634
+ width: 24px;
10635
+ height: 24px;
10636
+ display: flex;
10637
+ align-items: center;
10638
+ justify-content: center;
10639
+ transition: color 0.2s;
10640
+ }
10641
+ .a82c68467fbd9ba4 .ec213d35312b7d7e:hover {
10642
+ color: #333;
10643
+ }
10644
+ .a82c68467fbd9ba4 .dc3fb716e09637a3 {
10645
+ padding: 20px;
10646
+ flex: 1;
10647
+ overflow-y: auto;
10648
+ }
10649
+ .a82c68467fbd9ba4 .dab8560c96fa0283 {
10650
+ display: flex;
10651
+ flex-wrap: wrap;
10652
+ gap: 12px;
10653
+ margin-bottom: 20px;
10654
+ }
10655
+ .a82c68467fbd9ba4 .d36e84632eb09d08 {
10656
+ padding: 8px 16px;
10657
+ border: 1px solid #d9d9d9;
10658
+ border-radius: 4px;
10659
+ background: #fff;
10660
+ color: #333;
10661
+ font-size: 14px;
10662
+ cursor: pointer;
10663
+ transition: all 0.2s;
10664
+ }
10665
+ .a82c68467fbd9ba4 .d36e84632eb09d08:hover {
10666
+ border-color: #999;
10667
+ color: #666;
10668
+ }
10669
+ .a82c68467fbd9ba4 .b8dbe31e00feb69b {
10670
+ border-color: #b752ea;
10671
+ background: #fff;
10672
+ color: #b752ea;
10673
+ }
10674
+ .a82c68467fbd9ba4 .b8dbe31e00feb69b:hover {
10675
+ border-color: #999;
10676
+ color: #666;
10677
+ }
10678
+ .a82c68467fbd9ba4 .df277aeb58f67270 {
10679
+ margin-top: 16px;
10680
+ }
10681
+ .a82c68467fbd9ba4 .d79bf5aef0816574 {
10682
+ padding: 5px 8px;
10683
+ width: 100%;
10684
+ border: 1px solid #d9d9d9;
10685
+ border-radius: 4px;
10686
+ font-size: 14px;
10687
+ font-family: inherit;
10688
+ resize: vertical;
10689
+ min-height: 80px;
10690
+ box-sizing: border-box;
10691
+ resize: none;
10692
+ }
10693
+ .a82c68467fbd9ba4 .d79bf5aef0816574:focus {
10694
+ outline: none;
10695
+ border: 1px solid #b752ea;
10696
+ box-shadow: 0 0 0 2px rgba(183, 82, 234, 0.1);
10697
+ }
10698
+ .a82c68467fbd9ba4 .d79bf5aef0816574::-moz-placeholder {
10699
+ color: #999;
10700
+ }
10701
+ .a82c68467fbd9ba4 .d79bf5aef0816574::placeholder {
10702
+ color: #999;
10703
+ }
10704
+ .a82c68467fbd9ba4 .ddce66c2730266a9 {
10705
+ display: flex;
10706
+ justify-content: flex-end;
10707
+ gap: 12px;
10708
+ padding: 16px 20px;
10709
+ border-top: 1px solid #e8e8e8;
10710
+ }
10711
+ .a82c68467fbd9ba4 .cbb043ea2499271a,
10712
+ .a82c68467fbd9ba4 .c55955936e93afa3 {
10713
+ padding: 8px 20px;
10714
+ border-radius: 4px;
10715
+ font-size: 14px;
10716
+ cursor: pointer;
10717
+ transition: all 0.2s;
10718
+ border: none;
10719
+ }
10720
+ .a82c68467fbd9ba4 .cbb043ea2499271a {
10721
+ background: #fff;
10722
+ color: #333;
10723
+ border: 1px solid #d9d9d9;
10724
+ }
10725
+ .a82c68467fbd9ba4 .cbb043ea2499271a:hover {
10726
+ border-color: #999;
10727
+ color: #666;
10728
+ }
10729
+ .a82c68467fbd9ba4 .c55955936e93afa3 {
10730
+ background: #b752ea;
10731
+ color: #fff;
10732
+ }
10733
+ .a82c68467fbd9ba4 .c55955936e93afa3:hover:not(:disabled) {
10734
+ background: #9d3ac2;
10735
+ }
10736
+ .a82c68467fbd9ba4 .c55955936e93afa3:disabled {
10737
+ background: #d9d9d9;
10738
+ color: #999;
10739
+ cursor: not-allowed;
10740
+ }
10741
+ /* Responsive styles */
10742
+ @media (max-width: 768px) {
10743
+ .a82c68467fbd9ba4 {
10744
+ width: 95%;
10745
+ max-width: 95%;
10746
+ }
10747
+ .dab8560c96fa0283 {
10748
+ flex-direction: column;
10749
+ }
10750
+ .d36e84632eb09d08 {
10751
+ width: 100%;
10752
+ }
10753
+ }
10754
+ `, ""]);
10755
+ // Exports
10756
+ ___CSS_LOADER_EXPORT___.locals = {
10757
+ "container": `ffe867e2c235a0c5`,
10758
+ "icon-selected": `d07fb38c947809f8`,
10759
+ "iconSelected": `d07fb38c947809f8`,
10760
+ "icon-button-selected": `d9418402ebdc6c0f`,
10761
+ "iconButtonSelected": `d9418402ebdc6c0f`,
10762
+ "feedback-overlay": `b29fb4268fffc847`,
10763
+ "feedbackOverlay": `b29fb4268fffc847`,
10764
+ "feedback-dialog": `a82c68467fbd9ba4`,
10765
+ "feedbackDialog": `a82c68467fbd9ba4`,
10766
+ "feedback-header": `fe9b5896dd607d27`,
10767
+ "feedbackHeader": `fe9b5896dd607d27`,
10768
+ "feedback-title": `f15e6e77acfff31a`,
10769
+ "feedbackTitle": `f15e6e77acfff31a`,
10770
+ "feedback-close": `ec213d35312b7d7e`,
10771
+ "feedbackClose": `ec213d35312b7d7e`,
10772
+ "feedback-content": `dc3fb716e09637a3`,
10773
+ "feedbackContent": `dc3fb716e09637a3`,
10774
+ "feedback-types": `dab8560c96fa0283`,
10775
+ "feedbackTypes": `dab8560c96fa0283`,
10776
+ "feedback-type-btn": `d36e84632eb09d08`,
10777
+ "feedbackTypeBtn": `d36e84632eb09d08`,
10778
+ "feedback-type-btn-selected": `b8dbe31e00feb69b`,
10779
+ "feedbackTypeBtnSelected": `b8dbe31e00feb69b`,
10780
+ "feedback-comment": `df277aeb58f67270`,
10781
+ "feedbackComment": `df277aeb58f67270`,
10782
+ "feedback-textarea": `d79bf5aef0816574`,
10783
+ "feedbackTextarea": `d79bf5aef0816574`,
10784
+ "feedback-footer": `ddce66c2730266a9`,
10785
+ "feedbackFooter": `ddce66c2730266a9`,
10786
+ "feedback-btn-cancel": `cbb043ea2499271a`,
10787
+ "feedbackBtnCancel": `cbb043ea2499271a`,
10788
+ "feedback-btn-confirm": `c55955936e93afa3`,
10789
+ "feedbackBtnConfirm": `c55955936e93afa3`
10790
+ };
10791
+ /* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
10792
+
10793
+
10550
10794
  }),
10551
10795
  58678: (function (module, __webpack_exports__, __webpack_require__) {
10552
10796
  __webpack_require__.d(__webpack_exports__, {
@@ -14475,9 +14719,6 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.coze-chat-sdk * {
14475
14719
  -webkit-font-smoothing: antialiased;
14476
14720
  -moz-osx-font-smoothing: grayscale;
14477
14721
  }
14478
- .coze-chat-sdk textarea {
14479
- padding: 0;
14480
- }
14481
14722
  .coze-chat-sdk a:focus,
14482
14723
  .coze-chat-sdk input:focus,
14483
14724
  .coze-chat-sdk p:focus,
@@ -120955,6 +121196,229 @@ const getApiUrl = function(customApiUrl) {
120955
121196
  return customApiUrl || chat_ApiUrl[env] || defaultApiUrl;
120956
121197
  };
120957
121198
 
121199
+ // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
121200
+ var react = __webpack_require__(12957);
121201
+ ;// CONCATENATED MODULE: ./src/util/webcomponent-adapter.tsx
121202
+ /*
121203
+ * Copyright 2025 coze-dev Authors
121204
+ *
121205
+ * Licensed under the Apache License, Version 2.0 (the "License");
121206
+ * you may not use this file except in compliance with the License.
121207
+ * You may obtain a copy of the License at
121208
+ *
121209
+ * http://www.apache.org/licenses/LICENSE-2.0
121210
+ *
121211
+ * Unless required by applicable law or agreed to in writing, software
121212
+ * distributed under the License is distributed on an "AS IS" BASIS,
121213
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121214
+ * See the License for the specific language governing permissions and
121215
+ * limitations under the License.
121216
+ */
121217
+
121218
+ /**
121219
+ * 组件包装器缓存
121220
+ * 改进:避免重复创建相同 tagName 的包装器组件
121221
+ */ const wrapperCache = new Map();
121222
+ /**
121223
+ * 将对象转换为 Web Component 的属性
121224
+ * 改进:处理 null、undefined、数组等特殊情况,添加错误处理
121225
+ */ function setWebComponentProps(element, props) {
121226
+ Object.entries(props).forEach((param)=>{
121227
+ let [key, value] = param;
121228
+ try {
121229
+ // 跳过 undefined
121230
+ if (value === undefined) {
121231
+ return;
121232
+ }
121233
+ // null 设置为空字符串
121234
+ if (value === null) {
121235
+ element.setAttribute(key, '');
121236
+ return;
121237
+ }
121238
+ // 复杂对象(包括数组)设置为属性
121239
+ if (typeof value === 'object' || Array.isArray(value)) {
121240
+ element[key] = value;
121241
+ } else if (typeof value === 'function') {
121242
+ // 函数类型设置为属性(事件处理器等)
121243
+ element[key] = value;
121244
+ } else {
121245
+ // 基本类型设置为 attribute
121246
+ element.setAttribute(key, String(value));
121247
+ }
121248
+ } catch (error) {
121249
+ console.warn(`[WebComponent] Failed to set property "${key}" on ${element.tagName}:`, error);
121250
+ }
121251
+ });
121252
+ }
121253
+ /**
121254
+ * 创建一个 React 组件包装器,用于渲染 Web Component
121255
+ * 改进:
121256
+ * 1. 使用 React.memo 避免不必要的重渲染
121257
+ * 2. 优化 props 比较,避免无限循环
121258
+ * 3. 添加清理逻辑,防止内存泄漏
121259
+ * 4. 添加缓存机制,提升性能
121260
+ */ function createWebComponentWrapper(tagName) {
121261
+ // 检查缓存
121262
+ const cachedWrapper = wrapperCache.get(tagName);
121263
+ if (cachedWrapper) {
121264
+ return cachedWrapper;
121265
+ }
121266
+ const WrapperComponent = /*#__PURE__*/ react.memo((props)=>{
121267
+ const elementRef = (0,react.useRef)(null);
121268
+ const propsRef = (0,react.useRef)(props);
121269
+ const cleanupRef = (0,react.useRef)(null);
121270
+ const isInitialMountRef = (0,react.useRef)(true);
121271
+ // 使用 useMemo 进行深度比较,避免每次都触发更新
121272
+ const propsChanged = (0,react.useMemo)(()=>{
121273
+ try {
121274
+ return JSON.stringify(propsRef.current) !== JSON.stringify(props);
121275
+ } catch (error) {
121276
+ // JSON.stringify 可能失败(循环引用等),降级为浅比较
121277
+ console.warn('[WebComponent] Failed to compare props:', error);
121278
+ return propsRef.current !== props;
121279
+ }
121280
+ }, [
121281
+ props
121282
+ ]);
121283
+ (0,react.useEffect)(()=>{
121284
+ // 首次挂载或 props 变化时,都需要调用 updateProps
121285
+ const shouldUpdate = isInitialMountRef.current || propsChanged && elementRef.current;
121286
+ if (shouldUpdate && elementRef.current) {
121287
+ if (isInitialMountRef.current) {
121288
+ isInitialMountRef.current = false;
121289
+ }
121290
+ propsRef.current = props;
121291
+ // 设置属性
121292
+ setWebComponentProps(elementRef.current, props);
121293
+ // 如果 Web Component 定义了更新方法,调用它
121294
+ const customElement = elementRef.current;
121295
+ if (typeof customElement.updateProps === 'function') {
121296
+ try {
121297
+ customElement.updateProps(props);
121298
+ } catch (error) {
121299
+ console.error(`[WebComponent] Error calling updateProps on ${tagName}:`, error);
121300
+ }
121301
+ }
121302
+ // 保存清理函数
121303
+ if (typeof customElement.cleanup === 'function') {
121304
+ cleanupRef.current = ()=>{
121305
+ try {
121306
+ var _customElement_cleanup;
121307
+ (_customElement_cleanup = customElement.cleanup) === null || _customElement_cleanup === void 0 ? void 0 : _customElement_cleanup.call(customElement);
121308
+ } catch (error) {
121309
+ console.error(`[WebComponent] Error during cleanup of ${tagName}:`, error);
121310
+ }
121311
+ };
121312
+ }
121313
+ }
121314
+ // 返回清理函数
121315
+ return ()=>{
121316
+ if (cleanupRef.current) {
121317
+ cleanupRef.current();
121318
+ cleanupRef.current = null;
121319
+ }
121320
+ };
121321
+ // tagName 是外部作用域的值,不需要作为依赖项
121322
+ }, [
121323
+ propsChanged,
121324
+ props
121325
+ ]);
121326
+ // 使用 React.createElement 创建自定义元素
121327
+ return /*#__PURE__*/ react.createElement(tagName, {
121328
+ ref: elementRef
121329
+ });
121330
+ }, // 自定义比较函数,使用深度比较
121331
+ (prevProps, nextProps)=>{
121332
+ try {
121333
+ return JSON.stringify(prevProps) === JSON.stringify(nextProps);
121334
+ } catch (error) {
121335
+ // JSON.stringify 可能失败(循环引用等),降级为浅比较
121336
+ console.warn('[WebComponent] Failed to compare props in memo:', error);
121337
+ return prevProps === nextProps;
121338
+ }
121339
+ });
121340
+ // 缓存组件(类型安全的 cast)
121341
+ wrapperCache.set(tagName, WrapperComponent);
121342
+ return WrapperComponent;
121343
+ }
121344
+ /**
121345
+ * 支持的 UIKit 组件类型
121346
+ * 改进:使用常量定义,便于扩展和维护
121347
+ * 与 UIKitCustomComponentsMap 保持对齐
121348
+ */ const SUPPORTED_COMPONENTS = [
121349
+ 'JsonItem',
121350
+ 'MentionOperateTool',
121351
+ 'SendButton',
121352
+ 'AvatarWrap'
121353
+ ];
121354
+ /**
121355
+ * 将 Web Component 配置转换为 React 组件映射
121356
+ * 改进:
121357
+ * 1. 使用循环处理,避免重复代码
121358
+ * 2. 添加错误处理
121359
+ * 3. 返回类型更明确
121360
+ */ function adaptWebComponentsToReact(webComponents) {
121361
+ if (!webComponents) {
121362
+ return undefined;
121363
+ }
121364
+ try {
121365
+ const reactComponents = {};
121366
+ // 动态处理所有支持的组件
121367
+ SUPPORTED_COMPONENTS.forEach((componentName)=>{
121368
+ const tagName = webComponents[componentName];
121369
+ if (tagName) {
121370
+ // 验证 Web Component 是否已注册
121371
+ if (!customElements.get(tagName)) {
121372
+ console.warn(`[WebChatClient] Web Component "${tagName}" for ${componentName} is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
121373
+ }
121374
+ // 创建包装器组件
121375
+ // 使用类型断言,因为每个组件的 props 类型不同
121376
+ reactComponents[componentName] = createWebComponentWrapper(tagName);
121377
+ }
121378
+ });
121379
+ return Object.keys(reactComponents).length > 0 ? reactComponents : undefined;
121380
+ } catch (error) {
121381
+ console.error('[WebChatClient] Failed to adapt Web Components:', error);
121382
+ return undefined;
121383
+ }
121384
+ }
121385
+ /**
121386
+ * 适配 contentBox Web Component
121387
+ * 改进:添加错误处理和类型安全
121388
+ */ function adaptContentBoxWebComponent(tagName) {
121389
+ if (!tagName) {
121390
+ return undefined;
121391
+ }
121392
+ try {
121393
+ // 验证 Web Component 是否已注册
121394
+ if (!customElements.get(tagName)) {
121395
+ console.warn(`[WebChatClient] Web Component "${tagName}" is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
121396
+ }
121397
+ return createWebComponentWrapper(tagName);
121398
+ } catch (error) {
121399
+ console.error(`[WebChatClient] Failed to adapt contentBox Web Component "${tagName}":`, error);
121400
+ return undefined;
121401
+ }
121402
+ }
121403
+ /**
121404
+ * 检查浏览器是否支持 Web Components
121405
+ */ function checkWebComponentsSupport() {
121406
+ const missing = [];
121407
+ if (!window.customElements) {
121408
+ missing.push('Custom Elements');
121409
+ }
121410
+ if (!('attachShadow' in Element.prototype)) {
121411
+ missing.push('Shadow DOM');
121412
+ }
121413
+ if (!('content' in document.createElement('template'))) {
121414
+ missing.push('HTML Templates');
121415
+ }
121416
+ return {
121417
+ supported: missing.length === 0,
121418
+ missing
121419
+ };
121420
+ }
121421
+
120958
121422
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/zustand@4.5.7_@types+react@18.2.37_immer@10.1.3_react@18.2.0/node_modules/zustand/esm/middleware.mjs
120959
121423
  const reduxImpl = (reducer, initial) => (set, _get, api) => {
120960
121424
  api.dispatch = (action) => {
@@ -121582,8 +122046,6 @@ var vanilla = (createState) => {
121582
122046
 
121583
122047
 
121584
122048
 
121585
- // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js
121586
- var react = __webpack_require__(12957);
121587
122049
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/use-sync-external-store@1.6.0_react@18.2.0/node_modules/use-sync-external-store/shim/with-selector.js
121588
122050
  var with_selector = __webpack_require__(28394);
121589
122051
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/zustand@4.5.7_@types+react@18.2.37_immer@10.1.3_react@18.2.0/node_modules/zustand/esm/index.mjs
@@ -132694,11 +133156,11 @@ function flatRest(func) {
132694
133156
  * _.pick(object, ['a', 'c']);
132695
133157
  * // => { 'a': 1, 'c': 3 }
132696
133158
  */
132697
- var pick_pick = _flatRest(function(object, paths) {
133159
+ var pick = _flatRest(function(object, paths) {
132698
133160
  return object == null ? {} : _basePick(object, paths);
132699
133161
  });
132700
133162
 
132701
- /* ESM default export */ const pick = (pick_pick);
133163
+ /* ESM default export */ const lodash_es_pick = (pick);
132702
133164
 
132703
133165
  ;// CONCATENATED MODULE: ../open-chat/src/types/open.ts
132704
133166
  /*
@@ -132754,12 +133216,12 @@ const getChatConfig = (chatClientId, cozeChatOption)=>{
132754
133216
  conversation_id: index_browser_nanoid(),
132755
133217
  extra,
132756
133218
  ui: {
132757
- base: pick((ui === null || ui === void 0 ? void 0 : ui.base) || {}, [
133219
+ base: lodash_es_pick((ui === null || ui === void 0 ? void 0 : ui.base) || {}, [
132758
133220
  'icon',
132759
133221
  'lang',
132760
133222
  'layout'
132761
133223
  ]),
132762
- chatBot: pick((ui === null || ui === void 0 ? void 0 : ui.chatBot) || {}, [
133224
+ chatBot: lodash_es_pick((ui === null || ui === void 0 ? void 0 : ui.chatBot) || {}, [
132763
133225
  'title',
132764
133226
  'uploadable',
132765
133227
  'isNeedClearContext',
@@ -132775,7 +133237,7 @@ const getChatConfig = (chatClientId, cozeChatOption)=>{
132775
133237
  conversations: ui === null || ui === void 0 ? void 0 : ui.conversations,
132776
133238
  showUserInfo: ui === null || ui === void 0 ? void 0 : ui.showUserInfo
132777
133239
  },
132778
- auth: pick(auth || {}, [
133240
+ auth: lodash_es_pick(auth || {}, [
132779
133241
  'type',
132780
133242
  'token'
132781
133243
  ]),
@@ -151772,7 +152234,7 @@ var CarouselIndicator_rest = undefined && undefined.__rest || function (s, e) {
151772
152234
 
151773
152235
 
151774
152236
 
151775
- class CarouselIndicator_CarouselIndicator extends react.PureComponent {
152237
+ class CarouselIndicator extends react.PureComponent {
151776
152238
  constructor() {
151777
152239
  super(...arguments);
151778
152240
  this.onIndicatorChange = activeIndex => {
@@ -151842,7 +152304,7 @@ class CarouselIndicator_CarouselIndicator extends react.PureComponent {
151842
152304
  }, getDataAttr(restProps)), indicatorContent);
151843
152305
  }
151844
152306
  }
151845
- CarouselIndicator_CarouselIndicator.propTypes = {
152307
+ CarouselIndicator.propTypes = {
151846
152308
  activeKey: (prop_types_default()).number,
151847
152309
  className: (prop_types_default()).string,
151848
152310
  position: prop_types_default().oneOf(carousel_constants_strings.POSITION_MAP),
@@ -151854,7 +152316,7 @@ CarouselIndicator_CarouselIndicator.propTypes = {
151854
152316
  type: prop_types_default().oneOf(carousel_constants_strings.TYPE_MAP),
151855
152317
  trigger: prop_types_default().oneOf(carousel_constants_strings.TRIGGER)
151856
152318
  };
151857
- /* ESM default export */ const CarouselIndicator = (CarouselIndicator_CarouselIndicator);
152319
+ /* ESM default export */ const carousel_CarouselIndicator = (CarouselIndicator);
151858
152320
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-icons@2.72.3_react@18.2.0/node_modules/@douyinfe/semi-icons/lib/es/icons/IconChevronLeft.js
151859
152321
 
151860
152322
 
@@ -152112,7 +152574,7 @@ class Carousel extends BaseComponent {
152112
152574
  if (showIndicator && children.length > 1) {
152113
152575
  return /*#__PURE__*/react.createElement("div", {
152114
152576
  className: carouselIndicatorCls
152115
- }, /*#__PURE__*/react.createElement(CarouselIndicator, {
152577
+ }, /*#__PURE__*/react.createElement(carousel_CarouselIndicator, {
152116
152578
  type: indicatorType,
152117
152579
  total: children.length,
152118
152580
  activeIndex: activeIndex,
@@ -197661,7 +198123,7 @@ const TableContext = /*#__PURE__*/react.createContext({
197661
198123
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-ui@2.72.3_react-dom@18.2.0_react@18.2.0/node_modules/@douyinfe/semi-ui/lib/es/table/TableContextProvider.js
197662
198124
 
197663
198125
 
197664
- const TableContextProvider = _ref => {
198126
+ const TableContextProvider_TableContextProvider = _ref => {
197665
198127
  let {
197666
198128
  children,
197667
198129
  anyColumnFixed,
@@ -197697,7 +198159,7 @@ const TableContextProvider = _ref => {
197697
198159
  value: tableContextValue
197698
198160
  }, children);
197699
198161
  };
197700
- /* ESM default export */ const table_TableContextProvider = (TableContextProvider);
198162
+ /* ESM default export */ const TableContextProvider = (TableContextProvider_TableContextProvider);
197701
198163
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-foundation@2.72.3/node_modules/@douyinfe/semi-foundation/lib/es/table/tableSelectionCellFoundation.js
197702
198164
 
197703
198165
  class TableSelectionCellFoundation extends foundation {
@@ -202198,7 +202660,7 @@ class Table_Table extends BaseComponent {
202198
202660
  "data-column-fixed": anyColumnFixed,
202199
202661
  style: wrapStyle,
202200
202662
  id: id
202201
- }, dataAttr), /*#__PURE__*/react.createElement(table_TableContextProvider, Object.assign({}, tableContextValue, {
202663
+ }, dataAttr), /*#__PURE__*/react.createElement(TableContextProvider, Object.assign({}, tableContextValue, {
202202
202664
  direction: props.direction
202203
202665
  }), /*#__PURE__*/react.createElement(es_spin, {
202204
202666
  spinning: loading,
@@ -223349,9 +223811,9 @@ var nativeIsBuffer = isBuffer_Buffer ? isBuffer_Buffer.isBuffer : undefined;
223349
223811
  * _.isBuffer(new Uint8Array(2));
223350
223812
  * // => false
223351
223813
  */
223352
- var isBuffer = nativeIsBuffer || lodash_es_stubFalse;
223814
+ var isBuffer_isBuffer = nativeIsBuffer || lodash_es_stubFalse;
223353
223815
 
223354
- /* ESM default export */ const lodash_es_isBuffer = (isBuffer);
223816
+ /* ESM default export */ const isBuffer = (isBuffer_isBuffer);
223355
223817
 
223356
223818
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isPlainObject.js
223357
223819
 
@@ -223552,9 +224014,9 @@ var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
223552
224014
  * _.isTypedArray([]);
223553
224015
  * // => false
223554
224016
  */
223555
- var isTypedArray_isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
224017
+ var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
223556
224018
 
223557
- /* ESM default export */ const isTypedArray = (isTypedArray_isTypedArray);
224019
+ /* ESM default export */ const lodash_es_isTypedArray = (isTypedArray);
223558
224020
 
223559
224021
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_safeGet.js
223560
224022
  /**
@@ -223668,8 +224130,8 @@ var _arrayLikeKeys_hasOwnProperty = _arrayLikeKeys_objectProto.hasOwnProperty;
223668
224130
  function arrayLikeKeys(value, inherited) {
223669
224131
  var isArr = lodash_es_isArray(value),
223670
224132
  isArg = !isArr && isArguments(value),
223671
- isBuff = !isArr && !isArg && lodash_es_isBuffer(value),
223672
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
224133
+ isBuff = !isArr && !isArg && isBuffer(value),
224134
+ isType = !isArr && !isArg && !isBuff && lodash_es_isTypedArray(value),
223673
224135
  skipIndexes = isArr || isArg || isBuff || isType,
223674
224136
  result = skipIndexes ? _baseTimes(value.length, String) : [],
223675
224137
  length = result.length;
@@ -223868,8 +224330,8 @@ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, sta
223868
224330
 
223869
224331
  if (isCommon) {
223870
224332
  var isArr = lodash_es_isArray(srcValue),
223871
- isBuff = !isArr && lodash_es_isBuffer(srcValue),
223872
- isTyped = !isArr && !isBuff && isTypedArray(srcValue);
224333
+ isBuff = !isArr && isBuffer(srcValue),
224334
+ isTyped = !isArr && !isBuff && lodash_es_isTypedArray(srcValue);
223873
224335
 
223874
224336
  newValue = srcValue;
223875
224337
  if (isArr || isBuff || isTyped) {
@@ -224144,14 +224606,14 @@ function useMemoizedFn_useMemoizedFn(fn) {
224144
224606
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useUpdate/index.js
224145
224607
 
224146
224608
 
224147
- var useUpdate = function () {
224609
+ var useUpdate_useUpdate = function () {
224148
224610
  var _a = __read((0,react.useState)({}), 2),
224149
224611
  setState = _a[1];
224150
224612
  return (0,react.useCallback)(function () {
224151
224613
  return setState({});
224152
224614
  }, []);
224153
224615
  };
224154
- /* ESM default export */ const es_useUpdate = (useUpdate);
224616
+ /* ESM default export */ const useUpdate = (useUpdate_useUpdate);
224155
224617
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useControllableValue/index.js
224156
224618
 
224157
224619
 
@@ -224187,7 +224649,7 @@ function useControllableValue_useControllableValue(props, options) {
224187
224649
  if (isControlled) {
224188
224650
  stateRef.current = value;
224189
224651
  }
224190
- var update = es_useUpdate();
224652
+ var update = useUpdate();
224191
224653
  function setState(v) {
224192
224654
  var args = [];
224193
224655
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -245505,8 +245967,8 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
245505
245967
  othIsObj = othTag == _baseIsEqualDeep_objectTag,
245506
245968
  isSameTag = objTag == othTag;
245507
245969
 
245508
- if (isSameTag && lodash_es_isBuffer(object)) {
245509
- if (!lodash_es_isBuffer(other)) {
245970
+ if (isSameTag && isBuffer(object)) {
245971
+ if (!isBuffer(other)) {
245510
245972
  return false;
245511
245973
  }
245512
245974
  objIsArr = true;
@@ -245514,7 +245976,7 @@ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
245514
245976
  }
245515
245977
  if (isSameTag && !objIsObj) {
245516
245978
  stack || (stack = new _Stack);
245517
- return (objIsArr || isTypedArray(object))
245979
+ return (objIsArr || lodash_es_isTypedArray(object))
245518
245980
  ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack)
245519
245981
  : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
245520
245982
  }
@@ -250762,7 +251224,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
250762
251224
  var tag = _getTag(value),
250763
251225
  isFunc = tag == _baseClone_funcTag || tag == _baseClone_genTag;
250764
251226
 
250765
- if (lodash_es_isBuffer(value)) {
251227
+ if (isBuffer(value)) {
250766
251228
  return _cloneBuffer(value, isDeep);
250767
251229
  }
250768
251230
  if (tag == _baseClone_objectTag || tag == _baseClone_argsTag || (isFunc && !object)) {
@@ -250989,12 +251451,12 @@ var omit_omit = _flatRest(function(object, paths) {
250989
251451
 
250990
251452
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useLatest/index.js
250991
251453
 
250992
- function useLatest(value) {
251454
+ function useLatest_useLatest(value) {
250993
251455
  var ref = (0,react.useRef)(value);
250994
251456
  ref.current = value;
250995
251457
  return ref;
250996
251458
  }
250997
- /* ESM default export */ const es_useLatest = (useLatest);
251459
+ /* ESM default export */ const useLatest = (useLatest_useLatest);
250998
251460
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useUnmount/index.js
250999
251461
 
251000
251462
 
@@ -251006,7 +251468,7 @@ var useUnmount_useUnmount = function (fn) {
251006
251468
  console.error("useUnmount expected parameter is a function, got ".concat(typeof fn));
251007
251469
  }
251008
251470
  }
251009
- var fnRef = es_useLatest(fn);
251471
+ var fnRef = useLatest(fn);
251010
251472
  (0,react.useEffect)(function () {
251011
251473
  return function () {
251012
251474
  fnRef.current();
@@ -251120,8 +251582,8 @@ var useLayoutEffectWithTarget_useEffectWithTarget = utils_createEffectWithTarget
251120
251582
 
251121
251583
 
251122
251584
 
251123
- var useIsomorphicLayoutEffectWithTarget_useIsomorphicLayoutEffectWithTarget = utils_isBrowser ? useLayoutEffectWithTarget : utils_useEffectWithTarget;
251124
- /* ESM default export */ const useIsomorphicLayoutEffectWithTarget = (useIsomorphicLayoutEffectWithTarget_useIsomorphicLayoutEffectWithTarget);
251585
+ var useIsomorphicLayoutEffectWithTarget = utils_isBrowser ? useLayoutEffectWithTarget : utils_useEffectWithTarget;
251586
+ /* ESM default export */ const utils_useIsomorphicLayoutEffectWithTarget = (useIsomorphicLayoutEffectWithTarget);
251125
251587
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useSize/index.js
251126
251588
 
251127
251589
 
@@ -251138,7 +251600,7 @@ function useSize(target) {
251138
251600
  }), 2),
251139
251601
  state = _a[0],
251140
251602
  setState = _a[1];
251141
- useIsomorphicLayoutEffectWithTarget(function () {
251603
+ utils_useIsomorphicLayoutEffectWithTarget(function () {
251142
251604
  var el = getTargetElement(target);
251143
251605
  if (!el) {
251144
251606
  return;
@@ -252842,7 +253304,7 @@ function withFormApi_withFormApi(Component) {
252842
253304
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@douyinfe+semi-ui@2.72.3_react-dom@18.2.0_react@18.2.0/node_modules/@douyinfe/semi-ui/lib/es/form/hoc/withFormState.js
252843
253305
 
252844
253306
 
252845
- function withFormState(Component) {
253307
+ function withFormState_withFormState(Component) {
252846
253308
  let WithStateCom = (props, ref) => {
252847
253309
  return /*#__PURE__*/react.createElement(FormStateContext.Consumer, null, formState => /*#__PURE__*/react.createElement(Component, Object.assign({
252848
253310
  formState: formState,
@@ -252852,7 +253314,7 @@ function withFormState(Component) {
252852
253314
  WithStateCom = /*#__PURE__*/(0,react.forwardRef)(WithStateCom);
252853
253315
  return WithStateCom;
252854
253316
  }
252855
- /* ESM default export */ const hoc_withFormState = (withFormState);
253317
+ /* ESM default export */ const withFormState = (withFormState_withFormState);
252856
253318
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/@coze-arch+coze-design@0.0.6-alpha.eec92c_@types+react@18.2.37_react-dom@18.2.0_react@18.2.0/node_modules/@coze-arch/coze-design/dist/esm/components/semi/index.mjs
252857
253319
 
252858
253320
 
@@ -252948,7 +253410,7 @@ var __webpack_exports__useFormApi = useFormApi;
252948
253410
  var __webpack_exports__useFormState = useFormState;
252949
253411
  var __webpack_exports__withField = hoc_withField;
252950
253412
  var __webpack_exports__withFormApi = withFormApi;
252951
- var __webpack_exports__withFormState = hoc_withFormState;
253413
+ var __webpack_exports__withFormState = withFormState;
252952
253414
 
252953
253415
 
252954
253416
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[9].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[9].use[2]!../../../../../common/temp/default/node_modules/.pnpm/@coze-arch+coze-design@0.0.6-alpha.eec92c_@types+react@18.2.37_react-dom@18.2.0_react@18.2.0/node_modules/@coze-arch/coze-design/dist/esm/components/table/index.css
@@ -253822,7 +254284,7 @@ var toFinite_INFINITY = 1 / 0,
253822
254284
  * _.toFinite('3.2');
253823
254285
  * // => 3.2
253824
254286
  */
253825
- function toFinite_toFinite(value) {
254287
+ function toFinite(value) {
253826
254288
  if (!value) {
253827
254289
  return value === 0 ? value : 0;
253828
254290
  }
@@ -253834,7 +254296,7 @@ function toFinite_toFinite(value) {
253834
254296
  return value === value ? value : 0;
253835
254297
  }
253836
254298
 
253837
- /* ESM default export */ const toFinite = (toFinite_toFinite);
254299
+ /* ESM default export */ const lodash_es_toFinite = (toFinite);
253838
254300
 
253839
254301
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createRange.js
253840
254302
 
@@ -253854,14 +254316,14 @@ function createRange(fromRight) {
253854
254316
  end = step = undefined;
253855
254317
  }
253856
254318
  // Ensure the sign of `-0` is preserved.
253857
- start = toFinite(start);
254319
+ start = lodash_es_toFinite(start);
253858
254320
  if (end === undefined) {
253859
254321
  end = start;
253860
254322
  start = 0;
253861
254323
  } else {
253862
- end = toFinite(end);
254324
+ end = lodash_es_toFinite(end);
253863
254325
  }
253864
- step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
254326
+ step = step === undefined ? (start < end ? 1 : -1) : lodash_es_toFinite(step);
253865
254327
  return _baseRange(start, end, step, fromRight);
253866
254328
  };
253867
254329
  }
@@ -259007,14 +259469,14 @@ var esm_webpack_exports_zhCN = __webpack_exports__zhCN;
259007
259469
 
259008
259470
 
259009
259471
 
259010
- function useThrottleFn(fn, options) {
259472
+ function useThrottleFn_useThrottleFn(fn, options) {
259011
259473
  var _a;
259012
259474
  if (isDev) {
259013
259475
  if (!utils_isFunction(fn)) {
259014
259476
  console.error("useThrottleFn expected parameter is a function, got ".concat(typeof fn));
259015
259477
  }
259016
259478
  }
259017
- var fnRef = es_useLatest(fn);
259479
+ var fnRef = useLatest(fn);
259018
259480
  var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1000;
259019
259481
  var throttled = (0,react.useMemo)(function () {
259020
259482
  return throttle_default()(function () {
@@ -259034,7 +259496,7 @@ function useThrottleFn(fn, options) {
259034
259496
  flush: throttled.flush
259035
259497
  };
259036
259498
  }
259037
- /* ESM default export */ const es_useThrottleFn = (useThrottleFn);
259499
+ /* ESM default export */ const useThrottleFn = (useThrottleFn_useThrottleFn);
259038
259500
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/components/chat/audio-record/audio-wave/utils.ts
259039
259501
  /*
259040
259502
  * Copyright 2025 coze-dev Authors
@@ -259249,7 +259711,7 @@ const AudioRecord = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
259249
259711
  let { isRecording, getVolume, isPointerMoveOut, layout, text } = param;
259250
259712
  const [volumeNumber, setVolumeNumber] = (0,react.useState)(0);
259251
259713
  const animationIdRef = (0,react.useRef)(null);
259252
- const { run, flush } = es_useThrottleFn(()=>{
259714
+ const { run, flush } = useThrottleFn(()=>{
259253
259715
  setVolumeNumber((getVolume === null || getVolume === void 0 ? void 0 : getVolume()) ?? 0);
259254
259716
  animationIdRef.current = requestAnimationFrame(run);
259255
259717
  }, {
@@ -260111,7 +260573,7 @@ const isIterable = (thing) => thing != null && lib_utils_isFunction(thing[utils_
260111
260573
  *
260112
260574
  * @returns {Error} The created error.
260113
260575
  */
260114
- function AxiosError(message, code, config, request, response) {
260576
+ function AxiosError_AxiosError(message, code, config, request, response) {
260115
260577
  Error.call(this);
260116
260578
 
260117
260579
  if (Error.captureStackTrace) {
@@ -260131,7 +260593,7 @@ function AxiosError(message, code, config, request, response) {
260131
260593
  }
260132
260594
  }
260133
260595
 
260134
- utils.inherits(AxiosError, Error, {
260596
+ utils.inherits(AxiosError_AxiosError, Error, {
260135
260597
  toJSON: function toJSON() {
260136
260598
  return {
260137
260599
  // Standard
@@ -260153,7 +260615,7 @@ utils.inherits(AxiosError, Error, {
260153
260615
  }
260154
260616
  });
260155
260617
 
260156
- const AxiosError_prototype = AxiosError.prototype;
260618
+ const AxiosError_prototype = AxiosError_AxiosError.prototype;
260157
260619
  const AxiosError_descriptors = {};
260158
260620
 
260159
260621
  [
@@ -260174,11 +260636,11 @@ const AxiosError_descriptors = {};
260174
260636
  AxiosError_descriptors[code] = {value: code};
260175
260637
  });
260176
260638
 
260177
- Object.defineProperties(AxiosError, AxiosError_descriptors);
260639
+ Object.defineProperties(AxiosError_AxiosError, AxiosError_descriptors);
260178
260640
  Object.defineProperty(AxiosError_prototype, 'isAxiosError', {value: true});
260179
260641
 
260180
260642
  // eslint-disable-next-line func-names
260181
- AxiosError.from = (error, code, config, request, response, customProps) => {
260643
+ AxiosError_AxiosError.from = (error, code, config, request, response, customProps) => {
260182
260644
  const axiosError = Object.create(AxiosError_prototype);
260183
260645
 
260184
260646
  utils.toFlatObject(error, axiosError, function filter(obj) {
@@ -260191,7 +260653,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
260191
260653
 
260192
260654
  // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
260193
260655
  const errCode = code == null && error ? error.code : code;
260194
- AxiosError.call(axiosError, msg, errCode, config, request, response);
260656
+ AxiosError_AxiosError.call(axiosError, msg, errCode, config, request, response);
260195
260657
 
260196
260658
  // Chain the original error on the standard field; non-enumerable to avoid JSON noise
260197
260659
  if (error && axiosError.cause == null) {
@@ -260205,7 +260667,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
260205
260667
  return axiosError;
260206
260668
  };
260207
260669
 
260208
- /* ESM default export */ const core_AxiosError = (AxiosError);
260670
+ /* ESM default export */ const AxiosError = (AxiosError_AxiosError);
260209
260671
 
260210
260672
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/axios@1.12.2_debug@4.3.3/node_modules/axios/lib/helpers/null.js
260211
260673
  // eslint-disable-next-line strict
@@ -260339,7 +260801,7 @@ function toFormData(obj, formData, options) {
260339
260801
  }
260340
260802
 
260341
260803
  if (!useBlob && utils.isBlob(value)) {
260342
- throw new core_AxiosError('Blob is not supported. Use a Buffer instead.');
260804
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
260343
260805
  }
260344
260806
 
260345
260807
  if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
@@ -260970,7 +261432,7 @@ const defaults_defaults = {
260970
261432
  } catch (e) {
260971
261433
  if (strictJSONParsing) {
260972
261434
  if (e.name === 'SyntaxError') {
260973
- throw core_AxiosError.from(e, core_AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
261435
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
260974
261436
  }
260975
261437
  throw e;
260976
261438
  }
@@ -261442,11 +261904,11 @@ function isCancel(value) {
261442
261904
  */
261443
261905
  function CanceledError(message, config, request) {
261444
261906
  // eslint-disable-next-line no-eq-null,eqeqeq
261445
- core_AxiosError.call(this, message == null ? 'canceled' : message, core_AxiosError.ERR_CANCELED, config, request);
261907
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
261446
261908
  this.name = 'CanceledError';
261447
261909
  }
261448
261910
 
261449
- utils.inherits(CanceledError, core_AxiosError, {
261911
+ utils.inherits(CanceledError, AxiosError, {
261450
261912
  __CANCEL__: true
261451
261913
  });
261452
261914
 
@@ -261471,9 +261933,9 @@ function settle_settle(resolve, reject, response) {
261471
261933
  if (!response.status || !validateStatus || validateStatus(response.status)) {
261472
261934
  resolve(response);
261473
261935
  } else {
261474
- reject(new core_AxiosError(
261936
+ reject(new AxiosError(
261475
261937
  'Request failed with status code ' + response.status,
261476
- [core_AxiosError.ERR_BAD_REQUEST, core_AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
261938
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
261477
261939
  response.config,
261478
261940
  response.request,
261479
261941
  response
@@ -262027,7 +262489,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
262027
262489
  return;
262028
262490
  }
262029
262491
 
262030
- reject(new core_AxiosError('Request aborted', core_AxiosError.ECONNABORTED, config, request));
262492
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
262031
262493
 
262032
262494
  // Clean up request
262033
262495
  request = null;
@@ -262039,7 +262501,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
262039
262501
  // (message may be empty; when present, surface it)
262040
262502
  // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
262041
262503
  const msg = event && event.message ? event.message : 'Network Error';
262042
- const err = new core_AxiosError(msg, core_AxiosError.ERR_NETWORK, config, request);
262504
+ const err = new AxiosError(msg, AxiosError.ERR_NETWORK, config, request);
262043
262505
  // attach the underlying event for consumers who want details
262044
262506
  err.event = event || null;
262045
262507
  reject(err);
@@ -262053,9 +262515,9 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
262053
262515
  if (_config.timeoutErrorMessage) {
262054
262516
  timeoutErrorMessage = _config.timeoutErrorMessage;
262055
262517
  }
262056
- reject(new core_AxiosError(
262518
+ reject(new AxiosError(
262057
262519
  timeoutErrorMessage,
262058
- transitional.clarifyTimeoutError ? core_AxiosError.ETIMEDOUT : core_AxiosError.ECONNABORTED,
262520
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
262059
262521
  config,
262060
262522
  request));
262061
262523
 
@@ -262119,7 +262581,7 @@ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
262119
262581
  const protocol = parseProtocol(_config.url);
262120
262582
 
262121
262583
  if (protocol && lib_platform.protocols.indexOf(protocol) === -1) {
262122
- reject(new core_AxiosError('Unsupported protocol ' + protocol + ':', core_AxiosError.ERR_BAD_REQUEST, config));
262584
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
262123
262585
  return;
262124
262586
  }
262125
262587
 
@@ -262147,13 +262609,13 @@ const composeSignals = (signals, timeout) => {
262147
262609
  aborted = true;
262148
262610
  unsubscribe();
262149
262611
  const err = reason instanceof Error ? reason : this.reason;
262150
- controller.abort(err instanceof core_AxiosError ? err : new cancel_CanceledError(err instanceof Error ? err.message : err));
262612
+ controller.abort(err instanceof AxiosError ? err : new cancel_CanceledError(err instanceof Error ? err.message : err));
262151
262613
  }
262152
262614
  }
262153
262615
 
262154
262616
  let timer = timeout && setTimeout(() => {
262155
262617
  timer = null;
262156
- onabort(new core_AxiosError(`timeout ${timeout} of ms exceeded`, core_AxiosError.ETIMEDOUT))
262618
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT))
262157
262619
  }, timeout)
262158
262620
 
262159
262621
  const unsubscribe = () => {
@@ -262352,7 +262814,7 @@ const fetch_factory = (env) => {
262352
262814
  return method.call(res);
262353
262815
  }
262354
262816
 
262355
- throw new core_AxiosError(`Response type '${type}' is not supported`, core_AxiosError.ERR_NOT_SUPPORT, config);
262817
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
262356
262818
  })
262357
262819
  });
262358
262820
  })());
@@ -262518,14 +262980,14 @@ const fetch_factory = (env) => {
262518
262980
 
262519
262981
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
262520
262982
  throw Object.assign(
262521
- new core_AxiosError('Network Error', core_AxiosError.ERR_NETWORK, config, request),
262983
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
262522
262984
  {
262523
262985
  cause: err.cause || err
262524
262986
  }
262525
262987
  )
262526
262988
  }
262527
262989
 
262528
- throw core_AxiosError.from(err, err && err.code, config, request);
262990
+ throw AxiosError.from(err, err && err.code, config, request);
262529
262991
  }
262530
262992
  }
262531
262993
  }
@@ -262608,7 +263070,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n
262608
263070
  adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
262609
263071
 
262610
263072
  if (adapter === undefined) {
262611
- throw new core_AxiosError(`Unknown adapter '${id}'`);
263073
+ throw new AxiosError(`Unknown adapter '${id}'`);
262612
263074
  }
262613
263075
  }
262614
263076
 
@@ -262630,7 +263092,7 @@ const isResolvedHandle = (adapter) => utils.isFunction(adapter) || adapter === n
262630
263092
  (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
262631
263093
  'as no adapter specified';
262632
263094
 
262633
- throw new core_AxiosError(
263095
+ throw new AxiosError(
262634
263096
  `There is no suitable adapter to dispatch the request ` + s,
262635
263097
  'ERR_NOT_SUPPORT'
262636
263098
  );
@@ -262760,9 +263222,9 @@ validator_validators.transitional = function transitional(validator, version, me
262760
263222
  // eslint-disable-next-line func-names
262761
263223
  return (value, opt, opts) => {
262762
263224
  if (validator === false) {
262763
- throw new core_AxiosError(
263225
+ throw new AxiosError(
262764
263226
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
262765
- core_AxiosError.ERR_DEPRECATED
263227
+ AxiosError.ERR_DEPRECATED
262766
263228
  );
262767
263229
  }
262768
263230
 
@@ -262801,7 +263263,7 @@ validator_validators.spelling = function spelling(correctSpelling) {
262801
263263
 
262802
263264
  function assertOptions(options, schema, allowUnknown) {
262803
263265
  if (typeof options !== 'object') {
262804
- throw new core_AxiosError('options must be an object', core_AxiosError.ERR_BAD_OPTION_VALUE);
263266
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
262805
263267
  }
262806
263268
  const keys = Object.keys(options);
262807
263269
  let i = keys.length;
@@ -262812,12 +263274,12 @@ function assertOptions(options, schema, allowUnknown) {
262812
263274
  const value = options[opt];
262813
263275
  const result = value === undefined || validator(value, opt, options);
262814
263276
  if (result !== true) {
262815
- throw new core_AxiosError('option ' + opt + ' must be ' + result, core_AxiosError.ERR_BAD_OPTION_VALUE);
263277
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
262816
263278
  }
262817
263279
  continue;
262818
263280
  }
262819
263281
  if (allowUnknown !== true) {
262820
- throw new core_AxiosError('Unknown option ' + opt, core_AxiosError.ERR_BAD_OPTION);
263282
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
262821
263283
  }
262822
263284
  }
262823
263285
  }
@@ -263385,7 +263847,7 @@ axios.VERSION = VERSION;
263385
263847
  axios.toFormData = helpers_toFormData;
263386
263848
 
263387
263849
  // Expose AxiosError class
263388
- axios.AxiosError = core_AxiosError;
263850
+ axios.AxiosError = AxiosError;
263389
263851
 
263390
263852
  // alias for CanceledError for backward compatibility
263391
263853
  axios.Cancel = axios.CanceledError;
@@ -263883,7 +264345,7 @@ function baseForOwn(object, iteratee) {
263883
264345
  * _.mapValues(users, 'age');
263884
264346
  * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
263885
264347
  */
263886
- function mapValues_mapValues(object, iteratee) {
264348
+ function mapValues(object, iteratee) {
263887
264349
  var result = {};
263888
264350
  iteratee = _baseIteratee(iteratee, 3);
263889
264351
 
@@ -263893,7 +264355,7 @@ function mapValues_mapValues(object, iteratee) {
263893
264355
  return result;
263894
264356
  }
263895
264357
 
263896
- /* ESM default export */ const mapValues = (mapValues_mapValues);
264358
+ /* ESM default export */ const lodash_es_mapValues = (mapValues);
263897
264359
 
263898
264360
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNil.js
263899
264361
  /**
@@ -264162,7 +264624,7 @@ class SlardarReportClient {
264162
264624
  message,
264163
264625
  eventName
264164
264626
  });
264165
- (_this_slardarInstance = (_this = this).slardarInstance) === null || _this_slardarInstance === void 0 ? void 0 : _this_slardarInstance.call(_this, 'captureException', error, lodash_es_omitBy(mapValues(resolvedMeta, (v)=>lodash_es_isString(v) ? v : safeJson.stringify(v)), lodash_es_isNil), reactInfo);
264627
+ (_this_slardarInstance = (_this = this).slardarInstance) === null || _this_slardarInstance === void 0 ? void 0 : _this_slardarInstance.call(_this, 'captureException', error, lodash_es_omitBy(lodash_es_mapValues(resolvedMeta, (v)=>lodash_es_isString(v) ? v : safeJson.stringify(v)), lodash_es_isNil), reactInfo);
264166
264628
  } else if (eventName) {
264167
264629
  var // Report an independent incident
264168
264630
  _this_slardarInstance1, _this1;
@@ -264290,7 +264752,7 @@ function isEmpty_isEmpty(value) {
264290
264752
  }
264291
264753
  if (lodash_es_isArrayLike(value) &&
264292
264754
  (lodash_es_isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
264293
- lodash_es_isBuffer(value) || isTypedArray(value) || isArguments(value))) {
264755
+ isBuffer(value) || lodash_es_isTypedArray(value) || isArguments(value))) {
264294
264756
  return !value.length;
264295
264757
  }
264296
264758
  var tag = _getTag(value);
@@ -265847,6 +266309,9 @@ axios_axiosInstance.interceptors.response.use((response)=>{
265847
266309
  axios_axiosInstance.interceptors.request.use(async (config)=>{
265848
266310
  var _config_method, _config_headers;
265849
266311
  const setHeader = (key, value)=>{
266312
+ if (!config.headers) {
266313
+ return;
266314
+ }
265850
266315
  if (typeof config.headers.set === 'function') {
265851
266316
  config.headers.set(key, value);
265852
266317
  } else {
@@ -265854,6 +266319,9 @@ axios_axiosInstance.interceptors.request.use(async (config)=>{
265854
266319
  }
265855
266320
  };
265856
266321
  const getHeader = (key)=>{
266322
+ if (!config.headers) {
266323
+ return undefined;
266324
+ }
265857
266325
  if (typeof config.headers.get === 'function') {
265858
266326
  return config.headers.get(key);
265859
266327
  }
@@ -266311,6 +266779,9 @@ const useApiErrorResponseHook = (response)=>{
266311
266779
  };
266312
266780
  const useCsrfRequestHook = (config)=>{
266313
266781
  var _config_method;
266782
+ if (!config.headers) {
266783
+ return config;
266784
+ }
266314
266785
  config.headers.set('x-requested-with', 'XMLHttpRequest');
266315
266786
  if (((_config_method = config.method) === null || _config_method === void 0 ? void 0 : _config_method.toLowerCase()) === 'post' && !config.headers.get('content-type')) {
266316
266787
  // The new CSRF protection requires all post requests to have this header.
@@ -269575,7 +270046,7 @@ class HttpChunk extends CustomEventEmitter {
269575
270046
  dataClump: fetchDataHelper,
269576
270047
  body: channelFetchInfo.body,
269577
270048
  // 将 headers 数组转换为 Headers 对象,因为 fetch API 需要 Headers 对象或普通对象
269578
- headers: new Headers(channelFetchInfo.headers),
270049
+ headers: new Headers(Array.isArray(channelFetchInfo.headers) ? channelFetchInfo.headers : []),
269579
270050
  method: channelFetchInfo.method,
269580
270051
  signal: fetchDataHelper.abortSignal.signal,
269581
270052
  totalFetchTimeout: fetchDataHelper.totalFetchTimeout,
@@ -272308,7 +272779,7 @@ function baseOrderBy(collection, iteratees, orders) {
272308
272779
  * _.sortBy(users, ['user', 'age']);
272309
272780
  * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]]
272310
272781
  */
272311
- var sortBy_sortBy = _baseRest(function(collection, iteratees) {
272782
+ var sortBy = _baseRest(function(collection, iteratees) {
272312
272783
  if (collection == null) {
272313
272784
  return [];
272314
272785
  }
@@ -272321,7 +272792,7 @@ var sortBy_sortBy = _baseRest(function(collection, iteratees) {
272321
272792
  return _baseOrderBy(collection, _baseFlatten(iteratees, 1), []);
272322
272793
  });
272323
272794
 
272324
- /* ESM default export */ const sortBy = (sortBy_sortBy);
272795
+ /* ESM default export */ const lodash_es_sortBy = (sortBy);
272325
272796
 
272326
272797
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createFind.js
272327
272798
 
@@ -272406,7 +272877,7 @@ function baseFindIndex(array, predicate, fromIndex, fromRight) {
272406
272877
  * // => 3
272407
272878
  */
272408
272879
  function toInteger_toInteger(value) {
272409
- var result = toFinite(value),
272880
+ var result = lodash_es_toFinite(value),
272410
272881
  remainder = result % 1;
272411
272882
 
272412
272883
  return result === result ? (remainder ? result - remainder : result) : 0;
@@ -272498,9 +272969,9 @@ function findLastIndex_findLastIndex(array, predicate, fromIndex) {
272498
272969
  * });
272499
272970
  * // => 3
272500
272971
  */
272501
- var findLast_findLast = _createFind(lodash_es_findLastIndex);
272972
+ var findLast = _createFind(lodash_es_findLastIndex);
272502
272973
 
272503
- /* ESM default export */ const findLast = (findLast_findLast);
272974
+ /* ESM default export */ const lodash_es_findLast = (findLast);
272504
272975
 
272505
272976
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/concat.js
272506
272977
 
@@ -295962,7 +296433,7 @@ function mathText(e){let t={}.singleDollarTextMath;return null==t&&(t=!0),{token
295962
296433
  * Copyright (c) 2020 Titus Wormer <tituswormer@gmail.com>
295963
296434
  * Licensed under the MIT License
295964
296435
  * https://github.com/micromark/micromark-extension-math
295965
- */const mathFlow={tokenize:tokenizeMathFenced,concrete:!0},all_in_one_index_nonLazyContinuation={tokenize:all_in_one_index_tokenizeNonLazyContinuation,partial:!0};function tokenizeMathFenced(e,t,n){const r=this,s=r.events[r.events.length-1],i=s&&s[1].type===types_types.linePrefix?s[2].sliceSerialize(s[1],!0).length:0;let a=0;return function(t){return default_ok(t===codes_codes.dollarSign,"expected `$`"),e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),o(t)};function o(t){return t===codes_codes.dollarSign?(e.consume(t),a++,o):a<2?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,l,types_types.whitespace)(t))}function l(t){return t===codes_codes.eof||markdownLineEnding(t)?u(t):(e.enter("mathFlowFenceMeta"),e.enter(types_types.chunkString,{contentType:constants.contentTypeString}),c(t))}function c(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit(types_types.chunkString),e.exit("mathFlowFenceMeta"),u(t)):t===codes_codes.dollarSign?n(t):(e.consume(t),c)}function u(n){return e.exit("mathFlowFence"),r.interrupt?t(n):e.attempt(all_in_one_index_nonLazyContinuation,d,h)(n)}function d(t){return e.attempt({tokenize:f,partial:!0},h,p)(t)}function p(t){return(i?factorySpace(e,m,types_types.linePrefix,i+1):m)(t)}function m(t){return t===codes_codes.eof?h(t):markdownLineEnding(t)?e.attempt(all_in_one_index_nonLazyContinuation,d,h)(t):(e.enter("mathFlowValue"),g(t))}function g(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit("mathFlowValue"),m(t)):(e.consume(t),g)}function h(n){return e.exit("mathFlow"),t(n)}function f(e,t,n){let s=0;return default_ok(r.parser.constructs.disable.null,"expected `disable.null`"),factorySpace(e,(function(t){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),i(t)}),types_types.linePrefix,r.parser.constructs.disable.null.includes("codeIndented")?void 0:constants.tabSize);function i(t){return t===codes_codes.dollarSign?(s++,e.consume(t),i):s<a?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,o,types_types.whitespace)(t))}function o(r){return r===codes_codes.eof||markdownLineEnding(r)?(e.exit("mathFlowFence"),t(r)):n(r)}}}function all_in_one_index_tokenizeNonLazyContinuation(e,t,n){const r=this;return function(n){if(null===n)return t(n);return default_ok(markdownLineEnding(n),"expected eol"),e.enter(types_types.lineEnding),e.consume(n),e.exit(types_types.lineEnding),s};function s(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const dollarSign=36;function all_in_one_index_math(e){return{flow:{[dollarSign]:mathFlow},text:{[dollarSign]:mathText()}}}const parseJSONWithNull=e=>{try{return e?JSON.parse(e):null}catch(e){return null}},getByIndex=(e,t)=>{if(!lodash_es_isUndefined(t))return null==e?void 0:e[t]};class AssertError extends Error{constructor(){super(...arguments),this.name="assert_error"}}const assert=(e,t)=>{if(!e){if(lodash_es_isError(t))throw t;throw new AssertError(t)}};let _isSafari;function all_in_one_index_isSafari(){return"undefined"!=typeof navigator&&(void 0===_isSafari&&(_isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),_isSafari)}const pipe=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),isNumeric=e=>{const t=e.replace(/,/g,"");return!isNaN(t)&&!isNaN(parseFloat(t))},firstMatch=(e,t)=>{for(const n of e){const e=t(n);if(e)return e}},timeoutPromise=e=>new Promise((t=>setTimeout(t,e))),elementAt=(e,t)=>e[t],splitStringByPattern=(e,t)=>{const n=[],{flags:r}=t,s=new RegExp(t.source,r.includes("g")?r:`${r}g`);let i,a=0;for(;i=s.exec(e);){const t=i[0];i.index>a&&n.push(e.slice(a,i.index)),n.push(t),a=i.index+t.length}return e.length>a&&n.push(e.slice(a,e.length)),n},safeParseUrl=e=>{try{return new URL(e)}catch(e){return null}},useCustomMemoValue=(e,t)=>{const n=(0,react.useRef)(e);return t(e,n.current)||(n.current=e),n.current},useDeepCompareMemo=(e,t)=>{const n=(0,react.useRef)();return!lodash_es_isUndefined(n.current)&&lodash_es_isEqual(n.current,t)||(n.current=t),(0,react.useMemo)(e,n.current)},useComputeValue=e=>e(),purifyHtml=(e,t)=>isomorphic_dompurify_browser.sanitize?isomorphic_dompurify_browser.sanitize(e,t):(console.error("[Calypso] Cannot load isomorphic-dompurify"),e),voidTags=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],transformSelfClosing=e=>e.replace(/<([\w\-]+)([^>/]*)\/\s*>/g,((e,t,n)=>voidTags.includes(t.toLowerCase())?e:`<${t}${n}></${t}>`)),retryAsync=async(e,{tryTimes:t=5,interval:n=100,fallback:r,onRetryError:s})=>{for(let i=0;i<t;i++){const a=i+1;try{return await e()}catch(e){if(a>=t){if(!lodash_es_isUndefined(r))return r;throw e}null==s||s(e,i)}const o="number"==typeof n?n:n(a);await timeoutPromise(o)}throw Error("retry times out of limit")},withRetry=(e,t)=>(...n)=>retryAsync((()=>e(...n)),t),resizeImage=({width:e,height:t,minHeight:n,minWidth:r,maxHeight:s,maxWidth:i})=>{const a={width:e,height:t},o=e/t,l=e=>{a.height=e,a.width=e*o},c=e=>{a.width=e,a.height=e/o};return a.width<r&&c(r),a.height<n&&l(n),a.width>i&&c(i),a.height>s&&l(s),(a.width<r||a.width>i||a.height<n||a.height>s)&&console.warn(`[Calypso] Image cannot be resized to the specified size: Natural size: {${e},${t}} Resized size: {${a.width},${a.height}} Min size: {${r},${n}} Max size: {${i},${s}}`),a},createShallowedProvider$1=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}};var LinkTermination=(e=>(e.Include="Include",e.Hard="Hard",e.Soft="Soft",e.Close="Close",e.Open="Open",e))(LinkTermination||{});const DEFAULT_CONFIG={characterMap:new Map,cjkIsHard:!0,hardPattern:/[\s\p{C}]/u,softPattern:/[.,!?;:'"。,!?;:]/u,pairedOpenerMap:new Map([[")","("],["]","["],["}","{"],[">","<"],["』","『"],["」","「"],["〉","〈"],["》","《"]])},CJK_PATTERN=/[\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/u;class UnicodeURLDetector{constructor(e={}){this.config={...DEFAULT_CONFIG,...e}}getLinkTermination(e){if(this.config.characterMap.has(e))return this.config.characterMap.get(e)??"Include";if(this.config.cjkIsHard&&CJK_PATTERN.test(e))return"Hard";if(this.config.pairedOpenerMap.has(e))return"Close";for(const t of this.config.pairedOpenerMap.values())if(e===t)return"Open";return this.config.hardPattern.test(e)?"Hard":this.config.softPattern.test(e)?"Soft":"Include"}getPairedOpener(e){return this.config.pairedOpenerMap.get(e)||null}detectLink(e,t=0){let n=t;const r=[];for(let s=t;s<e.length;s++){const t=e[s];switch(this.getLinkTermination(t)){case"Include":default:n=s+1;break;case"Soft":{let t=s+1;for(;t<e.length&&"Soft"===this.getLinkTermination(e[t]);)t++;if(t>=e.length||"Hard"===this.getLinkTermination(e[t]))return n;n=s+1;break}case"Hard":return n;case"Open":r.push(t),n=s+1;break;case"Close":{if(0===r.length)return n;const e=r.pop();if(this.getPairedOpener(t)!==e)return n;n=s+1;break}}}return n}findAllLinks(e){const t=[],n=[/https?:\/\/[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]+/gi,/(^|[^a-zA-Z0-9.-])(www\.[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]*)?)/gi,/(^|[^a-zA-Z0-9.-@])([a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF@]*)?)/gi];for(const r of n){let n=r.exec(e);for(;null!==n;){let s=n.index;if(n.length>2&&n[2]){if(s=n.index+(n[0].length-n[2].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(n.length>1&&n[1]&&n[1]!==n[0]){if(s=n.index+(n[0].length-n[1].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(s>0&&"@"===e[s-1]){n=r.exec(e);continue}const i=this.detectLink(e,s),a=e.substring(s,i);if(i>s&&this.isValidURL(a)){t.some((e=>s>=e.start&&s<e.end||i>e.start&&i<=e.end))||t.push({start:s,end:i,url:a})}n=r.exec(e)}}return t.sort(((e,t)=>e.start-t.start))}isValidURL(e){if(e.length<4)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return e.length>10;return/^[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}/.test(e)}}const defaultDetector=new UnicodeURLDetector;function createDetector(e){return new UnicodeURLDetector(e)}var HyperNodeType=(e=>(e[e.text=0]="text",e[e.link=1]="link",e))(HyperNodeType||{});const extractAutolinkDetector=createDetector({}),getHyperLinkNodes$1=e=>{const t=[],n=extractAutolinkDetector.findAllLinks(e);let r=0;for(const s of n){if(r<s.start){const n=e.slice(r,s.start);n&&t.push({type:0,text:n})}const n=e.slice(s.start,s.end);t.push({type:1,url:n}),r=s.end}if(r<e.length){const n=e.slice(r);n&&t.push({type:0,text:n})}return t},completeProtocol$1=e=>e.match(/https?:\/\//)?e:`https://${e}`,isValidEmail=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);class UnicodeHyperLinkParser{constructor(e={}){this.config={enableEmail:!1,autoAddProtocol:!0,...e},this.detector=e.characterMap||void 0!==e.cjkIsHard?createDetector(e):defaultDetector}findEmailAddresses(e){if(!this.config.enableEmail)return[];const t=[],n=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;let r=n.exec(e);for(;null!==r;){const s=r[0];isValidEmail(s)&&t.push({start:r.index,end:r.index+s.length,email:s}),r=n.exec(e)}return t}getHyperLinkNodes(e){const t=[],n=this.detector.findAllLinks(e),r=this.findEmailAddresses(e),s=[...n.map((e=>({...e,type:"link"}))),...r.map((e=>({...e,url:e.email,type:"email"})))].sort(((e,t)=>e.start-t.start));let i=0;for(const n of s){if(i<n.start){const r=e.slice(i,n.start);r&&t.push({type:HyperNodeType.text,text:r})}if("email"===n.type)t.push({type:HyperNodeType.text,text:n.url});else{const e=this.config.autoAddProtocol?completeProtocol$1(n.url):n.url;t.push({type:HyperNodeType.link,url:e})}i=n.end}if(i<e.length){const n=e.slice(i);n&&t.push({type:HyperNodeType.text,text:n})}return t}}const createUnicodeParser=e=>new UnicodeHyperLinkParser(e),defaultUnicodeParser=new UnicodeHyperLinkParser,getHyperLinkNodes=e=>defaultUnicodeParser.getHyperLinkNodes(e),escapeRegExp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),escapeChars=(e,t)=>{if(t.filter((e=>1!==e.length)).length)throw Error(`illegal chars length: ${t.join(", ")}`);return t.reduce(((e,t)=>{const n=new RegExp(String.raw`([^\\]|^)(${escapeRegExp(t)})`,"g");return e.replace(n,((e,t,n)=>`${t}\\${n}`))}),e)},escapeCharsInLatex=e=>escapeChars(e,["#"]),texPreProcessor=pipe(escapeCharsInLatex),texMathExtract=e=>{let t=0;if(36!==e.charCodeAt(t))return;let n="$";t+=1;const r=e.charCodeAt(t);if(36===r){if(n="$$",t+=1,36===e.charCodeAt(t))return}else if(32===r||9===r||10===r)return;const s=e.indexOf(n,t);if(-1===s)return;if(92===e.charCodeAt(s-1))return;const i=s+n.length;if(1===n.length){const t=e.charCodeAt(s-1);if(32===t||9===t||10===t)return;const n=e.charCodeAt(i);if(n>=48&&n<58)return}return{type:1===n.length?"inline":"block",mathText:e.slice(t,s),endIndex:i}},katexTryParseOptions={throwOnError:!0,strict:!0,output:"mathml",trust:!1},katexCheckTex=(e,t)=>{try{return e.renderToString(texPreProcessor(t),katexTryParseOptions),!0}catch(t){if(t instanceof e.ParseError)return!1;throw t}},katexParseErrorIndex=(e,t)=>{try{e.renderToString(texPreProcessor(t),katexTryParseOptions)}catch(t){if(t instanceof e.ParseError)return t.position}},customCheckTex=e=>![/\([^\)]*$/].some((t=>t.test(e))),checkTex=({tex:e,katex:t})=>katexCheckTex(t,e)&&customCheckTex(e),findMaxLegalPrefixEndIndex=({src:e,katex:t})=>{let n=katexParseErrorIndex(t,e)??e.length;for(;n>=0;){const r=e.slice(0,n);if(checkTex({tex:r,katex:t}))return n;n-=1}return n},INSERT_ELEMENT_SLOT_NAME="insert_element",getTextSlotString=e=>`{${e}}`,getInsertElementSlotString=({data:e,index:t,wrapWith:n=""})=>`${n}${getTextSlotString(`insert_element_${t}_${node_modules_buffer.Buffer.from(e).toString("base64")}`.replace(/_/g,"\\_"))}${n}`,insertElementSlotRegex=`\\{${"insert_element".replace(/_/g,"\\\\_")}\\\\_(?<index>[0-9]+)\\\\_(?<b64_data>.*?)\\}`,startOfInsertElementSlot=e=>{var t;return null==(t=new RegExp(insertElementSlotRegex).exec(e))?void 0:t.index},matchInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}`).exec(e);return null==t?void 0:t[0]},extractDataFromInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}$`).exec(e),{index:n,b64_data:r}=(null==t?void 0:t.groups)||{};if(!lodash_es_isUndefined(n)&&!lodash_es_isUndefined(r))return{index:parseInt(n),b64Text:r,text:r&&node_modules_buffer.Buffer.from(r,"base64").toString("utf8")}},convertToOperation=(e,t)=>{const n=[],r={inline:"",newline:"\n",block:"\n\n"};return t.forEach((({range:t,type:s="inline"},i)=>{const a=lodash_es_isNumber(t)?[t,t]:t,[o,l]=a;o>l||o>e.length||n.push({replaceRange:lodash_es_isNumber(t)?[t,t]:t,insert:getInsertElementSlotString({index:i,data:e.slice(...a),wrapWith:r[s]}),index:n.length})})),n},transformOperationInOrder=(e,t)=>{const[n,r]=e.replaceRange,[s,i]=t.replaceRange,a=t.insert.length-(i-s);if(n<s)return e;if(n===s&&e.index<t.index)return e;const o=Math.min(Math.max(0,i-n),r-n);return{...e,replaceRange:[n+a+o,r+a]}},transformEach=e=>{const t=[];for(let n=0;n<e.length;n+=1){let r=e[n];for(let e=0;e<t.length;e+=1)r=transformOperationInOrder(r,t[e]);t.push(r)}return t},applyOperationToString=(e,t)=>{const{replaceRange:[n,r],insert:s}=t;return`${e.slice(0,n)}${s}${e.slice(r)}`},applyInsertListToString=(e,t)=>{const n=transformEach(convertToOperation(e,t));return pipe(...n.map((e=>t=>applyOperationToString(t,e))))(e)},addInsertElementSlotToString=(e,t)=>applyInsertListToString(e,t),removeInsertElementSlotInString=e=>e.replace(new RegExp(insertElementSlotRegex,"g"),(e=>{const t=extractDataFromInsertElementSlot(e);return t?t.text:""})),INLINE_MATH_SPAN_DATA_TYPE="inline-math",BLOCK_MATH_SPAN_DATA_TYPE="block-math",renderSpanString=(e,t)=>`<span data-type="${e}" data-value="${node_modules_buffer.Buffer.from(t).toString("base64")}"></span>`,renderInlineMathSpanString=e=>renderSpanString("inline-math",texPreProcessor(removeInsertElementSlotInString(e))),renderBlockMathSpanString=e=>renderSpanString("block-math",texPreProcessor(removeInsertElementSlotInString(e))),restoreMathPandocLatex=e=>e.replace(new RegExp('<span data-type="inline-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\(${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\)`)).replace(new RegExp('<span data-type="block-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\[${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\]`)),parseMarkdown=(e,t={})=>fromMarkdown(e,{extensions:[all_in_one_index_math(),syntax_gfmTable,disableSetextHeading(),...t.enableIndentedCode?[]:[disableIndentedCode()],gfmStrikethrough({singleTilde:!1}),gfmTaskListItem],mdastExtensions:[mathFromMarkdown(),gfmTableFromMarkdown,gfmStrikethroughFromMarkdown,gfmTaskListItemFromMarkdown]}),stringifyMarkdown=(e,t=!1)=>{const n=toMarkdown(e,{extensions:[mathToMarkdown(),gfmTableToMarkdown(),gfmStrikethroughToMarkdown,gfmTaskListItemToMarkdown],resourceLink:!0,fences:!0});return t?n.trim():n},stringifyChildren=(e,t=!1)=>{if(!e.length)return"";const n=stringifyMarkdown({type:"root",children:e},!0);return t?n.replace(/\n/g,""):n},isParentOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),all_in_one_index_isParent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),isLiteralOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.value),all_in_one_index_isImage=e=>"image"===(null==e?void 0:e.type),isRoot=e=>"root"===(null==e?void 0:e.type),isTypeOfContent=(e,...t)=>t.some((t=>(null==e?void 0:e.type)===t)),isHeading=e=>isParentOfContent(e)&&"heading"===e.type,getTextOfAst=(e,t={})=>{const{filter:n}=t;return n&&!n(e)?"":isParentOfContent(e)?`${e.children.map((e=>getTextOfAst(e,t))).join("")}\n`:isLiteralOfContent(e)?e.value:""},DEFAULT_ENABLED_ROOT_TAGS=["span","u","br"],matchTagNameOfHtmlTag=e=>{var t,n;const r=[/<(?<tag>[a-zA-Z]+)(\s+([a-zA-Z]+=(("[^"]*")|('[^']*'))))*\s*\/?>/,/<\/(?<tag>[a-zA-Z]+)>/];for(const s of r){const r=s.exec(e);if(r)return null==(n=null==(t=r.groups)?void 0:t.tag)?void 0:n.toLowerCase()}},getTagNameOfHtml=e=>{var t;const n=matchTagNameOfHtmlTag(e);if("undefined"==typeof DOMParser)return n;const r=new DOMParser,s=elementAt([...r.parseFromString(e,"text/html").body.children],0);return(null==(t=null==s?void 0:s.tagName)?void 0:t.toLowerCase())||n},autoDisableHtmlTag=(e,t=[])=>{const n=getTagNameOfHtml(e);if(!0===t)return e;const r=[...DEFAULT_ENABLED_ROOT_TAGS,...t||[]];return n&&!r.includes(n)?he.encode(e,{strict:!1}):e},stringifyDomNode=e=>esm(e,{encodeEntities:!1,decodeEntities:!0}),INSERT_ELEMENT_SLOT_EXTENSION_NAME="insert_element_extension",insertElementSlotExtension=()=>({name:"insert_element_extension",level:"inline",start:e=>startOfInsertElementSlot(e),tokenizer(e){const t=matchInsertElementSlot(e);if(t)return{type:"insert_element_extension",raw:t}},renderer({raw:e}){if(!e)return!1;const t=extractDataFromInsertElementSlot(e);if(!t)return!1;const{index:n,b64Text:r}=t;return`<span data-index="${n}" data-raw="${r}" data-type="insert_element_extension"></span>`}}),inlineTex=()=>({name:"inlineTex",level:"inline",start(e){var t;return null==(t=/\$([^\$]|$)/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"inline"===n?{type:"inlineTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderInlineMathSpanString(e.mathText)}),displayTex=()=>({name:"displayTex",level:"block",start(e){var t;return null==(t=/\$\$[^\$]+\$\$/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"block"===n?{type:"displayTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderBlockMathSpanString(e.mathText)}),escapeTest=/[&<>"']/,escapeReplace=new RegExp(escapeTest.source,"g"),escapeTestNoEncode=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode=new RegExp(escapeTestNoEncode.source,"g"),all_in_one_index_escapeReplacements={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},escapeMarkdownText=(e,t=!1)=>{const n=e=>all_in_one_index_escapeReplacements[e];if(t){if(escapeTest.test(e))return e.replace(escapeReplace,n)}else if(escapeTestNoEncode.test(e))return e.replace(escapeReplaceNoEncode,n);return e},getCalypsoRenderer=(e={})=>{const{enabledHtmlTags:t}=e;return new class extends _Renderer{html({text:e}){return autoDisableHtmlTag(e,t)}code({text:e,lang:t="",escaped:n}){const r=t.match(/^\s*(?<language>\S+)\s*(?<meta>[\S\s]*?)\s*$/),s=`${e.replace(/\n$/,"")}\n`;if(!r)return`<pre><code>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`;const{groups:i={}}=r,{language:a,meta:o}=i;return`<pre><code type="test" class="language-${escapeMarkdownText(a)}"${o?` data-meta="${escapeMarkdownText(o)}"`:""}>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`}}(e)},gfmDelRegex=/^(~~)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/;class CalypsoTokenizer extends _Tokenizer{autolink(e){}del(e){const t=gfmDelRegex.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}url(){}}const getHopDiff=(e,t)=>{if(e.type!==t.type)return isParentOfContent(e)&&isParentOfContent(t)?{prevEndNode:e,endNode:t}:null;if(!lodash_es_isEqual(e.children.map((e=>e.type)),t.children.map((e=>e.type))))return{prevEndNode:elementAt(e.children,e.children.length-1),endNode:elementAt(t.children,t.children.length-1)};for(let n=0;n<e.children.length;n++){const r=e.children[n],s=t.children[n];if(all_in_one_index_isParent(r)&&all_in_one_index_isParent(s)){const e=getHopDiff(r,s);if(e)return e}else{if(all_in_one_index_isParent(r)||all_in_one_index_isParent(s))return{prevEndNode:r,endNode:s};if(r.type!==s.type)return{prevEndNode:r,endNode:s}}}return null},standardNodeTypeMapping={thematicBreak:"thematic",heading:"heading",code:"code_block",html:"html",linkReference:"link_def_ref",paragraph:"paragraph",table:"table",blockquote:"block_quote",list:"list",listItem:"list_item",inlineCode:"inline_code",emphasis:"emphasis",strong:"strong",link:"link",image:"image",delete:"strike_through",text:"text",math:"math_block",inlineMath:"inline_math"},convertToStanardNodeTypeEnum=e=>e?standardNodeTypeMapping[e]??"unknown":"empty",updateAst=(e,t,n={})=>{const{order:r="pre_order",isReverse:s=!1}=n;let i=!1,a=!1,o=!1;const l=[[[],e]],c=[];for(;l.length;){const e=l.pop();assert(e,"current must not be undefined");const[n,u]=e,d=lodash_es_head(n),p=all_in_one_index_isParent(u)?u.children.slice():[],m=s?p:p.reverse(),g=all_in_one_index_isParent(u)?m.map((e=>[[u,...n],e])):[],h=(e,t=!1)=>{if(!d)return;const n=d.children.findIndex((e=>e===u));assert(lodash_es_isNumber(n),"Invoke insertAfter error in updateAst: parent is not parent of current"),t?d.children.splice(n,1,...e):d.children.splice(n+1,0,...e)},f=()=>{if(o)throw Error("You have to call stop synchronously");i=!0},x=()=>{if(o)throw Error("You have to call skip synchronously");a=!0},y=()=>{const e=null==d?void 0:d.children.findIndex((e=>e===u));assert(-1!==e,"Current must be child of it's parent"),t(u,{stop:f,skip:x,insertAfter:h,parent:d,parents:n,index:e})};if("pre_order"===r)y(),a||l.push(...g);else if("post_order"===r){const t=g.filter((([,e])=>!c.includes(e)));t.length?(l.push(e),l.push(...t)):(y(),c.push(u))}else"in_order"===r&&(all_in_one_index_isParent(u)&&g.length&&g.every((([,e])=>!c.includes(e)))?(l.push(...g.slice(0,g.length-1)),l.push(e),l.push(g[g.length-1])):(y(),c.push(u)));if(i)break;i=!1,a=!1}o=!0};var AstPluginPriority=(e=>(e[e.BeforeAll=-2]="BeforeAll",e[e.Before=-1]="Before",e[e.Normal=0]="Normal",e[e.After=1]="After",e[e.AfterAll=2]="AfterAll",e))(AstPluginPriority||{});class BaseAstPlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const modifyByCurrentPlugin=({plugin:e,ast:t,skipWhenError:n=!0,...r})=>{const s=lodash_es_isFunction(e.modifier)?[e.modifier.bind(e)]:e.modifier.map((t=>t.bind(e)));e.before(t);for(const i of s){e.beforeEach(t);try{updateAst(t,((t,n)=>i(t,{...n,recursiveModifier(t){modifyByCurrentPlugin({plugin:e,ast:t,...r})},...r})),e.config)}catch(t){if(!n)throw t;console.error(`[Calypso source plugin error: ${e.name}]`,t)}e.afterEach(t)}e.after(t)},processAstByPlugins=({ast:e,plugins:t,fixEnding:n=!1,skipWhenError:r,...s})=>{const i=sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??AstPluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})),a=lodash_es_cloneDeep(e);for(const e of i)modifyByCurrentPlugin({plugin:e,ast:a,skipWhenError:r,...s});return a};var SourcePluginPriority=(e=>(e[e.BeforeAll=-1]="BeforeAll",e[e.Normal=0]="Normal",e[e.AfterAll=1]="AfterAll",e))(SourcePluginPriority||{});class BaseSourcePlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const processSourceByPlugins=({source:e,plugins:t,fixEnding:n=!1,katex:r,skipWhenError:s=!0})=>sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??SourcePluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})).reduce(((e,t)=>{t.before(e);const n=(lodash_es_isFunction(t.modifier)?[t.modifier.bind(t)]:t.modifier.map((e=>e.bind(t)))).reduce(((e,n)=>{try{t.beforeEach(e);const s=n({source:e,katex:r});return t.afterEach(s),s}catch(n){if(!s)throw n;return console.error(`[Calypso source plugin error: ${t.name}]`,n),e}}),e);return t.after(n),n}),e);class AutofixLastCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r,s;if(isLiteralOfContent(e))if(n(),"code"===e.type){const{content:n}=(null==(r=e.value.match(/^(?<content>[\S\s]*?)\n`+$/))?void 0:r.groups)||{};if(!lodash_es_isString(n))return;t([{...e,value:n}],!0)}else if("text"===e.type){const{prefix:n}=(null==(s=e.value.match(/^(?<prefix>[\s\S]*?)`{1,2}$/))?void 0:s.groups)||{};if(!lodash_es_isString(n))return;t(n?[{type:"text",value:n}]:[],!0)}}}}const getLastTextNodeByRegex=(e,t)=>{const n=findLast(e.children,(e=>Boolean("text"===e.type&&e.value.match(t))));if(!n)return;assert("text"===n.type,"lastUnPaired.type must be text");const r=e.children.findIndex((e=>e===n));return assert(r>=0,"lastUnPairedIndex must >= 0"),{target:n,index:r}},UNPAIRED_REGEX=/^(?<prefix>.*([^\\`]|^))`(?!`)(?<suffix>.*?)$/;class AutofixLastInlineCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_inline_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{stop:t})=>{var n;if(!all_in_one_index_isParent(e))return;t();const r=getLastTextNodeByRegex(e,UNPAIRED_REGEX);if(!r)return;const{target:s,index:i}=r;if(e.children.slice(i+1).find((e=>"inlineCode"===e.type)))return;const{prefix:a,suffix:o}=(null==(n=s.value.match(UNPAIRED_REGEX))?void 0:n.groups)||{};if(!lodash_es_isString(o)||!lodash_es_isString(a))return;const l=[];a&&l.push({type:"text",value:a});const c=`${o}${stringifyChildren(e.children.slice(i+1),!0)}`;c&&l.push({type:"inlineCode",value:c}),e.children.splice(i,e.children.length-i,...l)}}}const truncatedHtmlRegexList=[/<([a-zA-Z\-]+((\s+([a-zA-Z\-]+=(("[^"]*")|('[^']*'))))*(\s*\/?|(\s+[a-zA-Z\-]+(=(("[^"]*)|('[^']*))?)?)))?)?$/,/<\/([a-zA-Z\-]+)?$/],truncatedDataSlotRegexList=[/<data-(inline|block)(\s.*)?$/],truncateTruncatedHtmlSuffix=(e,t={})=>{const{looseTruncateDataSlot:n=!1}=t,r=firstMatch(lodash_es_concat(truncatedHtmlRegexList,n?truncatedDataSlotRegexList:[]),(t=>t.exec(e)));return r?e.slice(0,r.index):e};class AutofixTruncatedHtmlTagAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_html_tag",this.config={isReverse:!0},this.modifier=(e,{insertAfter:t,stop:n,looseTruncateDataSlot:r=!1})=>{if(!isTypeOfContent(e,"text","html"))return;n();const s=truncateTruncatedHtmlSuffix(e.value,{looseTruncateDataSlot:r});t(s?[{type:e.type,value:s}]:[],!0)}}}class AutofixTruncatedLinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_link",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(isTypeOfContent(e,"link"))return void n();if(all_in_one_index_isParent(e)||"text"!==e.type&&"html"!==e.type)return;n();const s=[/\[(?<text>\[[^\]\n]*)$/,/\[(?<text>\[[^\]\n]+\])$/,/\[(?<text>\[[^\]\n]+\])\]$/,/\[(?<text>\[[^\]\n]+\])\]\([^\)\n]*$/,/\[(?<text>[^\]\n]*)$/,/\[(?<text>[^\]\n]+)\]$/,/\[(?<text>[^\]\n]+)\]\([^\)\n]*$/].find((t=>t.exec(e.value)));if(!s)return;const i=s.exec(e.value);if(!i)return;const a=null==(r=i.groups)?void 0:r.text,o=i.index;t(a?[{type:e.type,value:e.value.slice(0,o)},{type:"link",title:null,url:"#",children:[{type:"text",value:a}]}]:[{type:e.type,value:e.value.slice(0,o)}],!0)}}}class AutofixTruncatedImageAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_image",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,removeTruncatedImage:r=!1})=>{var s;const i=[/!$/,/!\[$/,/!\[(?<text>[^\]]*)$/,/!\[(?<text>[^\]]*)\]$/,/!\[(?<text>[^\]]*)\]\([^\)]*$/],a=r?i:i.slice(0,1),o=r?[]:i.slice(1);if(!isLiteralOfContent(e))return;if(n(),"text"!==e.type)return;const l=o.find((t=>t.exec(e.value))),c=a.find((t=>t.exec(e.value)));if(!c&&!l)return;const u=c??l;if(!u)return;const d=u.exec(e.value);d&&t(lodash_es_concat({type:"text",value:e.value.slice(0,d.index)},l?{type:"image",url:"",alt:(null==(s=d.groups)?void 0:s.text)||"image"}:[]),!0)}}}class AutofixTruncatedEscapePlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_escape",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(all_in_one_index_isParent(e)||"text"!==e.type)return;n();const s=e.value.match(/^(?<text>[\s\S]*)\\$/);if(!s)return;t([{type:"text",value:(null==(r=s.groups)?void 0:r.text)??""}],!0)}}}const completeProtocol=e=>e.match(/https?:\/\//)?e:`https://${e}`;class ExtractCustomAutolinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,skip:n})=>{if(all_in_one_index_isParent(e))return void(isParentOfContent(e)&&"link"===e.type&&n());if("text"!==e.type)return;t(getHyperLinkNodes$1(e.value).map((e=>{if(e.type===HyperNodeType.link){const t=e;return{type:"link",url:completeProtocol(t.url),title:"autolink",children:[{type:"text",value:t.url}]}}if(e.type===HyperNodeType.text){return{type:"text",value:e.text}}return null})).filter((e=>Boolean(e))),!0)}}}const indicatorItem={type:"html",value:'<span class="indicator" />'};class InsertIndicatorAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_indicator",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{if(all_in_one_index_isImage(e))n();else{if(isParentOfContent(e)&&"listItem"===e.type&&!stringifyChildren(e.children,!0).trim())return n(),void t([{...e,children:[indicatorItem]}],!0);if(isLiteralOfContent(e)){if(n(),"code"===e.type)return;t([indicatorItem])}}}}}const mergeTextChildren=e=>{const{children:t}=e,n=[];let r="";for(let e=0;e<t.length;e++){const s=t[e];"text"===s.type&&(r+=s.value),"text"===s.type&&e!==t.length-1||(r&&n.push({type:"text",value:r}),r=""),"text"!==s.type&&n.push(s)}e.children=n};class AutoMergeSiblingTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.AfterAll},this.modifier=(e,{skip:t,recursiveModifier:n})=>{if(isParentOfContent(e)){mergeTextChildren(e),t();for(const t of e.children)all_in_one_index_isParent(t)&&n(t)}}}}const indexOfFirstLegalDollar=e=>{var t;const n=e.match(/(?<prefix>[^\$\\]|^)(\$|\$\$)(?!\$)/);if(!n)return-1;const{index:r=0}=n,s=null==(t=null==n?void 0:n.groups)?void 0:t.prefix;return lodash_es_isString(s)?r+s.length:-1},lengthOfDollorPrefix=e=>{const t=e.match(/^\$*/);return t?t[0].length:0},findStartIndexOfNoneTexSuffix=e=>{let t=indexOfFirstLegalDollar(e),n=0,r=!0;for(;-1!==t;){const s=texMathExtract(e.slice(t));if(s){const{endIndex:e}=s;t+=e,r=!1,n=t}else{const n=indexOfFirstLegalDollar(e.slice(t));if(-1===n)break;t+=r?Math.max(n,lengthOfDollorPrefix(e.slice(t))):n,r=!0}}return n},RAW_NUMBER_REST_STRING_LENGTH_THRESHOLD=10,enSentenceRegexFullMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]$/,enSentenceRegexWithCountOfPrefixMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]{15}/,unpairedLongMathRegex=/^\s*(\\begin)/,shouldStopAutofix=(e,t)=>{const n=e.trim(),r=n.slice(0,t),s=n.length;return!unpairedLongMathRegex.exec(n)&&(!r||isNumeric(r)?s-t>10:!!(enSentenceRegexFullMatch.exec(r)&&s-t>10)||!!enSentenceRegexWithCountOfPrefixMatch.exec(r))};class AutofixTruncatedTexMathDollarAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_tex_math_dollar",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,katex:r})=>{if(r&&!all_in_one_index_isParent(e))if(isLiteralOfContent(e)&&n(),"text"===e.type){const n=findStartIndexOfNoneTexSuffix(e.value),s=e.value.slice(n).match(/^(?<prefix>[\s\S]*?([^\$\\]|^))(?<inter>\$|\$\$)(?!\$)(?<value>[^\$]*?)(?<suffix>\$*)$/),i=null==s?void 0:s.groups;if(!i)return;const{prefix:a,value:o}=i,l=findMaxLegalPrefixEndIndex({src:o,katex:r});if(shouldStopAutofix(o,l))return;const c=o.slice(0,l).trim(),u=`${e.value.slice(0,n)}${a}`;t(lodash_es_concat(u?{type:"text",value:u}:[],c?{type:"inlineMath",value:c}:[]),!0)}else if("inlineMath"===e.type||"math"===e.type){const n="math"===e.type?e.meta??e.value:e.value,s=findMaxLegalPrefixEndIndex({src:n,katex:r});if(shouldStopAutofix(n,s)){return void t(["inlineMath"===e.type?{type:"text",value:`$${n}$`}:{type:"paragraph",children:[{type:"text",value:`$$${n}$$`}]}],!0)}const i=n.slice(0,s).trim(),a="inlineMath"===e.type?{type:"inlineMath",value:i}:{type:"paragraph",children:[{type:"inlineMath",value:i}]};t(i?[a]:[],!0)}}}}class AutofixHeadingAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_heading",this.config={order:"pre_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{all_in_one_index_isParent(e)?isHeading(e)&&(1!==e.depth||stringifyChildren(e.children).trim()||t([],!0),n()):n()}}}const all_in_one_index_ellipsisContent="...";class InsertEllipsisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_ellipsis",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{isParentOfContent(e)&&!isTypeOfContent(e,"link")||(n(),isTypeOfContent(e,"text")&&t([{type:"text",value:`${e.value}...`}],!0),isTypeOfContent(e,"link","inlineCode")&&t([{type:"text",value:"..."}],!1))}}}class RemoveBreakBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_break_before_html",this.modifier=(e,{parent:t,index:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!t||lodash_es_isUndefined(n))return;const r=getByIndex(null==t?void 0:t.children,n-1);r&&"break"===r.type&&t.children.splice(n-1,1)}}}class TransformEndlineBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="transform_endline_before_html",this.config={order:"pre_order"},this.modifier=(e,{index:t,parent:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!n||!t)return;const r=n.children[t-1];if("text"!==r.type)return;const s=/(\r?\n|\r)$/;s.test(r.value)&&n.children.splice(t-1,1,{type:"text",value:r.value.replace(s,"")},{type:"html",value:"<br />"})}}}class DisableIllegalHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="disable_illegal_html",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t,enabledHtmlTags:n})=>{isLiteralOfContent(e)&&"html"===e.type&&t([{type:"html",value:autoDisableHtmlTag(e.value,n)}],!0)}}}class RestoreMathPandocLatexInContentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="restore_math_pandoc_latex_in_content",this.config={order:"pre_order"},this.modifier=(e,{insertAfter:t})=>{isLiteralOfContent(e)&&isTypeOfContent(e,"code","inlineCode","math","inlineMath")&&t([{...e,value:restoreMathPandocLatex(e.value)}],!0)}}}const autoSpacingGroupPatterns=[String.raw`\{${"insert_element"}_[0-9]+_.*?\}`];class AutoSpacingAllTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="auto_spacing_all_text",this.config={priority:AstPluginPriority.AfterAll,order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t})=>{if(!isTypeOfContent(e,"text"))return;const{value:n}=e;t([{type:"text",value:splitStringByPattern(n,new RegExp(`(${autoSpacingGroupPatterns.map((e=>`(${e})`)).join("|")})`,"g")).map((e=>pangu.spacing(e))).join("")}],!0)}}}class AutofixTruncatedStrongAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_strong",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,parent:r})=>{var s;if(!isTypeOfContent(e,"text")||!r||!isTypeOfContent(r,"paragraph"))return void n();const i=null==(s=e.value.match(/^(?<prefix>[\s\S]*?)(_{2}|\*{2})(?<suffix>[\s\S]*?)\*?$/))?void 0:s.groups;if(!i)return;const{prefix:a,suffix:o}=i,l=[];a&&l.push({type:"text",value:a}),o&&l.push({type:"strong",children:[{type:"text",value:o}]}),t(l,!0)},(e,{stop:t,parent:n,index:r})=>{if(!isParentOfContent(e))return;if(!isTypeOfContent(e,"emphasis")||!n||lodash_es_isUndefined(r))return void t();const s=n.children[r-1];if(!s||!isTypeOfContent(s,"text"))return void t();const i=/(?<prefix>(.*[^\*])|^)\*$/.exec(s.value);if(!i)return void t();const{prefix:a}=i.groups??{},o=[];a&&o.push({type:"text",value:a}),o.push({type:"strong",children:e.children}),n.children.splice(r-1,2,...o)},(e,{stop:t,insertAfter:n})=>{if(isParentOfContent(e)&&"listItem"!==e.type){if("list"===e.type)return!e.children.length||1===e.children.length&&!e.children[0].children.length?(n([],!0),void t()):void 0;t()}}]}}const splitByLastSingleAsterisk=e=>{if(e.includes("*"))for(let t=e.length-1;t>=0;t--){const n=e[t],r=e[t-1],s=e[t+1];if("*"===n&&"*"!==r&&"*"!==s)return[e.slice(0,t),e.slice(t+1)]}};class AutofixTruncatedEmphasisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_emphasis",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,parent:r})=>{if(isLiteralOfContent(e)&&r&&isTypeOfContent(r,"paragraph")){if("text"===e.type){const n=splitByLastSingleAsterisk(e.value);if(!n)return;const[r,s]=n,i=[];r&&i.push({type:"text",value:r}),s&&i.push({type:"emphasis",children:[{type:"text",value:s}]}),t(i,!0)}}else n()}}}class AutofixTruncatedListAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_list",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,index:r,parent:s})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(lodash_es_isUndefined(r)||0!==r||!s||s.children.length>1)return void n();const i=/^(?<prefix>.*)\n\s*(?<value>([0-9]+?\.?)|(\-\s*))$/.exec(e.value);if(i){const{prefix:e}=i.groups??{};t([{type:"text",value:e}],!0)}else/^\s*[0-9]+$/.exec(e.value)&&t([],!0);n()},(e,{insertAfter:t,stop:n,index:r,parent:s,parents:i})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"list","listItem","paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(!(s&&isTypeOfContent(i[0],"paragraph")&&isTypeOfContent(i[1],"listItem")&&isTypeOfContent(i[2],"list")))return void n();if(r!==s.children.length-1)return void n();const a=/^(?<prefix>.*)\n\s*(?<value>[0-9]+?)$/.exec(e.value);if(a){const{prefix:e}=a.groups??{};t([{type:"text",value:e}],!0)}n()}]}}class SetEmphasisAsImageTitleAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_emphasis_as_image_title",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{parent:t,index:n})=>{if(!t||lodash_es_isUndefined(n)||!all_in_one_index_isImage(e))return;const r=getByIndex(t.children,n+1),s=getByIndex(t.children,n+2);if(!r||!s)return;if(!isTypeOfContent(r,"text")||"\n"!==r.value)return;if(!isTypeOfContent(s,"emphasis"))return;const{children:i}=s,{url:a}=e,o=stringifyChildren(i,!0);t.children.splice(n,3,{type:"image",url:a,alt:o})}}}const getStartIndexOfCodeBlockFirstLine=e=>{var t;const n=e.match(/^(?<prefix>[\s]+)```/);return n?(null==(t=n.groups)?void 0:t.prefix.length)??null:null};class SetCodeBlockIndentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_code_block_indent",this.modifier=(e,{source:t,parent:n,insertAfter:r,skip:s})=>{if(all_in_one_index_isParent(e)&&n)return void s();if(!isLiteralOfContent(e))return;if("code"!==e.type)return;const{start:i}=e.position??{};if(!i)return;const{line:a}=i,o=getByIndex(t.split("\n"),a-1),{meta:l,lang:c}=e;if(lodash_es_isUndefined(o))return;const u=getStartIndexOfCodeBlockFirstLine(o);if(null===u)return;const d=`__indent=${u}`,p=l?`${d} ${l}`:d;r([{...e,meta:p,lang:c??"plaintext"}],!0)}}}class RemoveLastEmptyCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_last_empty_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{if(!isLiteralOfContent(e))return;if(n(),"code"!==e.type)return;const{value:r,lang:s,meta:i}=e;r||s||i||t([],!0)}}}class CompleteTruncatedLinkSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_truncated_link",this.modifier=({source:e})=>e.replace(/(^|[^!])\[(?<text>[^\]\n]+)\]\([^\)\n]*$/,"$1[$2](#)")}}class CompleteUnpairedCodeBlockSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_unpaired_code_block",this.modifier=({source:e})=>{const t=e.match(/(^|\n)[\s]*?```/g);return t?t.length%2==0?e:`${e.trimEnd()}\n\`\`\``:e}}}class ConvertFullMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_full_math_pandoc_latex",this.modifier=({source:e})=>e.replace(/\\\(([\s\S]*?)\\\)/g,((e,t)=>renderInlineMathSpanString(t))).replace(/\\\[([\s\S]*?)\\\]/g,((e,t)=>renderBlockMathSpanString(t)))}}class ConvertEndingMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_ending_math_pandoc_latex",this.config={fixEndingOnly:!0},this.modifier=[({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\((?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\()|(\\\)))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderInlineMathSpanString(i)}`:s},({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\[(?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\[)|(\\\]))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderBlockMathSpanString(i)}`:s}]}}class RemoveLongSpacesSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="remove_long_spaces",this.modifier=({source:e})=>e.replace(/[ ]{500,}/g,(e=>e.slice(0,500)))}}const getAstPlugins=({astPlugins:e,autoSpacing:t=!0,autolink:n=!0,imageEmphasisTitle:r=!1,indentFencedCode:s=!0,showIndicator:i=!1,showEllipsis:a=!1})=>{let o=[new AutofixTruncatedEscapePlugin,new RemoveLastEmptyCodeBlockAstPlugin,new AutofixLastCodeBlockAstPlugin,new AutofixLastInlineCodeBlockAstPlugin,new AutofixTruncatedTexMathDollarAstPlugin,new AutofixTruncatedImageAstPlugin,new AutofixTruncatedLinkAstPlugin,new AutofixHeadingAstPlugin,new AutofixTruncatedHtmlTagAstPlugin,new AutofixTruncatedStrongAstPlugin,new AutofixTruncatedEmphasisAstPlugin,new AutofixTruncatedListAstPlugin,new RestoreMathPandocLatexInContentAstPlugin,new DisableIllegalHtmlAstPlugin,new RemoveBreakBeforeHtmlAstPlugin,new TransformEndlineBeforeHtmlAstPlugin,new AutoMergeSiblingTextAstPlugin];return n&&o.push(new ExtractCustomAutolinkAstPlugin),t&&o.push(new AutoSpacingAllTextAstPlugin),r&&o.push(new SetEmphasisAsImageTitleAstPlugin),s&&o.push(new SetCodeBlockIndentAstPlugin),a&&o.push(new InsertEllipsisAstPlugin),i&&o.push(new InsertIndicatorAstPlugin),lodash_es_isArray(e)&&o.push(...e),lodash_es_isFunction(e)&&(o=e(o)),o},getSourcePlugins=({sourcePlugins:e})=>{let t=[new RemoveLongSpacesSourcePlugin,new CompleteUnpairedCodeBlockSourcePlugin,new CompleteTruncatedLinkSourcePlugin,new ConvertFullMathPandocLatexSourcePlugin,new ConvertEndingMathPandocLatexSourcePlugin];return lodash_es_isArray(e)&&t.push(...e),lodash_es_isFunction(e)&&(t=e(t)),t},parseMarkdownAndProcessByPlugins=({source:e,astPlugins:t,sourcePlugins:n,parseAst:r=!0,indentedCode:s=!1,insertedElements:i,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})=>{try{let d,p=e;return i&&(p=addInsertElementSlotToString(p,i)),n&&(p=processSourceByPlugins({source:p,plugins:n,fixEnding:a,katex:u})),r&&(d=parseMarkdown(p,{enableIndentedCode:s})),t&&d&&(d=processAstByPlugins({ast:d,plugins:t,source:p,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})),{ast:d,source:d?stringifyMarkdown(d):p}}catch(t){return console.error("[Calypso] Process markdown error: ",t),{source:e}}},parseMarkdownAndProcess=({source:e,processAst:t=!0,processSource:n=!0,showEllipsis:r,showIndicator:s,imageEmphasisTitle:i,indentFencedCode:a,indentedCode:o=!1,insertedElements:l,autolink:c,autoSpacing:u,astPlugins:d,sourcePlugins:p,fixEnding:m=!1,enabledHtmlTags:g=!1,looseTruncateDataSlot:h=!1,removeTruncatedImage:f=!1,katex:x})=>{const y=getAstPlugins({autolink:c,autoSpacing:u,imageEmphasisTitle:i,indentFencedCode:a,showEllipsis:r,showIndicator:s,astPlugins:d}),k=getSourcePlugins({sourcePlugins:p});return parseMarkdownAndProcessByPlugins({source:e,astPlugins:t?y:void 0,sourcePlugins:n?k:void 0,parseAst:t,indentedCode:o,insertedElements:l,fixEnding:m,enabledHtmlTags:g,looseTruncateDataSlot:h,removeTruncatedImage:f,katex:x})},useProcessMarkdown=e=>{const{insertedElements:t}=e,n=lodash_es_values(lodash_es_omit(e,["insertedElements","astPlugins","sourcePlugins"]));return (0,react.useMemo)((()=>parseMarkdownAndProcess(e)),[...n,null==t?void 0:t.length])},useEstablished=e=>{const t=(0,react.useRef)(e);return t.current=t.current||e,t.current},usePreviousRef=e=>{const t=(0,react.useRef)(),n=(0,react.useRef)(e);return n.current!==e&&(t.current=n.current,n.current=e),t},useForceUpdate=()=>{const[,e]=(0,react.useReducer)((e=>e+1),0);return e};function useLatestFunction(e){const t=es_useLatest(e),n=(0,react.useCallback)(((...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[]);return e&&n}const INITIAL_SPEED=.02,EXPECTED_BUFFER_SIZE=15,ELASTIC_COEFFICIENT=1/700/1e3,TICK_DURATION=1e3/60*2,findCommonPrefixLength=(e,t)=>{let n=0,r=Math.max(e.length,t.length);for(;n!==r&&n!==r-1;){const s=Math.floor((n+r)/2);e.slice(0,s)===t.slice(0,s)?n=s:r=s}return n},useSmoothText=(e,t={})=>{const{maxFirstTextSmoothSize:n,trailingSmooth:r,enable:s,pause:i,onSmoothFinished:a,onUpdate:o,onTextBreak:l,maxSpeed:c,expectedBufferSize:u,elasticCoefficient:d,tickDuration:p,initialSpeed:m,breakMode:g}=lodash_es_defaults(lodash_es_isBoolean(t)?{}:{...t},{maxFirstTextSmoothSize:1/0,trailingSmooth:!1,pause:!1,enable:Boolean(t),expectedBufferSize:15,elasticCoefficient:ELASTIC_COEFFICIENT,tickDuration:TICK_DURATION,initialSpeed:.02,breakMode:"prefix"}),h=lodash_es_isNumber(c)&&c>0?c:1/0,f=usePreviousRef(e),x=(0,react.useRef)(e.length<=n?1:e.length),y=(0,react.useRef)(x.current),k=useEstablished(s),T=s||k&&r&&x.current<e.length,[C,v]=(0,react.useState)(!1),E=(0,react.useRef)(m),P=()=>lodash_es_isString(f.current)&&!e.startsWith(f.current);if(P()){let t=0;"start"===g?t=0:"end"===g?t=Math.max(e.length-1,0):"prefix"===g&&(t=Math.max(1,findCommonPrefixLength(f.current??"",e))),x.current=t,y.current=Math.floor(x.current)}const S=y.current,w=T&&!C?e.slice(0,S):e,_=useForceUpdate(),b=e=>{e!==y.current&&(y.current=e,_())},A=useLatestFunction((()=>{v(!0)}));return (0,react.useEffect)((()=>{C&&(b(e.length),v(!1),x.current=e.length)}),[C]),(0,react.useEffect)((()=>{T||null==a||a()}),[T]),es_useInterval((()=>{if(P())null==l||l({prevText:f.current??"",currentText:e}),E.current=m,f.current=void 0;else{const t=Math.max(e.length+(!s&&r?2*u:0),2*u)-x.current,n=d*(t-u);E.current=Math.min(Math.max(0,E.current+p*n),h/1e3);const i=p*E.current;x.current=Math.min(e.length,x.current+i),b(Math.floor(x.current))}}),T&&!i?p:void 0),(0,react.useEffect)((()=>{null==o||o({text:w,speed:1e3*E.current})}),[S]),{text:w,flushCursor:A}},rtlLocaleList=["ae","aeb","ajt","apc","apd","ar","ara","arb","arc","arq","ars","ary","arz","ave","avl","bal","bcc","bej","bft","bgn","bqi","brh","cja","ckb","cld","dcc","dgl","div","drw","dv","fa","fas","fia","fub","gbz","gjk","gju","glk","grc","gwc","gwt","haz","he","heb","hnd","hno","iw","ji","kas","kby","khw","ks","kvx","kxp","kzh","lad","lah","lki","lrc","luz","mde","mfa","mki","mvy","myz","mzn","nqo","oru","ota","otk","oui","pal","pbu","per","pes","phl","phn","pnb","pra","prd","prs","ps","pus","rhg","rmt","scl","sd","sdh","shu","skr","smp","snd","sog","swb","syr","tnf","trw","ug","uig","ur","urd","wni","xco","xld","xmn","xmr","xna","xpr","xsa","ydd","yi","yid","zdj"],retryLoad=(e,t=3,n=1e3)=>new Promise(((r,s)=>{e().then(r).catch((i=>{setTimeout((()=>{1!==t?retryLoad(e,t-1,n).then(r,s):s(i)}),n)}))})),notStringifiedAstType=["code","inlineCode","math","inlineMath"],DETECT_MIN_LENGTH=20,isRTLChar=e=>new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]").test(e),isRTLOfAstLanguage=async e=>{try{const t=getTextOfAst(e,{filter:e=>!isLiteralOfContent(e)||!notStringifiedAstType.includes(e.type)}).trim(),n=elementAt(t.split("\n"),0);if(!n)return!1;const{franc:r}=await retryLoad((()=>__webpack_require__.e(/* import() */ "691").then(__webpack_require__.bind(__webpack_require__, 51854)))),s=r(n,{minLength:20});return"und"===s?isRTLChar(n.charAt(0)):rtlLocaleList.includes(s)}catch(e){return!1}},useIsRTL=e=>{const[t,n]=(0,react.useState)(!1);return (0,react.useEffect)((()=>{e?(async()=>{const t=await isRTLOfAstLanguage(e);n(t)})():n(!1)}),[e]),t},useHop=({onHop:e,ast:t,text:n,getRenderedText:r})=>{const s=(0,react.useRef)(""),i=es_usePrevious(n),a=es_usePrevious(t);(0,react.useEffect)((()=>{const o=s.current,l=r().trim();if(!lodash_es_isUndefined(o)&&!lodash_es_isUndefined(i)&&!lodash_es_isUndefined(a)&&!lodash_es_isUndefined(t)&&e&&n.length>i.length&&l.length<o.length){const n=getHopDiff(a,t);if(n){const{prevEndNode:r,endNode:s}=n;e({renderedText:l,prevRenderedText:o,ast:t,prevAst:a,prevEndNode:r,endNode:s,prevEndNodeType:convertToStanardNodeTypeEnum(null==r?void 0:r.type),endNodeType:convertToStanardNodeTypeEnum(null==s?void 0:s.type)})}}s.current=l}),[n])},isHTMLElementNode=e=>"undefined"==typeof HTMLElement?e.nodeType===Node.ELEMENT_NODE:e instanceof HTMLElement,replaceToText=e=>{for(const t of e.childNodes)replaceToText(t);if(!isHTMLElementNode(e))return;const{customCopyText:t}=e.dataset;if(!lodash_es_isUndefined(t))return void(e.textContent=t);if("br"===e.tagName.toLowerCase()){const t=document.createElement("span");return t.textContent="\n",void(e.parentElement&&e.parentElement.replaceChild(t,e))}},hasCustomCopyTextElement=e=>Boolean(e.querySelector("[data-custom-copy-text]")),supportClipboard=()=>"undefined"!=typeof navigator&&!lodash_es_isUndefined(navigator.clipboard)&&!lodash_es_isUndefined(navigator.clipboard.read)&&!lodash_es_isUndefined(navigator.clipboard.write)&&"undefined"!=typeof ClipboardItem,parseHtmlToDocumentFragment=e=>{const t=document.createDocumentFragment(),n=document.createElement("div");return n.innerHTML=e,t.append(...n.childNodes),t},useCopy=()=>async()=>{try{const e=window.getSelection();if(!(null==e?void 0:e.rangeCount))return;const t=e.getRangeAt(0).cloneContents();if(!hasCustomCopyTextElement(t)||!supportClipboard())return;const n=await navigator.clipboard.read(),r=lodash_es_head(n);if(assert(r),!r.types.includes("text/html"))return;const s=await r.getType("text/html"),i=await s.text(),a=parseHtmlToDocumentFragment(i);replaceToText(a);const o=a.textContent??"",l=(new XMLSerializer).serializeToString(a);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([l],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})])}catch(e){console.warn("[Calypso] Enhanced replication failed, possibly due to the user's refusal of replication permission. The default replication behavior takes effect, and the original error is:",e)}},isTextType=e=>"text"===e.type,isEndlineText=e=>isTextType(e)&&/^\n+$/.test(getInnerText(e)),isElementType=(e,...t)=>"attribs"in e&&"object"==typeof e.attribs&&("tag"===e.type&&(!(null==t?void 0:t.length)||t.some((t=>lodash_es_isRegExp(t)?t.test(e.name):t===e.name)))),getInnerText=e=>isTextType(e)?e.data:isElementType(e)?e.children.map(getInnerText).join(""):"",detectIsChinese=e=>/[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FD5\uF900-\uFA6D\uFA70-\uFAD9]/.test(e),renderDom=e=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact([e])}),renderReactElement=(e,t,n)=>"markdown-root"===t.className?(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:n}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:(0,react.createElement)(e,t,(null==n?void 0:n.length)?n:void 0)}),createShallowedProvider=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}},CalypsoConfigContext=(0,react.createContext)({theme:"default",mode:"light"}),CalypsoConfigProvider=createShallowedProvider(CalypsoConfigContext),useCalypsoConfig=()=>(0,react.useContext)(CalypsoConfigContext),CalypsoSlotsInnerContext=(0,react.createContext)(null),CalypsoSlotsInnerProvider=createShallowedProvider$1(CalypsoSlotsInnerContext),useCalypsoSlots=()=>{const e=(0,react.useContext)(CalypsoSlotsInnerContext);if(!e)throw Error("[Calypso Internal Bugs] CalypsoSlotsInnerContext Required");return e},createSlotConsumer=(e,t)=>{const n=n=>{const r=useCalypsoSlots()[e]??t;return r?(0,jsx_runtime.jsx)(r,{...n}):null};return n.displayName=e,n},CalypsoI18nContext=(0,react.createContext)(null),CalypsoI18nProvider=createShallowedProvider(CalypsoI18nContext),AUTO_HIDE_LAST_SIBLING_BR_CLASS="auto-hide-last-sibling-br",BlockElement=({node:e,renderRest:t,style:n,className:r,children:s})=>{const{BreakLine:i}=useCalypsoSlots(),{style:a,className:o,...l}=attributesToProps((null==e?void 0:e.attribs)??{});return (0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[e&&(0,react.createElement)(e.name,{...l,style:{...a,...n},className:classnames(o,r,"auto-hide-last-sibling-br")},...e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:null==t?void 0:t(e)},n)))),lodash_es_isFunction(s)?s({className:classnames("auto-hide-last-sibling-br")}):s,i&&(0,jsx_runtime.jsx)(i,{})]})},ComposedTable=createSlotConsumer("Table"),renderTable=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"table"))return;const{className:r,...s}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:i})=>(0,jsx_runtime.jsx)(ComposedTable,{...s,raw:e,parents:n,className:classnames(r,i),children:domToReact(e.children,{replace:t})})})},ComposedStrong=createSlotConsumer("Strong"),renderStrong=(e,{renderRest:t,parents:n})=>{if(isElementType(e,"strong"))return (0,jsx_runtime.jsx)(ComposedStrong,{node:e,raw:e,parents:n,children:domToReact(e.children,{replace:t})})},ComposedBreakLine=createSlotConsumer("BreakLine"),ComposedBlockquote=createSlotConsumer("Blockquote"),renderSimpleHtml=(e,{renderRest:t,renderHtml:n,renderDataSlot:r,parents:s})=>{if(!isElementType(e))return;const i=e.name.toLowerCase(),a=attributesToProps(e.attribs),o=e.children.length?e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:t(e)},n))):void 0;if(r&&["data-inline","data-block"].includes(i)){const{type:e,value:t,alt:n}=a;return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r({display:"data-inline"===i?"inline":"block",type:e,value:parseJSONWithNull(he.decode(t,{strict:!1})),alt:n,children:o})??n})}let l;if(n&&(l=null==n?void 0:n({tagName:i,props:a,children:o,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.childNodes)})),!lodash_es_isUndefined(l))return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:l});if("br"===i)return (0,jsx_runtime.jsx)(ComposedBreakLine,{raw:e,parents:s});if("blockquote"===i)return (0,jsx_runtime.jsx)(ComposedBlockquote,{raw:e,node:e,parents:s,renderRest:t});if("hr"===i)return (0,jsx_runtime.jsx)(BlockElement,{node:e,renderRest:t});if(1===e.children.length){const t=e.children[0];if(isTextType(t)&&!t.data.trim())return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})}return renderReactElement(i,a,o)},ComposedParagraph=createSlotConsumer("Paragraph"),renderParagraph=(e,{renderRest:t,forceBrInterSpacing:n,parents:r})=>{if(!isElementType(e,"p"))return;const{className:s,...i}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:a})=>(0,jsx_runtime.jsx)(ComposedParagraph,{...i,raw:e,parents:r,className:classnames(s,a),forceBrInterSpacing:n,children:domToReact(e.children,{replace:t})})})},ComposedTex=createSlotConsumer("Tex"),renderMath=(e,t={})=>{const{parents:n}=t;if(!isElementType(e,"span"))return;const r=e.attribs["data-type"],s=e.attribs["data-value"];if(s)try{const t=node_modules_buffer.Buffer.from(s,"base64").toString("utf8").trim();if("block-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"display"});if("inline-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"inline"})}catch(e){return void console.error("[Math Render Error]",e)}},ComposedList=createSlotConsumer("List"),all_in_one_index_renderList=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"ol","ul"))return;const r=e.children.every((e=>isTextType(e)||isElementType(e,"li")&&!lodash_es_isUndefined(e.children[0])&&isElementType(e.children[0],"input")&&"checkbox"===e.children[0].attribs.type))?"tasklist":void 0;return (0,jsx_runtime.jsx)(ComposedList,{className:r,node:e,raw:e,parents:n,renderRest:t})},ComposedLink=createSlotConsumer("Link"),renderLink=(e,{renderRest:t,customLink:n,callbacks:r={},parents:s})=>{if(!isElementType(e,"a"))return;const{href:i,title:a,...o}=e.attribs,l="autolink"===a;return (0,jsx_runtime.jsx)(ComposedLink,{...attributesToProps(o),raw:e,parents:s,href:i,customLink:n,type:l?"autolink":"markdown",title:l?void 0:a,...pick(r,"onLinkRender","onLinkClick","onSendMessage"),children:domToReact(e.children,{replace:t})})},renderInsertElement=(e,t)=>{var n;const{insertedElements:r=[]}=t;if(!isElementType(e,"span"))return;if("insert_element_extension"!==e.attribs["data-type"])return;const s=e.attribs["data-index"],i=e.attribs["data-raw"];if(lodash_es_isUndefined(s))return;const a=parseInt(s);return a>r.length||null==(n=r[a])?void 0:n.render(i&&node_modules_buffer.Buffer.from(i,"base64").toString("utf-8"))},ComposedIndicator=createSlotConsumer("Indicator"),renderIndicator=(e,t={})=>{var n;const{parents:r}=t;if(isElementType(e,"span")&&"indicator"===(null==(n=e.attribs)?void 0:n.class))return (0,jsx_runtime.jsx)(ComposedIndicator,{raw:e,parents:r})},ComposedImage=createSlotConsumer("Image"),hasSiblingText=(e,t={})=>{const{regardSiblingBrAsText:n=!0}=t,r={hasLeftText:!1,hasRightText:!1};if(!e.parent)return r;const{children:s}=e.parent,i=s.indexOf(e);if(i<0)return r;const a=e=>e<s.length&&e>=0&&(isTextType(s[e])||!!n&&isElementType(s[e],"br"));return{hasLeftText:a(i-1),hasRightText:a(i+1)}},renderImage=(e,t={})=>{const{callbacks:n={},imageOptions:r,marginWithSiblingBr:s=!0,parents:i}=t,{onImageRender:a,onImageClick:o}=n;if(!isElementType(e,"img"))return;const{src:l,alt:c,width:u,height:d}=e.attribs,p=Number(u),m=Number(d),{hasLeftText:g,hasRightText:h}=hasSiblingText(e,{regardSiblingBrAsText:s});return (0,jsx_runtime.jsx)(ComposedImage,{...attributesToProps(e.attribs),raw:e,parents:i,src:safeParseUrl(l)&&l,onImageClick:o,onImageRender:a,imageOptions:{alt:c,objectFit:"cover",objectPosition:"center",height:isNaN(m)?256:m,width:isNaN(p)?400:p,...r},style:{borderRadius:12,overflow:"hidden"},wrapperStyle:{marginTop:g?12:void 0,marginBottom:h?12:void 0},...n})},header$1="_header_1rhdj_1",styles$d={header:header$1},ComposedHeader=createSlotConsumer("Header"),all_in_one_index_renderHeader=(e,{renderRest:t,parents:n})=>{if(isElementType(e,/^h[0-9]+$/))return (0,jsx_runtime.jsx)(ComposedHeader,{className:styles$d.header,node:e,raw:e,parents:n,renderRest:t})},ComposedEmphasis=createSlotConsumer("Emphasis"),renderEm=(e,{renderRest:t,spacingAfterChineseEm:n,parents:r})=>{if(!isElementType(e,"em"))return;const s=void 0!==n&&!1!==n&&detectIsChinese(getInnerText(e).slice(-1)??"")&&!lodash_es_isNull(e.nextSibling)&&(isElementType(e.nextSibling)||isTextType(e.nextSibling))&&detectIsChinese(getInnerText(e.nextSibling).slice(0,1)??"");return (0,jsx_runtime.jsx)(ComposedEmphasis,{style:{marginRight:s?"boolean"==typeof n?2:n:void 0},node:e,raw:e,parents:r,children:domToReact(e.children,{replace:t})})},renderDanger=e=>{if("tag"!==e.type&&"text"!==e.type&&"root"!==e.type)return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})},DEFAULT_LANGUAGE="plaintext",getCodeElement=e=>isElementType(e,"code")?e:isElementType(e,"pre")?e.childNodes.find((e=>isElementType(e,"code"))):void 0,getLanguageFromElement=(e,t="plaintext")=>{var n,r,s;const i=getCodeElement(e);return i&&(null==(s=null==(r=null==(n=i.attribs)?void 0:n.class)?void 0:r.match(/language-(.*)/))?void 0:s[1])||t},getMetaFromElement=(e,t=!0)=>{const n=getCodeElement(e),r=null==n?void 0:n.attribs["data-meta"];if(r)return t?r.split(/\s+/).filter((e=>!e.match(/^__[^_].*/))).join(" ")||void 0:r},getIndentFromCodeElememt=e=>{var t;const n=getMetaFromElement(e,!1);if(!n)return 0;const r=n.match(/(\s|^)__indent=(?<indent>[0-9]+)(\s|$)/);if(!r)return 0;const s=Number(null==(t=r.groups)?void 0:t.indent);return isNaN(s)?0:s},HIDE_HEADER_LANGUAGES=["result","stderr","stdout"],styles$c={"code-group-item--begin":"_code-group-item--begin_1wdrc_1","code-group-item--center":"_code-group-item--center_1wdrc_5","code-group-item--end":"_code-group-item--end_1wdrc_8"},INDENT_WIDTH=18,ComposedCodeBlock=createSlotConsumer("CodeBlock"),isCodeBlockElement=e=>{if(!isElementType(e,"pre"))return!1;const{childNodes:t}=e;return!!t.find((e=>isElementType(e,"code")))},EmptyWrapperElement=({children:e})=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e()}),renderCodeBlocks=(e,t)=>{const{autoHideCodeHeaderLanguage:n=HIDE_HEADER_LANGUAGES,renderRest:r,parents:s,callbacks:i={},indentTabs:a=0,loading:o}=t,{onCopyCodeBlock:l}=i,c=Array.isArray(n)?n:[n],u=BlockElement;return (0,jsx_runtime.jsx)(EmptyWrapperElement,{children:({className:t}={className:""})=>e.map((({target:n},i)=>{if(!isCodeBlockElement(n))return null;const d=styles$c["code-group-item--"+(e.length,"normal")],{childNodes:p=[]}=n;return p.map(((e,n)=>(0,jsx_runtime.jsx)(u,{children:()=>{if(isElementType(e,"code")){const t=getLanguageFromElement(e),r=getMetaFromElement(e);return (0,jsx_runtime.jsx)(ComposedCodeBlock,{parents:s,code:getInnerText(e),language:t,meta:r,showHeader:!c.includes(t.toLowerCase()),className:d,onCopyCode:l,style:{marginLeft:a?18*a+"px":void 0},loading:o},n)}return isElementType(e)?(0,jsx_runtime.jsx)("pre",{className:t,children:r(e)},n):(0,jsx_runtime.jsx)("pre",{className:t,children:domToReact([e])},n)}})))}))})},splitToCodeBlockGroup=({children:e,adjacentCodeAsGroup:t=!0})=>{const n=[];let r=null;for(const s of e)if(isCodeBlockElement(s)){const e=elementAt(n,n.length-1),r={target:s,language:getLanguageFromElement(s,""),code:innerText(s)};(null==e?void 0:e.isCodeBlockGroup)&&t?e.codeBlocks.push(r):n.push({isCodeBlockGroup:!0,codeBlocks:[r]})}else isEndlineText(s)?r=s:(r&&(n.push({isCodeBlockGroup:!1,target:r,code:innerText(r)}),r=null),n.push({isCodeBlockGroup:!1,target:s,code:isElementType(s)||isTextType(s)?innerText(s):""}));return n},renderCodeBlock=(e,{renderRest:t,adjacentCodeAsGroup:n,callbacks:r={}})=>{if(!isElementType(e))return;const{childNodes:s}=e;if(s.every((e=>!isCodeBlockElement(e))))return;const i=splitToCodeBlockGroup({children:s,adjacentCodeAsGroup:n});return renderReactElement(e.name,attributesToProps(e.attribs),i.map(((e,n)=>{if(e.isCodeBlockGroup){const{codeBlocks:s}=e,a=n===i.length-1,o=Math.min(8,...s.map((e=>Math.floor(getIndentFromCodeElememt(e.target)/2))));return renderCodeBlocks(s,{renderRest:t,callbacks:r,indentTabs:o,loading:a,autoHideCodeHeaderLanguage:[]})}return (0,jsx_runtime.jsx)(react.Fragment,{children:t(e.target)},n)})))},renderCustomNode=(e,t={})=>{const{parents:n=[],callbacks:r={},insertedElements:s,imageOptions:i,adjacentCodeAsGroup:a,forceBrInterSpacing:o,spacingAfterChineseEm:l,customLink:c,renderHtml:u,renderRawHtml:d,renderDataSlot:p}=t,m=r=>renderCustomNode(r,{...t,parents:[e,...n]}),g=isElementType(e)?e.name.toLowerCase():"",h=isElementType(e)?attributesToProps(e.attribs):{};return(()=>{if(d&&isElementType(e))return d({tagName:g,props:h,parents:n,renderRest:m,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.children)})})()??renderMath(e,{parents:n})??(s&&renderInsertElement(e,{insertedElements:s}))??renderDanger(e)??renderLink(e,{callbacks:r,customLink:c,parents:n,renderRest:m})??renderImage(e,{callbacks:r,imageOptions:i,marginWithSiblingBr:!o,parents:n})??renderCodeBlock(e,{adjacentCodeAsGroup:a,callbacks:r,renderRest:m})??renderIndicator(e,{parents:n})??renderParagraph(e,{forceBrInterSpacing:o,parents:n,renderRest:m})??renderTable(e,{parents:n,renderRest:m})??all_in_one_index_renderList(e,{parents:n,renderRest:m})??all_in_one_index_renderHeader(e,{parents:n,renderRest:m})??renderEm(e,{parents:n,renderRest:m,spacingAfterChineseEm:l})??renderStrong(e,{parents:n,renderRest:m})??renderSimpleHtml(e,{parents:n,renderRest:m,renderDataSlot:p,renderHtml:u})??renderDom(e)},wrapHtmlByMarkdownRoot=e=>`<div class="markdown-root">${e}</div>`,Markdown=({markDown:e,smartypants:t=!1,enabledHtmlTags:n,purifyHtml:r=!0,purifyHtmlConfig:s,modifyHtmlNode:i,...a})=>{const o=(0,react.useMemo)((()=>new CalypsoTokenizer),[]),l=useDeepCompareMemo((()=>getCalypsoRenderer({enabledHtmlTags:n})),[n]),c=useDeepCompareMemo((()=>{const e=new Marked({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]});return e.setOptions({gfm:!0,silent:!0,breaks:!0}),e.use({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]}),e.use(mangle()),t&&e.use(markedSmartypants()),e}),[t,n]),u=pipe((e=>c.parse(e,{tokenizer:o,renderer:l})),transformSelfClosing,(e=>{const t=(()=>{const e=lodash_es_isArray(n)?n:void 0,t={ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM:!1};e&&(t.ADD_TAGS=e);const r=lodash_es_isFunction(s)?s(t):s;if(r){const{ALLOW_UNKNOWN_PROTOCOLS:e,RETURN_DOM:n,...s}=r;lodash_es_isUndefined(e)||(t.ALLOW_UNKNOWN_PROTOCOLS=e),lodash_es_isUndefined(n)||(t.RETURN_DOM=n),lodash_es_assign(t,s)}return t})();return lodash_es_isFunction(r)?r(e,t):r?purifyHtml(e,t):e}),wrapHtmlByMarkdownRoot),d=(0,react.useMemo)((()=>u(e)),[e,c]),p=(0,react.useMemo)((()=>{const e=htmlToDOM(d);return(null==i?void 0:i(e))??e}),[d]);return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact(p,{replace:e=>renderCustomNode(e,a)})})},container$6="_container_7mgzw_1",all_in_one_index_active="_active_7mgzw_7",blink="_blink_7mgzw_35",all_in_one_index_frame="_frame_7mgzw_631",all_in_one_index_enabled="_enabled_7mgzw_792",cursorAnimation="_cursorAnimation_7mgzw_1",styles$b={container:container$6,active:all_in_one_index_active,blink:blink,"no-list":"_no-list_7mgzw_553",frame:all_in_one_index_frame,"align-center":"_align-center_7mgzw_654","align-right":"_align-right_7mgzw_669","float-left":"_float-left_7mgzw_684","float-right":"_float-right_7mgzw_693",enabled:all_in_one_index_enabled,cursorAnimation:cursorAnimation},CalypsoSlotsContext=(0,react.createContext)(null);createShallowedProvider$1(CalypsoSlotsContext);const emptySlots={BreakLine:null,Tex:null,CodeBlockHighlighter:null,CodeBlock:null,Table:null,Image:null,Indicator:null,Paragraph:null,Link:null,Emphasis:null,Strong:null,Header:null,List:null,Blockquote:null},MarkdownEngine=(0,react.forwardRef)((function({className:e,style:t,mode:n="light",markDown:r,eventCallbacks:s,showIndicator:i=!1,autoFixSyntax:a=!0,smooth:o=!1,insertedElements:l=[],showEllipsis:c=!1,imageOptions:u,autoFitRTL:d=!1,forceBrInterSpacing:p,spacingAfterChineseEm:m=2,indentFencedCode:g,indentedCode:h,smartypants:f,enhancedCopy:x=!1,autolink:y,customLink:k,autoSpacing:T,slots:C={},translate:v={},enabledHtmlTags:E,purifyHtml:P,purifyHtmlConfig:S,astPlugins:w,sourcePlugins:_,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R,onAstChange:N,onHop:I,...M},$){const H=(0,react.useContext)(CalypsoSlotsContext),B={...emptySlots,...H,...C},j={theme:"default",mode:n},{Indicator:O}=B,{text:F,flushCursor:D}=useSmoothText(r,o),{katex:z,autoFixEnding:U,imageEmphasisTitle:q}=lodash_es_defaults(lodash_es_isBoolean(a)?{}:a,{autoFixEnding:!1}),Z=(0,react.useMemo)((()=>R&&!0!==E?[...E||[],"data-block","data-inline"]:E),[E,Boolean(R)]),{source:W,ast:V}=useProcessMarkdown({source:F,processAst:Boolean(a),showEllipsis:c,showIndicator:i,imageEmphasisTitle:q,indentFencedCode:g,indentedCode:h,insertedElements:l,autolink:y,autoSpacing:T,astPlugins:w,sourcePlugins:_,fixEnding:U,enabledHtmlTags:Z,looseTruncateDataSlot:Boolean(R),katex:z}),G=useIsRTL(d?V:void 0),K=useCopy(),X=(0,react.useRef)(null);useHop({onHop:I,ast:V,text:F,getRenderedText:()=>{var e;return(null==(e=X.current)?void 0:e.textContent)??""}}),(0,react.useEffect)((()=>{null==N||N(V)}),[V]),(0,react.useImperativeHandle)($,(()=>({getRootElement:()=>X.current,flushSmoothCursor:D})),[]);return W.trim()?(0,jsx_runtime.jsx)(CalypsoConfigProvider,{value:j,children:(0,jsx_runtime.jsx)(CalypsoSlotsInnerProvider,{value:B,afterMemoedProcess:e=>e?{...e}:e,children:(0,jsx_runtime.jsx)(CalypsoI18nProvider,{value:v,children:(0,jsx_runtime.jsx)("div",{...M,ref:X,"theme-mode":n,className:classnames(styles$b.container,"flow-markdown-body",styles$b[`theme-${j.theme}`],e),style:t,dir:G?"rtl":"ltr","data-show-indicator":i,onCopy:x?K:void 0,children:(0,jsx_runtime.jsx)(Markdown,{markDown:W,callbacks:s,insertedElements:l,imageOptions:u,forceBrInterSpacing:p,spacingAfterChineseEm:m,smartypants:f,customLink:k,enabledHtmlTags:Z,purifyHtml:P,purifyHtmlConfig:S,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R})})})})}):(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[c&&"...",i&&O&&(0,jsx_runtime.jsx)(O,{})]})})),CalypsoCore=(0,react.forwardRef)((function({plugins:e=[],slots:t={},astPlugins:n=[],sourcePlugins:r=[],modifyHtmlNode:s,renderHtml:i,renderRawHtml:a,...o},l){const c=(0,react.useMemo)((()=>aggregatePlugins(e)),[e]),u=(0,react.useMemo)((()=>({...c.slots,...t})),[t,c.slots]);function d(e){return e?"function"==typeof e?e([]):e:[]}const p=[...d(n),...c.astPlugins],m=[...d(r),...c.sourcePlugins],g=c.modifyHtmlNode||s,h=c.renderHtml||i,f=c.renderRawHtml||a;return (0,jsx_runtime.jsx)(MarkdownEngine,{ref:l,slots:u,astPlugins:p,sourcePlugins:m,modifyHtmlNode:g,renderHtml:h,renderRawHtml:f,...o})}));function composeModifyHtmlNode(e){if(e.length)return t=>{let n=t;return e.forEach((e=>{const t=e(n);t&&(n=t)})),n}}function composeRenderer(e){if(e.length)return t=>{for(const n of e){const e=n(t);if(null!=e)return e}}}function aggregatePlugins(e){let t={};const n=[],r=[],s=[],i=[],a=[];return e.forEach((e=>{var o,l;e.slots&&(t={...t,...e.slots}),(null==(o=e.astPlugins)?void 0:o.length)&&n.push(...e.astPlugins),(null==(l=e.sourcePlugins)?void 0:l.length)&&r.push(...e.sourcePlugins),e.modifyHtmlNode&&s.push(e.modifyHtmlNode),e.renderHtml&&i.push(e.renderHtml),e.renderRawHtml&&a.push(e.renderRawHtml)})),{slots:t,astPlugins:n,sourcePlugins:r,modifyHtmlNode:composeModifyHtmlNode(s),renderHtml:composeRenderer(i),renderRawHtml:composeRenderer(a)}}const LightTex=({tex:e,mode:t,className:n,style:r})=>(0,jsx_runtime.jsx)("span",{className:classnames("math-inline",n),style:r,children:e}),texLightPlugin={name:"tex-light",slots:{Tex:LightTex}},styles$a={"table-container":"_table-container_18bux_1"},all_in_one_index_Table=({children:e,className:t,raw:n,parents:r,...s})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$a["table-container"]),...s,children:(0,jsx_runtime.jsx)("table",{children:e})}),tablePlugin={name:"table",slots:{Table:all_in_one_index_Table}},Strong=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("strong",{className:e,style:t,children:n}),strongPlugin={name:"strong",slots:{Strong:Strong}},all_in_one_index_paragraph="_paragraph_1b2re_1",styles$9={paragraph:all_in_one_index_paragraph},all_in_one_index_Paragraph=({children:e,className:t,forceBrInterSpacing:n=!1,raw:r,parents:s,...i})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$9.paragraph,"paragraph-element",{"br-paragraph-space":n}),...i,children:(0,react.isValidElement)(e)?(0,react.cloneElement)(e,{key:"0"}):e}),paragraphPlugin={name:"paragraph",slots:{Paragraph:all_in_one_index_Paragraph}},all_in_one_index_List=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),listPlugin={name:"list",slots:{List:all_in_one_index_List}},all_in_one_index_link="_link_eyymc_1",styles$8={link:all_in_one_index_link},isHttpLink=e=>{const t=safeParseUrl(e);return!!t&&("http:"===t.protocol||"https:"===t.protocol)},all_in_one_index_Link=({className:e,style:t,href:n,children:r,customLink:s=!0,onLinkClick:i,onLinkRender:a,onOpenLink:o,type:l,raw:c,parents:u,...d})=>{const p=n?safeParseUrl(n):null,m=useComputeValue((()=>!!n&&(!!isHttpLink(n)||(lodash_es_isFunction(s)?s(n):s)))),g=e=>{o?null==o||o(e):window.open(e)};return (0,react.useEffect)((()=>{n&&p&&(null==a||a({url:n,parsedUrl:p}))}),[n]),m?(0,jsx_runtime.jsx)("a",{...lodash_es_omit(d,"href"),className:classnames(styles$8.link,e),style:t,onClick:e=>{n&&p?isHttpLink(n)&&(i?i(e,{url:n,parsedUrl:p,exts:{type:LinkType.normal},openLink:g}):(e.preventDefault(),e.stopPropagation(),g(n))):e.preventDefault()},href:p?n:void 0,target:"_blank",children:r}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r})},linkPlugin={name:"link",slots:{Link:all_in_one_index_Link}},styles$7={},all_in_one_index_Indicator=({className:e,style:t})=>(0,jsx_runtime.jsx)("span",{className:styles$7.container,children:(0,jsx_runtime.jsx)("span",{className:classnames(styles$7.indicator,styles$7.flashing,e),style:t,"data-testid":"indicator"})}),indicatorPlugin={name:"indicator",slots:{Indicator:all_in_one_index_Indicator}},all_in_one_index_SvgIconError=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 21.375C6.82233 21.375 2.625 17.1777 2.625 12C2.625 6.82233 6.82233 2.625 12 2.625C17.1777 2.625 21.375 6.82233 21.375 12C21.375 17.1777 17.1777 21.375 12 21.375ZM0.75 12C0.75 5.7868 5.7868 0.75 12 0.75C18.2132 0.75 23.25 5.7868 23.25 12C23.25 18.2132 18.2132 23.25 12 23.25C5.7868 23.25 0.75 18.2132 0.75 12ZM11.9911 13.6761C11.3638 13.6761 11.0393 13.3623 11.0174 12.7348L10.8752 7.87488C10.8606 7.55381 10.9591 7.29476 11.1706 7.09774C11.3821 6.89342 11.6519 6.79126 11.9801 6.79126C12.3083 6.79126 12.5818 6.89342 12.8006 7.09774C13.0194 7.30206 13.1215 7.56475 13.107 7.88583L12.9429 12.7238C12.921 13.3587 12.6037 13.6761 11.9911 13.6761ZM11.9911 17.1349C11.6483 17.1349 11.3529 17.0255 11.1049 16.8066C10.8642 16.5877 10.7439 16.3104 10.7439 15.9747C10.7439 15.639 10.8642 15.3617 11.1049 15.1428C11.3456 14.9239 11.641 14.8144 11.9911 14.8144C12.3412 14.8144 12.6365 14.9239 12.8772 15.1428C13.1252 15.3617 13.2492 15.639 13.2492 15.9747C13.2492 16.3177 13.1252 16.5986 12.8772 16.8175C12.6365 17.0291 12.3412 17.1349 11.9911 17.1349Z",fill:"#999999"})),container$5="_container_hux85_1",centered="_centered_hux85_8",all_in_one_index_image="_image_hux85_11",fallbackIcon="_fallbackIcon_hux85_30",square="_square_hux85_40",all_in_one_index_clickable="_clickable_hux85_45",all_in_one_index_title="_title_hux85_48",styles$6={container:container$5,centered:centered,image:all_in_one_index_image,"loading-image":"_loading-image_hux85_16","error-wrapper":"_error-wrapper_hux85_21",fallbackIcon:fallbackIcon,"image-wrapper":"_image-wrapper_hux85_35",square:square,clickable:all_in_one_index_clickable,title:all_in_one_index_title},convertHttpToHttps=e=>{const t=new URL(e);return"http:"===t.protocol&&(t.protocol="https:"),t.toString()},all_in_one_index_Image=({className:e,style:t,raw:n,parents:r,wrapperClassName:s,wrapperStyle:i,src:a=null,otherFormatSrc:o,onImageClick:l,onImageRender:c,imageOptions:u={layout:"intrinsic",objectFit:"contain"},errorClassName:d,children:p,onImageLoadComplete:m,useCustomPlaceHolder:g=!1,customPlaceHolder:h,onImageContextMenu:f,onImageMouseEnter:x,...y})=>{const{squareContainer:k=!1,forceHttps:T=!1,responsiveNaturalSize:C=!1,width:v=400,height:E=256,showTitle:P=!1,centered:S=!1,...w}=u,{alt:_}=u,[b,A]=(0,react.useState)(v),[L,R]=(0,react.useState)(E);(0,react.useEffect)((()=>{(v||E)&&(A(v),R(E))}),[v,E]);const{minHeight:N,minWidth:I,maxHeight:M,maxWidth:$}=lodash_es_defaults(lodash_es_isBoolean(C)?{}:{...C},{minHeight:0,minWidth:0,maxWidth:v??400,maxHeight:E??256}),H=a&&(T?convertHttpToHttps(a):a),[B,j]=(0,react.useState)(ImageStatus.Loading),O=B!==ImageStatus.Loading,F={src:H,status:B},D=(C||g)&&!O;(0,react.useEffect)((()=>{H&&(null==c||c(F))}),[H]);const z=lodash_es_isNumber(b)&&lodash_es_isNumber(L)&&{width:"100%",height:0,paddingBottom:`min(${L/b*100}%, ${L}px)`,maxWidth:b};return (0,jsx_runtime.jsxs)("div",{className:classnames(styles$6.container,{[styles$6.centered]:S}),style:i,children:[(0,jsx_runtime.jsx)("div",{onClick:e=>{l&&F&&(l(e,F),e.stopPropagation())},className:classnames(styles$6["image-wrapper"],{[styles$6.clickable]:Boolean(l),[styles$6.square]:k},s),style:{...z},"data-testid":"calypso_image",children:p||(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[C&&!O&&!g&&(0,jsx_runtime.jsx)("span",{className:styles$6["loading-image"],children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,height:L,width:b,placeholder:"skeleton",src:""})}),(0,jsx_runtime.jsx)("span",{style:{display:"inline-block",...D?{width:0,height:0}:{}},children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,onContextMenu:f,onMouseEnter:x,height:L,width:b,alt:"image",src:H??"",formats:["avif","webp"],placeholder:"skeleton",loader:({extra:{origin:e},format:t})=>(null==o?void 0:o.avifSrc)&&"avis"===t?null==o?void 0:o.avifSrc:(null==o?void 0:o.webpSrc)&&"awebp"===t?null==o?void 0:o.webpSrc:H??e,error:(0,jsx_runtime.jsx)("div",{className:classnames(styles$6["error-wrapper"],d,"error-wrapper"),ref:()=>{j(ImageStatus.Failed),null==m||m()},children:(0,jsx_runtime.jsx)(all_in_one_index_SvgIconError,{className:styles$6.fallbackIcon})}),onLoadingComplete:e=>{var t;j(ImageStatus.Success),null==m||m();const{naturalWidth:n,naturalHeight:r}=e;if(C&&n&&r){const e=resizeImage({width:n,height:r,minHeight:N,minWidth:I,maxHeight:M,maxWidth:$});A(e.width),R(e.height)}null==(t=w.onLoadingComplete)||t.call(w,e)},className:classnames(e,styles$6.image),style:t})}),g&&!O&&h]})}),P&&_&&(0,jsx_runtime.jsx)("div",{className:styles$6.title,children:_})]})},imagePlugin={name:"samantha-image",slots:{Image:all_in_one_index_Image}},all_in_one_index_Header=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),headerPlugin={name:"header",slots:{Header:all_in_one_index_Header}},Emphasis=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("em",{className:e,style:t,children:n}),emphasisPlugin={name:"emphasis",slots:{Emphasis:Emphasis}};let fullLanguages=null;const fetchFullLanguagePacks=async()=>{if(!fullLanguages){const{languages:e=null}=await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 847, 19));fullLanguages=e}return fullLanguages},useLanguagePack=e=>{const[t,n]=(0,react.useState)(fullLanguages||prism.languages);return (0,react.useEffect)((()=>{t[e]||(async()=>{const e=await fetchFullLanguagePacks();e&&e!==t&&n(e)})()}),[t,e]),t[e]||t.plaintext},useHighLight=(e,t)=>{const n=t.toLowerCase(),r=useLanguagePack(n);return (0,react.useMemo)((()=>{try{return (0,prism.highlight)(e,r,n)}catch(t){return console.error("Fail to highlight code by prism",t),e}}),[n,e,r])},container$4="_container_g7n3b_57",dark$1="_dark_g7n3b_176",styles$5={container:container$4,dark:dark$1},PrismCodeBlockHighlighter=({code:e,language:t="",className:n,style:r,dark:s=!1})=>{const i=useHighLight(e,t);return (0,jsx_runtime.jsx)("pre",{className:classnames(styles$5.container,n,t&&`language-${t}`,{[styles$5.dark]:s}),style:r,children:(0,jsx_runtime.jsx)("code",{className:t&&`language-${t}`,dangerouslySetInnerHTML:{__html:purifyHtml(i)}})})},index$2=Object.freeze(Object.defineProperty({__proto__:null,PrismCodeBlockHighlighter:PrismCodeBlockHighlighter,default:PrismCodeBlockHighlighter},Symbol.toStringTag,{value:"Module"})),codeHighlighterPrismPlugin={name:"code-highlighter-prism",slots:{CodeBlockHighlighter:PrismCodeBlockHighlighter}},detectLanguage=e=>{},PLAIN_TEXT="plaintext",useAutoDetectLanguage=(e,t=PLAIN_TEXT)=>{const[n,r]=(0,react.useState)(t);return (0,react.useEffect)((()=>{r(t)}),[t]),(0,react.useEffect)((()=>{(async()=>{if(n===PLAIN_TEXT){const e=await detectLanguage();e&&r(e)}})()}),[e,n]),n},SvgDoneIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{d:"M9.2267 16.1272L19.9535 5.40038C20.4274 4.92644 21.1958 4.92644 21.6698 5.40038C22.1437 5.87432 22.1437 6.64272 21.6698 7.11666L10.0848 18.7016C9.61091 19.1755 8.8425 19.1755 8.36856 18.7016L2.36156 12.6946C1.88762 12.2207 1.88762 11.4522 2.36156 10.9783C2.8355 10.5044 3.6039 10.5044 4.07784 10.9783L9.2267 16.1272Z",fill:"currentColor"})),SvgCopyIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.5 3.5V17C21.5 18.1046 20.6046 19 19.5 19H17.5V21C17.5 22.1046 16.5406 23 15.3571 23H4.64286C3.45939 23 2.5 22.1046 2.5 21V7.5C2.5 6.39543 3.45939 5.5 4.64286 5.5H6.5V3.5C6.5 2.39543 7.39543 1.5 8.5 1.5H19.5C20.6046 1.5 21.5 2.39543 21.5 3.5ZM8.5 5.5H15.3571C16.5406 5.5 17.5 6.39543 17.5 7.5V17H19.5V3.5H8.5V5.5ZM15.3571 7.5H4.64286L4.64286 21H15.3571V7.5Z",fill:"currentColor"})),SvgCodeIcon=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 9V15H5.2V9H7ZM7 8V16H5C4.44771 16 4 15.7015 4 15.3333V8.66667C4 8.29848 4.44771 8 5 8H7Z",fill:"currentColor"}),react.createElement("path",{d:"M8.5 10L11.5 12L8.5 14",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{d:"M15.5 15H11.5",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 9V15H18.8V9H17ZM17 8V16H19C19.5523 16 20 15.7015 20 15.3333V8.66667C20 8.29848 19.5523 8 19 8H17Z",fill:"currentColor"})),container$3="_container_vmcsy_1",dark="_dark_vmcsy_13",all_in_one_index_header="_header_vmcsy_32",all_in_one_index_text="_text_vmcsy_44",all_in_one_index_icon="_icon_vmcsy_53",all_in_one_index_actions="_actions_vmcsy_56",all_in_one_index_item="_item_vmcsy_61",all_in_one_index_img="_img_vmcsy_82",all_in_one_index_content="_content_vmcsy_85",hoverable="_hoverable_vmcsy_98",styles$4={container:container$3,dark:dark,"code-area":"_code-area_vmcsy_20",header:all_in_one_index_header,text:all_in_one_index_text,icon:all_in_one_index_icon,actions:all_in_one_index_actions,item:all_in_one_index_item,img:all_in_one_index_img,content:all_in_one_index_content,hoverable:hoverable,"light-scrollbar":"_light-scrollbar_vmcsy_121"},CodeBlock=({className:e,style:t,code:n,language:r,onCopyCode:s,showHeader:i=!0,raw:a,parents:o})=>{const{mode:l}=useCalypsoConfig(),c="dark"===l,{CodeBlockHighlighter:u}=useCalypsoSlots(),[d,p]=(0,react.useState)(!1),m=useAutoDetectLanguage(n,r);return (0,jsx_runtime.jsx)("div",{"data-testid":"code_block",className:classnames(styles$4.container,e,"hide-indicator",{[styles$4.dark]:c}),style:t,children:(0,jsx_runtime.jsxs)("div",{className:classnames(styles$4["code-area"]),dir:"ltr",children:[i&&(0,jsx_runtime.jsxs)("div",{className:styles$4.header,children:[(0,jsx_runtime.jsxs)("div",{className:styles$4.text,children:[(0,jsx_runtime.jsx)(SvgCodeIcon,{className:styles$4.icon}),m]}),(0,jsx_runtime.jsx)("div",{className:styles$4.actions,children:(0,jsx_runtime.jsx)("div",{className:styles$4.item,onClick:()=>{d||(copy_to_clipboard(n),null==s||s(n),p(!0),setTimeout((()=>{p(!1)}),3e3))},children:(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.icon,styles$4.hoverable),"data-testid":"code_block_copy",children:(0,jsx_runtime.jsx)(d?SvgDoneIcon:SvgCopyIcon,{className:styles$4.img})})})})]}),(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.content,styles$4[`content--${m.toLowerCase()}`]),children:u&&(0,jsx_runtime.jsx)(u,{code:n,language:r,raw:a,parents:o,dark:c})})]})})},codeBlockPlugin={name:"code-block",slots:{CodeBlock:CodeBlock}},all_in_one_index_wrapper="_wrapper_aaa8t_1",wrapperStyles={wrapper:all_in_one_index_wrapper},container$2="_container_1lt86_9",styles$3={container:container$2},BreakLine=({className:e,style:t})=>(0,jsx_runtime.jsx)("br",{className:classnames(styles$3.container,e),style:t}),withCalypsoBreakLine=e=>function({className:t,...n}){return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e&&(0,jsx_runtime.jsx)(e,{className:classnames(wrapperStyles.wrapper,t,{[styles$3["non-select"]]:!all_in_one_index_isSafari()}),...n})})},WrappedBreakLine=withCalypsoBreakLine(BreakLine),breakLinePlugin={name:"break-line",slots:{BreakLine:WrappedBreakLine}},Blockquote=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),blockquotePlugin={name:"blockquote",slots:{Blockquote:Blockquote}},defaultPlugins=[breakLinePlugin,texLightPlugin,codeHighlighterPrismPlugin,codeBlockPlugin,tablePlugin,imagePlugin,indicatorPlugin,paragraphPlugin,linkPlugin,emphasisPlugin,strongPlugin,headerPlugin,listPlugin,blockquotePlugin],CalypsoLite=(0,react.forwardRef)((function(e,t){return (0,jsx_runtime.jsx)(CalypsoCore,{ref:t,plugins:defaultPlugins,...e})})),safeKatexTexToHtml=(e,t={})=>{try{return katex["default"].renderToString(e,{throwOnError:!1,strict:!1,output:"html",trust:!1,...t})}catch(e){return null}},adaptor=(0,liteAdaptor.liteAdaptor)();(0,handlers_html.RegisterHTMLHandler)(adaptor);const all_in_one_index_tex=new tex.TeX({packages:[...AllPackages.AllPackages.sort().join(", ").split(/\s*,\s*/),"physics","mhchem"],macros:{equalparallel:"{\\lower{2.6pt}{\\arrowvert\\hspace{-4.2pt}\\arrowvert}\\above{-2pt}\\raise{7.5pt}{=}}",number:["{#1}",1],unit:["{#1}",1],div:"{÷}"}}),all_in_one_index_svg=new output_svg.SVG({fontCache:"none"}),all_in_one_index_html=mathjax.mathjax.document("",{InputJax:all_in_one_index_tex,OutputJax:all_in_one_index_svg}),texToSvg=e=>{var t;const n=xregexp_lib.replace(e,xregexp_lib(String.raw`[^\P{C}\n\t]+`,"ug"),"");try{const e=all_in_one_index_html.convert(n,{display:!0,em:16,ex:8,containerWidth:1280});return adaptor.outerHTML(null==(t=null==e?void 0:e.children)?void 0:t[0])}catch(t){return safeKatexTexToHtml(e)??e}},container$1="_container_1dcs1_1",single$1="_single_1dcs1_16",all_in_one_index_error="_error_1dcs1_44",styles$2={container:container$1,single:single$1,error:all_in_one_index_error},RawMathjaxTex=(0,react.forwardRef)((function({className:e,style:t,tex:n,html:r},s){const i=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(n.trim())),[n]),a=Boolean(null==r?void 0:r.includes("data-mjx-error")),o=!lodash_es_isUndefined(r)&&!a;return (0,jsx_runtime.jsx)("span",{ref:s,className:classnames(styles$2.container,e,"math-inline",{[styles$2.single]:i,[styles$2.error]:a}),style:t,dangerouslySetInnerHTML:o?{__html:r}:void 0,"data-custom-copy-text":`\\(${n}\\)`,children:o?null:n})})),MathJaxTex=({className:e,style:t,tex:n,mode:r})=>{const s=(0,react.useMemo)((()=>purifyHtml(texToSvg(n))),[n]);return (0,jsx_runtime.jsx)(RawMathjaxTex,{className:e,style:t,tex:n,html:s})},Calypso=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,...n},r){return (0,jsx_runtime.jsx)(CalypsoLite,{ref:r,slots:lodash_es_defaults(e,{Tex:MathJaxTex,CodeBlockHighlighter:PrismCodeBlockHighlighter}),autoFixSyntax:t&&{katex:katex["default"],...lodash_es_isBoolean(t)?{}:t},...n})}));class DefaultParseError extends Error{constructor(e,t,n){super(),this.message=e,this.lexer=t,this.position=n}}const useLazyKatex=()=>{const[e,t]=(0,react.useState)(),n=(0,react.useCallback)((async()=>{if(e)return;const{default:n}=await retryLoad((()=>Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 97234))));t(n)}),[e]),r=(0,react.useMemo)((()=>{var e;return(e=class{static render(){throw n(),new DefaultParseError("DefaultKatex.render has called",{},0)}static renderToString(){throw n(),new DefaultParseError("DefaultKatex.renderToString has called",{},0)}}).ParseError=DefaultParseError,e}),[n]);return e??r},withSuspense=(e,t)=>{const n=n=>(0,jsx_runtime.jsx)(react.Suspense,{fallback:t&&(0,jsx_runtime.jsx)(t,{...n}),children:(0,jsx_runtime.jsx)(e,{...n})});return n.displayName=e.displayName??(null==t?void 0:t.displayName),n},useLazyComponent=(e,t,n={})=>{const{retryTimes:r=5,retryInterval:s=100}=n;return (0,react.useMemo)((()=>withSuspense(react.lazy(withRetry(e,{tryTimes:r,interval:s,fallback:{default:t}})),t)),[r,s])},styles$1={"light-scrollbar":"_light-scrollbar_1ks9r_1"},LightCodeBlockHighlighter=({language:e,code:t,className:n,style:r})=>(0,jsx_runtime.jsx)("pre",{className:classnames(e&&`language-${e}`,styles$1["light-scrollbar"],n),style:r,children:(0,jsx_runtime.jsx)("code",{children:t})}),CalypsoLazy=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,retryTimes:n=5,retryInterval:r=100,...s},i){const a=useLazyKatex(),o=useLazyComponent((()=>Promise.resolve().then((()=>index$1))),LightTex,{retryTimes:n,retryInterval:r}),l=useLazyComponent((()=>Promise.resolve().then((()=>all_in_one_index_index))),o,{retryTimes:n,retryInterval:r}),c=useLazyComponent((()=>Promise.resolve().then((()=>index$2))),LightCodeBlockHighlighter,{retryTimes:n,retryInterval:r});return (0,jsx_runtime.jsx)(CalypsoLite,{ref:i,slots:lodash_es_defaults(e,{Tex:l,CodeBlockHighlighter:c}),autoFixSyntax:t&&{katex:a,...lodash_es_isBoolean(t)?{}:t},...s})})),AsyncLazyMathJaxTex=({className:e,style:t,tex:n})=>{const[r,s]=useState(),[i,a]=useState(!1),o=useRef(null);return useEffect((()=>{i&&s(texToSvg(n))}),[n,i]),useEffect((()=>{const e=new IntersectionObserver((t=>{if(!(null==t?void 0:t[0]))return;const{intersectionRatio:n}=t[0];n>0&&(a(!0),e.disconnect())}));return o.current&&e.observe(o.current),()=>{e.disconnect()}}),[]),jsx(RawMathjaxTex,{ref:o,className:e,style:t,tex:n,html:r})},asyncLazyMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"async-lazy-mathjax-tex",slots:{Tex:AsyncLazyMathJaxTex}})),codeHighlighterLightPlugin=(/* unused pure expression or super */ null && ({name:"code-highlighter-light",slots:{CodeBlockHighlighter:LightCodeBlockHighlighter}})),all_in_one_index_container="_container_imek1_1",all_in_one_index_single="_single_imek1_6",all_in_one_index_block="_block_imek1_9",all_in_one_index_styles={container:all_in_one_index_container,single:all_in_one_index_single,block:all_in_one_index_block},KatexTex=({tex:e,mode:t,className:n,style:r,fallback:s,katexOptions:i})=>{const a=useDeepCompareMemo((()=>safeKatexTexToHtml(e,i)),[e,i]),o=useDeepCompareMemo((()=>a?null:safeKatexTexToHtml(e,{...i,displayMode:!0})),[e,i,Boolean(a)]),l=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(e.trim())),[e]);return!s||a||o?(0,jsx_runtime.jsx)("span",{className:classnames(all_in_one_index_styles.container,n,"math-inline",{[all_in_one_index_styles.single]:l,[all_in_one_index_styles.block]:Boolean(o)}),style:r,dangerouslySetInnerHTML:{__html:purifyHtml((a||o)??e)},"data-custom-copy-text":l?e:`\\(${e}\\)`}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:s})},index$1=Object.freeze(Object.defineProperty({__proto__:null,KatexTex:KatexTex,default:KatexTex},Symbol.toStringTag,{value:"Module"})),katexTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-tex",slots:{Tex:KatexTex}})),KatexMathjaxTex=e=>(0,jsx_runtime.jsx)(KatexTex,{...e,katexOptions:{strict:!0,throwOnError:!0},fallback:(0,jsx_runtime.jsx)(MathJaxTex,{...e})}),all_in_one_index_index=Object.freeze(Object.defineProperty({__proto__:null,KatexMathjaxTex:KatexMathjaxTex,default:KatexMathjaxTex},Symbol.toStringTag,{value:"Module"})),katexMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-mathjax-tex",slots:{Tex:KatexMathjaxTex}})),mathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"mathjax-tex",slots:{Tex:MathJaxTex}}));
296436
+ */const mathFlow={tokenize:tokenizeMathFenced,concrete:!0},all_in_one_index_nonLazyContinuation={tokenize:all_in_one_index_tokenizeNonLazyContinuation,partial:!0};function tokenizeMathFenced(e,t,n){const r=this,s=r.events[r.events.length-1],i=s&&s[1].type===types_types.linePrefix?s[2].sliceSerialize(s[1],!0).length:0;let a=0;return function(t){return default_ok(t===codes_codes.dollarSign,"expected `$`"),e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),o(t)};function o(t){return t===codes_codes.dollarSign?(e.consume(t),a++,o):a<2?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,l,types_types.whitespace)(t))}function l(t){return t===codes_codes.eof||markdownLineEnding(t)?u(t):(e.enter("mathFlowFenceMeta"),e.enter(types_types.chunkString,{contentType:constants.contentTypeString}),c(t))}function c(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit(types_types.chunkString),e.exit("mathFlowFenceMeta"),u(t)):t===codes_codes.dollarSign?n(t):(e.consume(t),c)}function u(n){return e.exit("mathFlowFence"),r.interrupt?t(n):e.attempt(all_in_one_index_nonLazyContinuation,d,h)(n)}function d(t){return e.attempt({tokenize:f,partial:!0},h,p)(t)}function p(t){return(i?factorySpace(e,m,types_types.linePrefix,i+1):m)(t)}function m(t){return t===codes_codes.eof?h(t):markdownLineEnding(t)?e.attempt(all_in_one_index_nonLazyContinuation,d,h)(t):(e.enter("mathFlowValue"),g(t))}function g(t){return t===codes_codes.eof||markdownLineEnding(t)?(e.exit("mathFlowValue"),m(t)):(e.consume(t),g)}function h(n){return e.exit("mathFlow"),t(n)}function f(e,t,n){let s=0;return default_ok(r.parser.constructs.disable.null,"expected `disable.null`"),factorySpace(e,(function(t){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),i(t)}),types_types.linePrefix,r.parser.constructs.disable.null.includes("codeIndented")?void 0:constants.tabSize);function i(t){return t===codes_codes.dollarSign?(s++,e.consume(t),i):s<a?n(t):(e.exit("mathFlowFenceSequence"),factorySpace(e,o,types_types.whitespace)(t))}function o(r){return r===codes_codes.eof||markdownLineEnding(r)?(e.exit("mathFlowFence"),t(r)):n(r)}}}function all_in_one_index_tokenizeNonLazyContinuation(e,t,n){const r=this;return function(n){if(null===n)return t(n);return default_ok(markdownLineEnding(n),"expected eol"),e.enter(types_types.lineEnding),e.consume(n),e.exit(types_types.lineEnding),s};function s(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}const dollarSign=36;function all_in_one_index_math(e){return{flow:{[dollarSign]:mathFlow},text:{[dollarSign]:mathText()}}}const parseJSONWithNull=e=>{try{return e?JSON.parse(e):null}catch(e){return null}},getByIndex=(e,t)=>{if(!lodash_es_isUndefined(t))return null==e?void 0:e[t]};class AssertError extends Error{constructor(){super(...arguments),this.name="assert_error"}}const assert=(e,t)=>{if(!e){if(lodash_es_isError(t))throw t;throw new AssertError(t)}};let _isSafari;function all_in_one_index_isSafari(){return"undefined"!=typeof navigator&&(void 0===_isSafari&&(_isSafari=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),_isSafari)}const pipe=(...e)=>t=>e.reduce(((e,t)=>t(e)),t),isNumeric=e=>{const t=e.replace(/,/g,"");return!isNaN(t)&&!isNaN(parseFloat(t))},firstMatch=(e,t)=>{for(const n of e){const e=t(n);if(e)return e}},timeoutPromise=e=>new Promise((t=>setTimeout(t,e))),elementAt=(e,t)=>e[t],splitStringByPattern=(e,t)=>{const n=[],{flags:r}=t,s=new RegExp(t.source,r.includes("g")?r:`${r}g`);let i,a=0;for(;i=s.exec(e);){const t=i[0];i.index>a&&n.push(e.slice(a,i.index)),n.push(t),a=i.index+t.length}return e.length>a&&n.push(e.slice(a,e.length)),n},safeParseUrl=e=>{try{return new URL(e)}catch(e){return null}},useCustomMemoValue=(e,t)=>{const n=(0,react.useRef)(e);return t(e,n.current)||(n.current=e),n.current},useDeepCompareMemo=(e,t)=>{const n=(0,react.useRef)();return!lodash_es_isUndefined(n.current)&&lodash_es_isEqual(n.current,t)||(n.current=t),(0,react.useMemo)(e,n.current)},useComputeValue=e=>e(),purifyHtml=(e,t)=>isomorphic_dompurify_browser.sanitize?isomorphic_dompurify_browser.sanitize(e,t):(console.error("[Calypso] Cannot load isomorphic-dompurify"),e),voidTags=["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"],transformSelfClosing=e=>e.replace(/<([\w\-]+)([^>/]*)\/\s*>/g,((e,t,n)=>voidTags.includes(t.toLowerCase())?e:`<${t}${n}></${t}>`)),retryAsync=async(e,{tryTimes:t=5,interval:n=100,fallback:r,onRetryError:s})=>{for(let i=0;i<t;i++){const a=i+1;try{return await e()}catch(e){if(a>=t){if(!lodash_es_isUndefined(r))return r;throw e}null==s||s(e,i)}const o="number"==typeof n?n:n(a);await timeoutPromise(o)}throw Error("retry times out of limit")},withRetry=(e,t)=>(...n)=>retryAsync((()=>e(...n)),t),resizeImage=({width:e,height:t,minHeight:n,minWidth:r,maxHeight:s,maxWidth:i})=>{const a={width:e,height:t},o=e/t,l=e=>{a.height=e,a.width=e*o},c=e=>{a.width=e,a.height=e/o};return a.width<r&&c(r),a.height<n&&l(n),a.width>i&&c(i),a.height>s&&l(s),(a.width<r||a.width>i||a.height<n||a.height>s)&&console.warn(`[Calypso] Image cannot be resized to the specified size: Natural size: {${e},${t}} Resized size: {${a.width},${a.height}} Min size: {${r},${n}} Max size: {${i},${s}}`),a},createShallowedProvider$1=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}};var LinkTermination=(e=>(e.Include="Include",e.Hard="Hard",e.Soft="Soft",e.Close="Close",e.Open="Open",e))(LinkTermination||{});const DEFAULT_CONFIG={characterMap:new Map,cjkIsHard:!0,hardPattern:/[\s\p{C}]/u,softPattern:/[.,!?;:'"。,!?;:]/u,pairedOpenerMap:new Map([[")","("],["]","["],["}","{"],[">","<"],["』","『"],["」","「"],["〉","〈"],["》","《"]])},CJK_PATTERN=/[\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]/u;class UnicodeURLDetector{constructor(e={}){this.config={...DEFAULT_CONFIG,...e}}getLinkTermination(e){if(this.config.characterMap.has(e))return this.config.characterMap.get(e)??"Include";if(this.config.cjkIsHard&&CJK_PATTERN.test(e))return"Hard";if(this.config.pairedOpenerMap.has(e))return"Close";for(const t of this.config.pairedOpenerMap.values())if(e===t)return"Open";return this.config.hardPattern.test(e)?"Hard":this.config.softPattern.test(e)?"Soft":"Include"}getPairedOpener(e){return this.config.pairedOpenerMap.get(e)||null}detectLink(e,t=0){let n=t;const r=[];for(let s=t;s<e.length;s++){const t=e[s];switch(this.getLinkTermination(t)){case"Include":default:n=s+1;break;case"Soft":{let t=s+1;for(;t<e.length&&"Soft"===this.getLinkTermination(e[t]);)t++;if(t>=e.length||"Hard"===this.getLinkTermination(e[t]))return n;n=s+1;break}case"Hard":return n;case"Open":r.push(t),n=s+1;break;case"Close":{if(0===r.length)return n;const e=r.pop();if(this.getPairedOpener(t)!==e)return n;n=s+1;break}}}return n}findAllLinks(e){const t=[],n=[/https?:\/\/[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]+/gi,/(^|[^a-zA-Z0-9.-])(www\.[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF]*)?)/gi,/(^|[^a-zA-Z0-9.-@])([a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}(?:[^\s\u4E00-\u9FFF\u3400-\u4DBF\u3040-\u309F\u30A0-\u30FF\uAC00-\uD7AF@]*)?)/gi];for(const r of n){let n=r.exec(e);for(;null!==n;){let s=n.index;if(n.length>2&&n[2]){if(s=n.index+(n[0].length-n[2].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(n.length>1&&n[1]&&n[1]!==n[0]){if(s=n.index+(n[0].length-n[1].length),s>0&&"@"===e[s-1]){n=r.exec(e);continue}}else if(s>0&&"@"===e[s-1]){n=r.exec(e);continue}const i=this.detectLink(e,s),a=e.substring(s,i);if(i>s&&this.isValidURL(a)){t.some((e=>s>=e.start&&s<e.end||i>e.start&&i<=e.end))||t.push({start:s,end:i,url:a})}n=r.exec(e)}}return t.sort(((e,t)=>e.start-t.start))}isValidURL(e){if(e.length<4)return!1;if(e.startsWith("http://")||e.startsWith("https://"))return e.length>10;return/^[a-zA-Z0-9][-a-zA-Z0-9]*\.[a-zA-Z]{2,}/.test(e)}}const defaultDetector=new UnicodeURLDetector;function createDetector(e){return new UnicodeURLDetector(e)}var HyperNodeType=(e=>(e[e.text=0]="text",e[e.link=1]="link",e))(HyperNodeType||{});const extractAutolinkDetector=createDetector({}),getHyperLinkNodes$1=e=>{const t=[],n=extractAutolinkDetector.findAllLinks(e);let r=0;for(const s of n){if(r<s.start){const n=e.slice(r,s.start);n&&t.push({type:0,text:n})}const n=e.slice(s.start,s.end);t.push({type:1,url:n}),r=s.end}if(r<e.length){const n=e.slice(r);n&&t.push({type:0,text:n})}return t},completeProtocol$1=e=>e.match(/https?:\/\//)?e:`https://${e}`,isValidEmail=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);class UnicodeHyperLinkParser{constructor(e={}){this.config={enableEmail:!1,autoAddProtocol:!0,...e},this.detector=e.characterMap||void 0!==e.cjkIsHard?createDetector(e):defaultDetector}findEmailAddresses(e){if(!this.config.enableEmail)return[];const t=[],n=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;let r=n.exec(e);for(;null!==r;){const s=r[0];isValidEmail(s)&&t.push({start:r.index,end:r.index+s.length,email:s}),r=n.exec(e)}return t}getHyperLinkNodes(e){const t=[],n=this.detector.findAllLinks(e),r=this.findEmailAddresses(e),s=[...n.map((e=>({...e,type:"link"}))),...r.map((e=>({...e,url:e.email,type:"email"})))].sort(((e,t)=>e.start-t.start));let i=0;for(const n of s){if(i<n.start){const r=e.slice(i,n.start);r&&t.push({type:HyperNodeType.text,text:r})}if("email"===n.type)t.push({type:HyperNodeType.text,text:n.url});else{const e=this.config.autoAddProtocol?completeProtocol$1(n.url):n.url;t.push({type:HyperNodeType.link,url:e})}i=n.end}if(i<e.length){const n=e.slice(i);n&&t.push({type:HyperNodeType.text,text:n})}return t}}const createUnicodeParser=e=>new UnicodeHyperLinkParser(e),defaultUnicodeParser=new UnicodeHyperLinkParser,getHyperLinkNodes=e=>defaultUnicodeParser.getHyperLinkNodes(e),escapeRegExp=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),escapeChars=(e,t)=>{if(t.filter((e=>1!==e.length)).length)throw Error(`illegal chars length: ${t.join(", ")}`);return t.reduce(((e,t)=>{const n=new RegExp(String.raw`([^\\]|^)(${escapeRegExp(t)})`,"g");return e.replace(n,((e,t,n)=>`${t}\\${n}`))}),e)},escapeCharsInLatex=e=>escapeChars(e,["#"]),texPreProcessor=pipe(escapeCharsInLatex),texMathExtract=e=>{let t=0;if(36!==e.charCodeAt(t))return;let n="$";t+=1;const r=e.charCodeAt(t);if(36===r){if(n="$$",t+=1,36===e.charCodeAt(t))return}else if(32===r||9===r||10===r)return;const s=e.indexOf(n,t);if(-1===s)return;if(92===e.charCodeAt(s-1))return;const i=s+n.length;if(1===n.length){const t=e.charCodeAt(s-1);if(32===t||9===t||10===t)return;const n=e.charCodeAt(i);if(n>=48&&n<58)return}return{type:1===n.length?"inline":"block",mathText:e.slice(t,s),endIndex:i}},katexTryParseOptions={throwOnError:!0,strict:!0,output:"mathml",trust:!1},katexCheckTex=(e,t)=>{try{return e.renderToString(texPreProcessor(t),katexTryParseOptions),!0}catch(t){if(t instanceof e.ParseError)return!1;throw t}},katexParseErrorIndex=(e,t)=>{try{e.renderToString(texPreProcessor(t),katexTryParseOptions)}catch(t){if(t instanceof e.ParseError)return t.position}},customCheckTex=e=>![/\([^\)]*$/].some((t=>t.test(e))),checkTex=({tex:e,katex:t})=>katexCheckTex(t,e)&&customCheckTex(e),findMaxLegalPrefixEndIndex=({src:e,katex:t})=>{let n=katexParseErrorIndex(t,e)??e.length;for(;n>=0;){const r=e.slice(0,n);if(checkTex({tex:r,katex:t}))return n;n-=1}return n},INSERT_ELEMENT_SLOT_NAME="insert_element",getTextSlotString=e=>`{${e}}`,getInsertElementSlotString=({data:e,index:t,wrapWith:n=""})=>`${n}${getTextSlotString(`insert_element_${t}_${node_modules_buffer.Buffer.from(e).toString("base64")}`.replace(/_/g,"\\_"))}${n}`,insertElementSlotRegex=`\\{${"insert_element".replace(/_/g,"\\\\_")}\\\\_(?<index>[0-9]+)\\\\_(?<b64_data>.*?)\\}`,startOfInsertElementSlot=e=>{var t;return null==(t=new RegExp(insertElementSlotRegex).exec(e))?void 0:t.index},matchInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}`).exec(e);return null==t?void 0:t[0]},extractDataFromInsertElementSlot=e=>{const t=new RegExp(`^${insertElementSlotRegex}$`).exec(e),{index:n,b64_data:r}=(null==t?void 0:t.groups)||{};if(!lodash_es_isUndefined(n)&&!lodash_es_isUndefined(r))return{index:parseInt(n),b64Text:r,text:r&&node_modules_buffer.Buffer.from(r,"base64").toString("utf8")}},convertToOperation=(e,t)=>{const n=[],r={inline:"",newline:"\n",block:"\n\n"};return t.forEach((({range:t,type:s="inline"},i)=>{const a=lodash_es_isNumber(t)?[t,t]:t,[o,l]=a;o>l||o>e.length||n.push({replaceRange:lodash_es_isNumber(t)?[t,t]:t,insert:getInsertElementSlotString({index:i,data:e.slice(...a),wrapWith:r[s]}),index:n.length})})),n},transformOperationInOrder=(e,t)=>{const[n,r]=e.replaceRange,[s,i]=t.replaceRange,a=t.insert.length-(i-s);if(n<s)return e;if(n===s&&e.index<t.index)return e;const o=Math.min(Math.max(0,i-n),r-n);return{...e,replaceRange:[n+a+o,r+a]}},transformEach=e=>{const t=[];for(let n=0;n<e.length;n+=1){let r=e[n];for(let e=0;e<t.length;e+=1)r=transformOperationInOrder(r,t[e]);t.push(r)}return t},applyOperationToString=(e,t)=>{const{replaceRange:[n,r],insert:s}=t;return`${e.slice(0,n)}${s}${e.slice(r)}`},applyInsertListToString=(e,t)=>{const n=transformEach(convertToOperation(e,t));return pipe(...n.map((e=>t=>applyOperationToString(t,e))))(e)},addInsertElementSlotToString=(e,t)=>applyInsertListToString(e,t),removeInsertElementSlotInString=e=>e.replace(new RegExp(insertElementSlotRegex,"g"),(e=>{const t=extractDataFromInsertElementSlot(e);return t?t.text:""})),INLINE_MATH_SPAN_DATA_TYPE="inline-math",BLOCK_MATH_SPAN_DATA_TYPE="block-math",renderSpanString=(e,t)=>`<span data-type="${e}" data-value="${node_modules_buffer.Buffer.from(t).toString("base64")}"></span>`,renderInlineMathSpanString=e=>renderSpanString("inline-math",texPreProcessor(removeInsertElementSlotInString(e))),renderBlockMathSpanString=e=>renderSpanString("block-math",texPreProcessor(removeInsertElementSlotInString(e))),restoreMathPandocLatex=e=>e.replace(new RegExp('<span data-type="inline-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\(${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\)`)).replace(new RegExp('<span data-type="block-math" data-value="(.*?)"></span>',"g"),((e,t)=>String.raw`\[${node_modules_buffer.Buffer.from(t,"base64").toString("utf8")}\]`)),parseMarkdown=(e,t={})=>fromMarkdown(e,{extensions:[all_in_one_index_math(),syntax_gfmTable,disableSetextHeading(),...t.enableIndentedCode?[]:[disableIndentedCode()],gfmStrikethrough({singleTilde:!1}),gfmTaskListItem],mdastExtensions:[mathFromMarkdown(),gfmTableFromMarkdown,gfmStrikethroughFromMarkdown,gfmTaskListItemFromMarkdown]}),stringifyMarkdown=(e,t=!1)=>{const n=toMarkdown(e,{extensions:[mathToMarkdown(),gfmTableToMarkdown(),gfmStrikethroughToMarkdown,gfmTaskListItemToMarkdown],resourceLink:!0,fences:!0});return t?n.trim():n},stringifyChildren=(e,t=!1)=>{if(!e.length)return"";const n=stringifyMarkdown({type:"root",children:e},!0);return t?n.replace(/\n/g,""):n},isParentOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),all_in_one_index_isParent=e=>!lodash_es_isUndefined(null==e?void 0:e.children),isLiteralOfContent=e=>!lodash_es_isUndefined(null==e?void 0:e.value),all_in_one_index_isImage=e=>"image"===(null==e?void 0:e.type),isRoot=e=>"root"===(null==e?void 0:e.type),isTypeOfContent=(e,...t)=>t.some((t=>(null==e?void 0:e.type)===t)),isHeading=e=>isParentOfContent(e)&&"heading"===e.type,getTextOfAst=(e,t={})=>{const{filter:n}=t;return n&&!n(e)?"":isParentOfContent(e)?`${e.children.map((e=>getTextOfAst(e,t))).join("")}\n`:isLiteralOfContent(e)?e.value:""},DEFAULT_ENABLED_ROOT_TAGS=["span","u","br"],matchTagNameOfHtmlTag=e=>{var t,n;const r=[/<(?<tag>[a-zA-Z]+)(\s+([a-zA-Z]+=(("[^"]*")|('[^']*'))))*\s*\/?>/,/<\/(?<tag>[a-zA-Z]+)>/];for(const s of r){const r=s.exec(e);if(r)return null==(n=null==(t=r.groups)?void 0:t.tag)?void 0:n.toLowerCase()}},getTagNameOfHtml=e=>{var t;const n=matchTagNameOfHtmlTag(e);if("undefined"==typeof DOMParser)return n;const r=new DOMParser,s=elementAt([...r.parseFromString(e,"text/html").body.children],0);return(null==(t=null==s?void 0:s.tagName)?void 0:t.toLowerCase())||n},autoDisableHtmlTag=(e,t=[])=>{const n=getTagNameOfHtml(e);if(!0===t)return e;const r=[...DEFAULT_ENABLED_ROOT_TAGS,...t||[]];return n&&!r.includes(n)?he.encode(e,{strict:!1}):e},stringifyDomNode=e=>esm(e,{encodeEntities:!1,decodeEntities:!0}),INSERT_ELEMENT_SLOT_EXTENSION_NAME="insert_element_extension",insertElementSlotExtension=()=>({name:"insert_element_extension",level:"inline",start:e=>startOfInsertElementSlot(e),tokenizer(e){const t=matchInsertElementSlot(e);if(t)return{type:"insert_element_extension",raw:t}},renderer({raw:e}){if(!e)return!1;const t=extractDataFromInsertElementSlot(e);if(!t)return!1;const{index:n,b64Text:r}=t;return`<span data-index="${n}" data-raw="${r}" data-type="insert_element_extension"></span>`}}),inlineTex=()=>({name:"inlineTex",level:"inline",start(e){var t;return null==(t=/\$([^\$]|$)/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"inline"===n?{type:"inlineTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderInlineMathSpanString(e.mathText)}),displayTex=()=>({name:"displayTex",level:"block",start(e){var t;return null==(t=/\$\$[^\$]+\$\$/.exec(e))?void 0:t.index},tokenizer(e){const t=texMathExtract(e);if(!t)return;const{type:n,endIndex:r,mathText:s}=t;return"block"===n?{type:"displayTex",raw:e.slice(0,r),mathText:s}:void 0},renderer:e=>renderBlockMathSpanString(e.mathText)}),escapeTest=/[&<>"']/,escapeReplace=new RegExp(escapeTest.source,"g"),escapeTestNoEncode=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode=new RegExp(escapeTestNoEncode.source,"g"),all_in_one_index_escapeReplacements={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},escapeMarkdownText=(e,t=!1)=>{const n=e=>all_in_one_index_escapeReplacements[e];if(t){if(escapeTest.test(e))return e.replace(escapeReplace,n)}else if(escapeTestNoEncode.test(e))return e.replace(escapeReplaceNoEncode,n);return e},getCalypsoRenderer=(e={})=>{const{enabledHtmlTags:t}=e;return new class extends _Renderer{html({text:e}){return autoDisableHtmlTag(e,t)}code({text:e,lang:t="",escaped:n}){const r=t.match(/^\s*(?<language>\S+)\s*(?<meta>[\S\s]*?)\s*$/),s=`${e.replace(/\n$/,"")}\n`;if(!r)return`<pre><code>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`;const{groups:i={}}=r,{language:a,meta:o}=i;return`<pre><code type="test" class="language-${escapeMarkdownText(a)}"${o?` data-meta="${escapeMarkdownText(o)}"`:""}>${n?s:escapeMarkdownText(s,!0)}</code></pre>\n`}}(e)},gfmDelRegex=/^(~~)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/;class CalypsoTokenizer extends _Tokenizer{autolink(e){}del(e){const t=gfmDelRegex.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}url(){}}const getHopDiff=(e,t)=>{if(e.type!==t.type)return isParentOfContent(e)&&isParentOfContent(t)?{prevEndNode:e,endNode:t}:null;if(!lodash_es_isEqual(e.children.map((e=>e.type)),t.children.map((e=>e.type))))return{prevEndNode:elementAt(e.children,e.children.length-1),endNode:elementAt(t.children,t.children.length-1)};for(let n=0;n<e.children.length;n++){const r=e.children[n],s=t.children[n];if(all_in_one_index_isParent(r)&&all_in_one_index_isParent(s)){const e=getHopDiff(r,s);if(e)return e}else{if(all_in_one_index_isParent(r)||all_in_one_index_isParent(s))return{prevEndNode:r,endNode:s};if(r.type!==s.type)return{prevEndNode:r,endNode:s}}}return null},standardNodeTypeMapping={thematicBreak:"thematic",heading:"heading",code:"code_block",html:"html",linkReference:"link_def_ref",paragraph:"paragraph",table:"table",blockquote:"block_quote",list:"list",listItem:"list_item",inlineCode:"inline_code",emphasis:"emphasis",strong:"strong",link:"link",image:"image",delete:"strike_through",text:"text",math:"math_block",inlineMath:"inline_math"},convertToStanardNodeTypeEnum=e=>e?standardNodeTypeMapping[e]??"unknown":"empty",updateAst=(e,t,n={})=>{const{order:r="pre_order",isReverse:s=!1}=n;let i=!1,a=!1,o=!1;const l=[[[],e]],c=[];for(;l.length;){const e=l.pop();assert(e,"current must not be undefined");const[n,u]=e,d=lodash_es_head(n),p=all_in_one_index_isParent(u)?u.children.slice():[],m=s?p:p.reverse(),g=all_in_one_index_isParent(u)?m.map((e=>[[u,...n],e])):[],h=(e,t=!1)=>{if(!d)return;const n=d.children.findIndex((e=>e===u));assert(lodash_es_isNumber(n),"Invoke insertAfter error in updateAst: parent is not parent of current"),t?d.children.splice(n,1,...e):d.children.splice(n+1,0,...e)},f=()=>{if(o)throw Error("You have to call stop synchronously");i=!0},x=()=>{if(o)throw Error("You have to call skip synchronously");a=!0},y=()=>{const e=null==d?void 0:d.children.findIndex((e=>e===u));assert(-1!==e,"Current must be child of it's parent"),t(u,{stop:f,skip:x,insertAfter:h,parent:d,parents:n,index:e})};if("pre_order"===r)y(),a||l.push(...g);else if("post_order"===r){const t=g.filter((([,e])=>!c.includes(e)));t.length?(l.push(e),l.push(...t)):(y(),c.push(u))}else"in_order"===r&&(all_in_one_index_isParent(u)&&g.length&&g.every((([,e])=>!c.includes(e)))?(l.push(...g.slice(0,g.length-1)),l.push(e),l.push(g[g.length-1])):(y(),c.push(u)));if(i)break;i=!1,a=!1}o=!0};var AstPluginPriority=(e=>(e[e.BeforeAll=-2]="BeforeAll",e[e.Before=-1]="Before",e[e.Normal=0]="Normal",e[e.After=1]="After",e[e.AfterAll=2]="AfterAll",e))(AstPluginPriority||{});class BaseAstPlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const modifyByCurrentPlugin=({plugin:e,ast:t,skipWhenError:n=!0,...r})=>{const s=lodash_es_isFunction(e.modifier)?[e.modifier.bind(e)]:e.modifier.map((t=>t.bind(e)));e.before(t);for(const i of s){e.beforeEach(t);try{updateAst(t,((t,n)=>i(t,{...n,recursiveModifier(t){modifyByCurrentPlugin({plugin:e,ast:t,...r})},...r})),e.config)}catch(t){if(!n)throw t;console.error(`[Calypso source plugin error: ${e.name}]`,t)}e.afterEach(t)}e.after(t)},processAstByPlugins=({ast:e,plugins:t,fixEnding:n=!1,skipWhenError:r,...s})=>{const i=lodash_es_sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??AstPluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})),a=lodash_es_cloneDeep(e);for(const e of i)modifyByCurrentPlugin({plugin:e,ast:a,skipWhenError:r,...s});return a};var SourcePluginPriority=(e=>(e[e.BeforeAll=-1]="BeforeAll",e[e.Normal=0]="Normal",e[e.AfterAll=1]="AfterAll",e))(SourcePluginPriority||{});class BaseSourcePlugin{constructor(){this.config={},this.before=lodash_es_noop,this.after=lodash_es_noop,this.beforeEach=lodash_es_noop,this.afterEach=lodash_es_noop}}const processSourceByPlugins=({source:e,plugins:t,fixEnding:n=!1,katex:r,skipWhenError:s=!0})=>lodash_es_sortBy(t,(e=>{var t;return(null==(t=e.config)?void 0:t.priority)??SourcePluginPriority.Normal})).filter((e=>{const{fixEndingOnly:t=!1}=e.config??{};return!t||n})).reduce(((e,t)=>{t.before(e);const n=(lodash_es_isFunction(t.modifier)?[t.modifier.bind(t)]:t.modifier.map((e=>e.bind(t)))).reduce(((e,n)=>{try{t.beforeEach(e);const s=n({source:e,katex:r});return t.afterEach(s),s}catch(n){if(!s)throw n;return console.error(`[Calypso source plugin error: ${t.name}]`,n),e}}),e);return t.after(n),n}),e);class AutofixLastCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r,s;if(isLiteralOfContent(e))if(n(),"code"===e.type){const{content:n}=(null==(r=e.value.match(/^(?<content>[\S\s]*?)\n`+$/))?void 0:r.groups)||{};if(!lodash_es_isString(n))return;t([{...e,value:n}],!0)}else if("text"===e.type){const{prefix:n}=(null==(s=e.value.match(/^(?<prefix>[\s\S]*?)`{1,2}$/))?void 0:s.groups)||{};if(!lodash_es_isString(n))return;t(n?[{type:"text",value:n}]:[],!0)}}}}const getLastTextNodeByRegex=(e,t)=>{const n=lodash_es_findLast(e.children,(e=>Boolean("text"===e.type&&e.value.match(t))));if(!n)return;assert("text"===n.type,"lastUnPaired.type must be text");const r=e.children.findIndex((e=>e===n));return assert(r>=0,"lastUnPairedIndex must >= 0"),{target:n,index:r}},UNPAIRED_REGEX=/^(?<prefix>.*([^\\`]|^))`(?!`)(?<suffix>.*?)$/;class AutofixLastInlineCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_last_inline_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{stop:t})=>{var n;if(!all_in_one_index_isParent(e))return;t();const r=getLastTextNodeByRegex(e,UNPAIRED_REGEX);if(!r)return;const{target:s,index:i}=r;if(e.children.slice(i+1).find((e=>"inlineCode"===e.type)))return;const{prefix:a,suffix:o}=(null==(n=s.value.match(UNPAIRED_REGEX))?void 0:n.groups)||{};if(!lodash_es_isString(o)||!lodash_es_isString(a))return;const l=[];a&&l.push({type:"text",value:a});const c=`${o}${stringifyChildren(e.children.slice(i+1),!0)}`;c&&l.push({type:"inlineCode",value:c}),e.children.splice(i,e.children.length-i,...l)}}}const truncatedHtmlRegexList=[/<([a-zA-Z\-]+((\s+([a-zA-Z\-]+=(("[^"]*")|('[^']*'))))*(\s*\/?|(\s+[a-zA-Z\-]+(=(("[^"]*)|('[^']*))?)?)))?)?$/,/<\/([a-zA-Z\-]+)?$/],truncatedDataSlotRegexList=[/<data-(inline|block)(\s.*)?$/],truncateTruncatedHtmlSuffix=(e,t={})=>{const{looseTruncateDataSlot:n=!1}=t,r=firstMatch(lodash_es_concat(truncatedHtmlRegexList,n?truncatedDataSlotRegexList:[]),(t=>t.exec(e)));return r?e.slice(0,r.index):e};class AutofixTruncatedHtmlTagAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_html_tag",this.config={isReverse:!0},this.modifier=(e,{insertAfter:t,stop:n,looseTruncateDataSlot:r=!1})=>{if(!isTypeOfContent(e,"text","html"))return;n();const s=truncateTruncatedHtmlSuffix(e.value,{looseTruncateDataSlot:r});t(s?[{type:e.type,value:s}]:[],!0)}}}class AutofixTruncatedLinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_link",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(isTypeOfContent(e,"link"))return void n();if(all_in_one_index_isParent(e)||"text"!==e.type&&"html"!==e.type)return;n();const s=[/\[(?<text>\[[^\]\n]*)$/,/\[(?<text>\[[^\]\n]+\])$/,/\[(?<text>\[[^\]\n]+\])\]$/,/\[(?<text>\[[^\]\n]+\])\]\([^\)\n]*$/,/\[(?<text>[^\]\n]*)$/,/\[(?<text>[^\]\n]+)\]$/,/\[(?<text>[^\]\n]+)\]\([^\)\n]*$/].find((t=>t.exec(e.value)));if(!s)return;const i=s.exec(e.value);if(!i)return;const a=null==(r=i.groups)?void 0:r.text,o=i.index;t(a?[{type:e.type,value:e.value.slice(0,o)},{type:"link",title:null,url:"#",children:[{type:"text",value:a}]}]:[{type:e.type,value:e.value.slice(0,o)}],!0)}}}class AutofixTruncatedImageAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_image",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,removeTruncatedImage:r=!1})=>{var s;const i=[/!$/,/!\[$/,/!\[(?<text>[^\]]*)$/,/!\[(?<text>[^\]]*)\]$/,/!\[(?<text>[^\]]*)\]\([^\)]*$/],a=r?i:i.slice(0,1),o=r?[]:i.slice(1);if(!isLiteralOfContent(e))return;if(n(),"text"!==e.type)return;const l=o.find((t=>t.exec(e.value))),c=a.find((t=>t.exec(e.value)));if(!c&&!l)return;const u=c??l;if(!u)return;const d=u.exec(e.value);d&&t(lodash_es_concat({type:"text",value:e.value.slice(0,d.index)},l?{type:"image",url:"",alt:(null==(s=d.groups)?void 0:s.text)||"image"}:[]),!0)}}}class AutofixTruncatedEscapePlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_escape",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{var r;if(all_in_one_index_isParent(e)||"text"!==e.type)return;n();const s=e.value.match(/^(?<text>[\s\S]*)\\$/);if(!s)return;t([{type:"text",value:(null==(r=s.groups)?void 0:r.text)??""}],!0)}}}const completeProtocol=e=>e.match(/https?:\/\//)?e:`https://${e}`;class ExtractCustomAutolinkAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,skip:n})=>{if(all_in_one_index_isParent(e))return void(isParentOfContent(e)&&"link"===e.type&&n());if("text"!==e.type)return;t(getHyperLinkNodes$1(e.value).map((e=>{if(e.type===HyperNodeType.link){const t=e;return{type:"link",url:completeProtocol(t.url),title:"autolink",children:[{type:"text",value:t.url}]}}if(e.type===HyperNodeType.text){return{type:"text",value:e.text}}return null})).filter((e=>Boolean(e))),!0)}}}const indicatorItem={type:"html",value:'<span class="indicator" />'};class InsertIndicatorAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_indicator",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{if(all_in_one_index_isImage(e))n();else{if(isParentOfContent(e)&&"listItem"===e.type&&!stringifyChildren(e.children,!0).trim())return n(),void t([{...e,children:[indicatorItem]}],!0);if(isLiteralOfContent(e)){if(n(),"code"===e.type)return;t([indicatorItem])}}}}}const mergeTextChildren=e=>{const{children:t}=e,n=[];let r="";for(let e=0;e<t.length;e++){const s=t[e];"text"===s.type&&(r+=s.value),"text"===s.type&&e!==t.length-1||(r&&n.push({type:"text",value:r}),r=""),"text"!==s.type&&n.push(s)}e.children=n};class AutoMergeSiblingTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="extract_custom_autolink",this.config={priority:AstPluginPriority.AfterAll},this.modifier=(e,{skip:t,recursiveModifier:n})=>{if(isParentOfContent(e)){mergeTextChildren(e),t();for(const t of e.children)all_in_one_index_isParent(t)&&n(t)}}}}const indexOfFirstLegalDollar=e=>{var t;const n=e.match(/(?<prefix>[^\$\\]|^)(\$|\$\$)(?!\$)/);if(!n)return-1;const{index:r=0}=n,s=null==(t=null==n?void 0:n.groups)?void 0:t.prefix;return lodash_es_isString(s)?r+s.length:-1},lengthOfDollorPrefix=e=>{const t=e.match(/^\$*/);return t?t[0].length:0},findStartIndexOfNoneTexSuffix=e=>{let t=indexOfFirstLegalDollar(e),n=0,r=!0;for(;-1!==t;){const s=texMathExtract(e.slice(t));if(s){const{endIndex:e}=s;t+=e,r=!1,n=t}else{const n=indexOfFirstLegalDollar(e.slice(t));if(-1===n)break;t+=r?Math.max(n,lengthOfDollorPrefix(e.slice(t))):n,r=!0}}return n},RAW_NUMBER_REST_STRING_LENGTH_THRESHOLD=10,enSentenceRegexFullMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]$/,enSentenceRegexWithCountOfPrefixMatch=/^[0-9a-zA-Z\s"'\.,\-\(\)]{15}/,unpairedLongMathRegex=/^\s*(\\begin)/,shouldStopAutofix=(e,t)=>{const n=e.trim(),r=n.slice(0,t),s=n.length;return!unpairedLongMathRegex.exec(n)&&(!r||isNumeric(r)?s-t>10:!!(enSentenceRegexFullMatch.exec(r)&&s-t>10)||!!enSentenceRegexWithCountOfPrefixMatch.exec(r))};class AutofixTruncatedTexMathDollarAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_tex_math_dollar",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,katex:r})=>{if(r&&!all_in_one_index_isParent(e))if(isLiteralOfContent(e)&&n(),"text"===e.type){const n=findStartIndexOfNoneTexSuffix(e.value),s=e.value.slice(n).match(/^(?<prefix>[\s\S]*?([^\$\\]|^))(?<inter>\$|\$\$)(?!\$)(?<value>[^\$]*?)(?<suffix>\$*)$/),i=null==s?void 0:s.groups;if(!i)return;const{prefix:a,value:o}=i,l=findMaxLegalPrefixEndIndex({src:o,katex:r});if(shouldStopAutofix(o,l))return;const c=o.slice(0,l).trim(),u=`${e.value.slice(0,n)}${a}`;t(lodash_es_concat(u?{type:"text",value:u}:[],c?{type:"inlineMath",value:c}:[]),!0)}else if("inlineMath"===e.type||"math"===e.type){const n="math"===e.type?e.meta??e.value:e.value,s=findMaxLegalPrefixEndIndex({src:n,katex:r});if(shouldStopAutofix(n,s)){return void t(["inlineMath"===e.type?{type:"text",value:`$${n}$`}:{type:"paragraph",children:[{type:"text",value:`$$${n}$$`}]}],!0)}const i=n.slice(0,s).trim(),a="inlineMath"===e.type?{type:"inlineMath",value:i}:{type:"paragraph",children:[{type:"inlineMath",value:i}]};t(i?[a]:[],!0)}}}}class AutofixHeadingAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_heading",this.config={order:"pre_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{all_in_one_index_isParent(e)?isHeading(e)&&(1!==e.depth||stringifyChildren(e.children).trim()||t([],!0),n()):n()}}}const all_in_one_index_ellipsisContent="...";class InsertEllipsisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="insert_ellipsis",this.config={isReverse:!0,priority:AstPluginPriority.After},this.modifier=(e,{insertAfter:t,stop:n})=>{isParentOfContent(e)&&!isTypeOfContent(e,"link")||(n(),isTypeOfContent(e,"text")&&t([{type:"text",value:`${e.value}...`}],!0),isTypeOfContent(e,"link","inlineCode")&&t([{type:"text",value:"..."}],!1))}}}class RemoveBreakBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_break_before_html",this.modifier=(e,{parent:t,index:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!t||lodash_es_isUndefined(n))return;const r=getByIndex(null==t?void 0:t.children,n-1);r&&"break"===r.type&&t.children.splice(n-1,1)}}}class TransformEndlineBeforeHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="transform_endline_before_html",this.config={order:"pre_order"},this.modifier=(e,{index:t,parent:n})=>{if(!isLiteralOfContent(e)||"html"!==e.type||!n||!t)return;const r=n.children[t-1];if("text"!==r.type)return;const s=/(\r?\n|\r)$/;s.test(r.value)&&n.children.splice(t-1,1,{type:"text",value:r.value.replace(s,"")},{type:"html",value:"<br />"})}}}class DisableIllegalHtmlAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="disable_illegal_html",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t,enabledHtmlTags:n})=>{isLiteralOfContent(e)&&"html"===e.type&&t([{type:"html",value:autoDisableHtmlTag(e.value,n)}],!0)}}}class RestoreMathPandocLatexInContentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="restore_math_pandoc_latex_in_content",this.config={order:"pre_order"},this.modifier=(e,{insertAfter:t})=>{isLiteralOfContent(e)&&isTypeOfContent(e,"code","inlineCode","math","inlineMath")&&t([{...e,value:restoreMathPandocLatex(e.value)}],!0)}}}const autoSpacingGroupPatterns=[String.raw`\{${"insert_element"}_[0-9]+_.*?\}`];class AutoSpacingAllTextAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="auto_spacing_all_text",this.config={priority:AstPluginPriority.AfterAll,order:"pre_order",isReverse:!0},this.modifier=(e,{insertAfter:t})=>{if(!isTypeOfContent(e,"text"))return;const{value:n}=e;t([{type:"text",value:splitStringByPattern(n,new RegExp(`(${autoSpacingGroupPatterns.map((e=>`(${e})`)).join("|")})`,"g")).map((e=>pangu.spacing(e))).join("")}],!0)}}}class AutofixTruncatedStrongAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_strong",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,parent:r})=>{var s;if(!isTypeOfContent(e,"text")||!r||!isTypeOfContent(r,"paragraph"))return void n();const i=null==(s=e.value.match(/^(?<prefix>[\s\S]*?)(_{2}|\*{2})(?<suffix>[\s\S]*?)\*?$/))?void 0:s.groups;if(!i)return;const{prefix:a,suffix:o}=i,l=[];a&&l.push({type:"text",value:a}),o&&l.push({type:"strong",children:[{type:"text",value:o}]}),t(l,!0)},(e,{stop:t,parent:n,index:r})=>{if(!isParentOfContent(e))return;if(!isTypeOfContent(e,"emphasis")||!n||lodash_es_isUndefined(r))return void t();const s=n.children[r-1];if(!s||!isTypeOfContent(s,"text"))return void t();const i=/(?<prefix>(.*[^\*])|^)\*$/.exec(s.value);if(!i)return void t();const{prefix:a}=i.groups??{},o=[];a&&o.push({type:"text",value:a}),o.push({type:"strong",children:e.children}),n.children.splice(r-1,2,...o)},(e,{stop:t,insertAfter:n})=>{if(isParentOfContent(e)&&"listItem"!==e.type){if("list"===e.type)return!e.children.length||1===e.children.length&&!e.children[0].children.length?(n([],!0),void t()):void 0;t()}}]}}const splitByLastSingleAsterisk=e=>{if(e.includes("*"))for(let t=e.length-1;t>=0;t--){const n=e[t],r=e[t-1],s=e[t+1];if("*"===n&&"*"!==r&&"*"!==s)return[e.slice(0,t),e.slice(t+1)]}};class AutofixTruncatedEmphasisAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_emphasis",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n,parent:r})=>{if(isLiteralOfContent(e)&&r&&isTypeOfContent(r,"paragraph")){if("text"===e.type){const n=splitByLastSingleAsterisk(e.value);if(!n)return;const[r,s]=n,i=[];r&&i.push({type:"text",value:r}),s&&i.push({type:"emphasis",children:[{type:"text",value:s}]}),t(i,!0)}}else n()}}}class AutofixTruncatedListAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="autofix_truncated_list",this.config={isReverse:!0,fixEndingOnly:!0},this.modifier=[(e,{insertAfter:t,stop:n,index:r,parent:s})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(lodash_es_isUndefined(r)||0!==r||!s||s.children.length>1)return void n();const i=/^(?<prefix>.*)\n\s*(?<value>([0-9]+?\.?)|(\-\s*))$/.exec(e.value);if(i){const{prefix:e}=i.groups??{};t([{type:"text",value:e}],!0)}else/^\s*[0-9]+$/.exec(e.value)&&t([],!0);n()},(e,{insertAfter:t,stop:n,index:r,parent:s,parents:i})=>{if(all_in_one_index_isParent(e))return void(isTypeOfContent(e,"list","listItem","paragraph")||isRoot(e)||n());if(!isTypeOfContent(e,"text"))return void n();if(!(s&&isTypeOfContent(i[0],"paragraph")&&isTypeOfContent(i[1],"listItem")&&isTypeOfContent(i[2],"list")))return void n();if(r!==s.children.length-1)return void n();const a=/^(?<prefix>.*)\n\s*(?<value>[0-9]+?)$/.exec(e.value);if(a){const{prefix:e}=a.groups??{};t([{type:"text",value:e}],!0)}n()}]}}class SetEmphasisAsImageTitleAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_emphasis_as_image_title",this.config={order:"pre_order",isReverse:!0},this.modifier=(e,{parent:t,index:n})=>{if(!t||lodash_es_isUndefined(n)||!all_in_one_index_isImage(e))return;const r=getByIndex(t.children,n+1),s=getByIndex(t.children,n+2);if(!r||!s)return;if(!isTypeOfContent(r,"text")||"\n"!==r.value)return;if(!isTypeOfContent(s,"emphasis"))return;const{children:i}=s,{url:a}=e,o=stringifyChildren(i,!0);t.children.splice(n,3,{type:"image",url:a,alt:o})}}}const getStartIndexOfCodeBlockFirstLine=e=>{var t;const n=e.match(/^(?<prefix>[\s]+)```/);return n?(null==(t=n.groups)?void 0:t.prefix.length)??null:null};class SetCodeBlockIndentAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="set_code_block_indent",this.modifier=(e,{source:t,parent:n,insertAfter:r,skip:s})=>{if(all_in_one_index_isParent(e)&&n)return void s();if(!isLiteralOfContent(e))return;if("code"!==e.type)return;const{start:i}=e.position??{};if(!i)return;const{line:a}=i,o=getByIndex(t.split("\n"),a-1),{meta:l,lang:c}=e;if(lodash_es_isUndefined(o))return;const u=getStartIndexOfCodeBlockFirstLine(o);if(null===u)return;const d=`__indent=${u}`,p=l?`${d} ${l}`:d;r([{...e,meta:p,lang:c??"plaintext"}],!0)}}}class RemoveLastEmptyCodeBlockAstPlugin extends BaseAstPlugin{constructor(){super(...arguments),this.name="remove_last_empty_code_block",this.config={order:"in_order",isReverse:!0,fixEndingOnly:!0},this.modifier=(e,{insertAfter:t,stop:n})=>{if(!isLiteralOfContent(e))return;if(n(),"code"!==e.type)return;const{value:r,lang:s,meta:i}=e;r||s||i||t([],!0)}}}class CompleteTruncatedLinkSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_truncated_link",this.modifier=({source:e})=>e.replace(/(^|[^!])\[(?<text>[^\]\n]+)\]\([^\)\n]*$/,"$1[$2](#)")}}class CompleteUnpairedCodeBlockSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="complete_unpaired_code_block",this.modifier=({source:e})=>{const t=e.match(/(^|\n)[\s]*?```/g);return t?t.length%2==0?e:`${e.trimEnd()}\n\`\`\``:e}}}class ConvertFullMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_full_math_pandoc_latex",this.modifier=({source:e})=>e.replace(/\\\(([\s\S]*?)\\\)/g,((e,t)=>renderInlineMathSpanString(t))).replace(/\\\[([\s\S]*?)\\\]/g,((e,t)=>renderBlockMathSpanString(t)))}}class ConvertEndingMathPandocLatexSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="convert_ending_math_pandoc_latex",this.config={fixEndingOnly:!0},this.modifier=[({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\((?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\()|(\\\)))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderInlineMathSpanString(i)}`:s},({source:e,katex:t})=>{if(!t)return e;const n=e.match(/(?<prefix>.*?)\\\[(?<ending>[\s\S]*?)$/);if(!(null==n?void 0:n.groups)||lodash_es_isUndefined(n.index))return e;const r=n.groups.ending??"",s=n.groups.prefix??"";if(r.match(/((\\\[)|(\\\]))/))return e;const i=r.slice(0,findMaxLegalPrefixEndIndex({src:r,katex:t})).trim();return i?`${s}${renderBlockMathSpanString(i)}`:s}]}}class RemoveLongSpacesSourcePlugin extends BaseSourcePlugin{constructor(){super(...arguments),this.name="remove_long_spaces",this.modifier=({source:e})=>e.replace(/[ ]{500,}/g,(e=>e.slice(0,500)))}}const getAstPlugins=({astPlugins:e,autoSpacing:t=!0,autolink:n=!0,imageEmphasisTitle:r=!1,indentFencedCode:s=!0,showIndicator:i=!1,showEllipsis:a=!1})=>{let o=[new AutofixTruncatedEscapePlugin,new RemoveLastEmptyCodeBlockAstPlugin,new AutofixLastCodeBlockAstPlugin,new AutofixLastInlineCodeBlockAstPlugin,new AutofixTruncatedTexMathDollarAstPlugin,new AutofixTruncatedImageAstPlugin,new AutofixTruncatedLinkAstPlugin,new AutofixHeadingAstPlugin,new AutofixTruncatedHtmlTagAstPlugin,new AutofixTruncatedStrongAstPlugin,new AutofixTruncatedEmphasisAstPlugin,new AutofixTruncatedListAstPlugin,new RestoreMathPandocLatexInContentAstPlugin,new DisableIllegalHtmlAstPlugin,new RemoveBreakBeforeHtmlAstPlugin,new TransformEndlineBeforeHtmlAstPlugin,new AutoMergeSiblingTextAstPlugin];return n&&o.push(new ExtractCustomAutolinkAstPlugin),t&&o.push(new AutoSpacingAllTextAstPlugin),r&&o.push(new SetEmphasisAsImageTitleAstPlugin),s&&o.push(new SetCodeBlockIndentAstPlugin),a&&o.push(new InsertEllipsisAstPlugin),i&&o.push(new InsertIndicatorAstPlugin),lodash_es_isArray(e)&&o.push(...e),lodash_es_isFunction(e)&&(o=e(o)),o},getSourcePlugins=({sourcePlugins:e})=>{let t=[new RemoveLongSpacesSourcePlugin,new CompleteUnpairedCodeBlockSourcePlugin,new CompleteTruncatedLinkSourcePlugin,new ConvertFullMathPandocLatexSourcePlugin,new ConvertEndingMathPandocLatexSourcePlugin];return lodash_es_isArray(e)&&t.push(...e),lodash_es_isFunction(e)&&(t=e(t)),t},parseMarkdownAndProcessByPlugins=({source:e,astPlugins:t,sourcePlugins:n,parseAst:r=!0,indentedCode:s=!1,insertedElements:i,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})=>{try{let d,p=e;return i&&(p=addInsertElementSlotToString(p,i)),n&&(p=processSourceByPlugins({source:p,plugins:n,fixEnding:a,katex:u})),r&&(d=parseMarkdown(p,{enableIndentedCode:s})),t&&d&&(d=processAstByPlugins({ast:d,plugins:t,source:p,fixEnding:a,enabledHtmlTags:o,looseTruncateDataSlot:l,removeTruncatedImage:c,katex:u})),{ast:d,source:d?stringifyMarkdown(d):p}}catch(t){return console.error("[Calypso] Process markdown error: ",t),{source:e}}},parseMarkdownAndProcess=({source:e,processAst:t=!0,processSource:n=!0,showEllipsis:r,showIndicator:s,imageEmphasisTitle:i,indentFencedCode:a,indentedCode:o=!1,insertedElements:l,autolink:c,autoSpacing:u,astPlugins:d,sourcePlugins:p,fixEnding:m=!1,enabledHtmlTags:g=!1,looseTruncateDataSlot:h=!1,removeTruncatedImage:f=!1,katex:x})=>{const y=getAstPlugins({autolink:c,autoSpacing:u,imageEmphasisTitle:i,indentFencedCode:a,showEllipsis:r,showIndicator:s,astPlugins:d}),k=getSourcePlugins({sourcePlugins:p});return parseMarkdownAndProcessByPlugins({source:e,astPlugins:t?y:void 0,sourcePlugins:n?k:void 0,parseAst:t,indentedCode:o,insertedElements:l,fixEnding:m,enabledHtmlTags:g,looseTruncateDataSlot:h,removeTruncatedImage:f,katex:x})},useProcessMarkdown=e=>{const{insertedElements:t}=e,n=lodash_es_values(lodash_es_omit(e,["insertedElements","astPlugins","sourcePlugins"]));return (0,react.useMemo)((()=>parseMarkdownAndProcess(e)),[...n,null==t?void 0:t.length])},useEstablished=e=>{const t=(0,react.useRef)(e);return t.current=t.current||e,t.current},usePreviousRef=e=>{const t=(0,react.useRef)(),n=(0,react.useRef)(e);return n.current!==e&&(t.current=n.current,n.current=e),t},useForceUpdate=()=>{const[,e]=(0,react.useReducer)((e=>e+1),0);return e};function useLatestFunction(e){const t=useLatest(e),n=(0,react.useCallback)(((...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[]);return e&&n}const INITIAL_SPEED=.02,EXPECTED_BUFFER_SIZE=15,ELASTIC_COEFFICIENT=1/700/1e3,TICK_DURATION=1e3/60*2,findCommonPrefixLength=(e,t)=>{let n=0,r=Math.max(e.length,t.length);for(;n!==r&&n!==r-1;){const s=Math.floor((n+r)/2);e.slice(0,s)===t.slice(0,s)?n=s:r=s}return n},useSmoothText=(e,t={})=>{const{maxFirstTextSmoothSize:n,trailingSmooth:r,enable:s,pause:i,onSmoothFinished:a,onUpdate:o,onTextBreak:l,maxSpeed:c,expectedBufferSize:u,elasticCoefficient:d,tickDuration:p,initialSpeed:m,breakMode:g}=lodash_es_defaults(lodash_es_isBoolean(t)?{}:{...t},{maxFirstTextSmoothSize:1/0,trailingSmooth:!1,pause:!1,enable:Boolean(t),expectedBufferSize:15,elasticCoefficient:ELASTIC_COEFFICIENT,tickDuration:TICK_DURATION,initialSpeed:.02,breakMode:"prefix"}),h=lodash_es_isNumber(c)&&c>0?c:1/0,f=usePreviousRef(e),x=(0,react.useRef)(e.length<=n?1:e.length),y=(0,react.useRef)(x.current),k=useEstablished(s),T=s||k&&r&&x.current<e.length,[C,v]=(0,react.useState)(!1),E=(0,react.useRef)(m),P=()=>lodash_es_isString(f.current)&&!e.startsWith(f.current);if(P()){let t=0;"start"===g?t=0:"end"===g?t=Math.max(e.length-1,0):"prefix"===g&&(t=Math.max(1,findCommonPrefixLength(f.current??"",e))),x.current=t,y.current=Math.floor(x.current)}const S=y.current,w=T&&!C?e.slice(0,S):e,_=useForceUpdate(),b=e=>{e!==y.current&&(y.current=e,_())},A=useLatestFunction((()=>{v(!0)}));return (0,react.useEffect)((()=>{C&&(b(e.length),v(!1),x.current=e.length)}),[C]),(0,react.useEffect)((()=>{T||null==a||a()}),[T]),es_useInterval((()=>{if(P())null==l||l({prevText:f.current??"",currentText:e}),E.current=m,f.current=void 0;else{const t=Math.max(e.length+(!s&&r?2*u:0),2*u)-x.current,n=d*(t-u);E.current=Math.min(Math.max(0,E.current+p*n),h/1e3);const i=p*E.current;x.current=Math.min(e.length,x.current+i),b(Math.floor(x.current))}}),T&&!i?p:void 0),(0,react.useEffect)((()=>{null==o||o({text:w,speed:1e3*E.current})}),[S]),{text:w,flushCursor:A}},rtlLocaleList=["ae","aeb","ajt","apc","apd","ar","ara","arb","arc","arq","ars","ary","arz","ave","avl","bal","bcc","bej","bft","bgn","bqi","brh","cja","ckb","cld","dcc","dgl","div","drw","dv","fa","fas","fia","fub","gbz","gjk","gju","glk","grc","gwc","gwt","haz","he","heb","hnd","hno","iw","ji","kas","kby","khw","ks","kvx","kxp","kzh","lad","lah","lki","lrc","luz","mde","mfa","mki","mvy","myz","mzn","nqo","oru","ota","otk","oui","pal","pbu","per","pes","phl","phn","pnb","pra","prd","prs","ps","pus","rhg","rmt","scl","sd","sdh","shu","skr","smp","snd","sog","swb","syr","tnf","trw","ug","uig","ur","urd","wni","xco","xld","xmn","xmr","xna","xpr","xsa","ydd","yi","yid","zdj"],retryLoad=(e,t=3,n=1e3)=>new Promise(((r,s)=>{e().then(r).catch((i=>{setTimeout((()=>{1!==t?retryLoad(e,t-1,n).then(r,s):s(i)}),n)}))})),notStringifiedAstType=["code","inlineCode","math","inlineMath"],DETECT_MIN_LENGTH=20,isRTLChar=e=>new RegExp("^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]").test(e),isRTLOfAstLanguage=async e=>{try{const t=getTextOfAst(e,{filter:e=>!isLiteralOfContent(e)||!notStringifiedAstType.includes(e.type)}).trim(),n=elementAt(t.split("\n"),0);if(!n)return!1;const{franc:r}=await retryLoad((()=>__webpack_require__.e(/* import() */ "691").then(__webpack_require__.bind(__webpack_require__, 51854)))),s=r(n,{minLength:20});return"und"===s?isRTLChar(n.charAt(0)):rtlLocaleList.includes(s)}catch(e){return!1}},useIsRTL=e=>{const[t,n]=(0,react.useState)(!1);return (0,react.useEffect)((()=>{e?(async()=>{const t=await isRTLOfAstLanguage(e);n(t)})():n(!1)}),[e]),t},useHop=({onHop:e,ast:t,text:n,getRenderedText:r})=>{const s=(0,react.useRef)(""),i=es_usePrevious(n),a=es_usePrevious(t);(0,react.useEffect)((()=>{const o=s.current,l=r().trim();if(!lodash_es_isUndefined(o)&&!lodash_es_isUndefined(i)&&!lodash_es_isUndefined(a)&&!lodash_es_isUndefined(t)&&e&&n.length>i.length&&l.length<o.length){const n=getHopDiff(a,t);if(n){const{prevEndNode:r,endNode:s}=n;e({renderedText:l,prevRenderedText:o,ast:t,prevAst:a,prevEndNode:r,endNode:s,prevEndNodeType:convertToStanardNodeTypeEnum(null==r?void 0:r.type),endNodeType:convertToStanardNodeTypeEnum(null==s?void 0:s.type)})}}s.current=l}),[n])},isHTMLElementNode=e=>"undefined"==typeof HTMLElement?e.nodeType===Node.ELEMENT_NODE:e instanceof HTMLElement,replaceToText=e=>{for(const t of e.childNodes)replaceToText(t);if(!isHTMLElementNode(e))return;const{customCopyText:t}=e.dataset;if(!lodash_es_isUndefined(t))return void(e.textContent=t);if("br"===e.tagName.toLowerCase()){const t=document.createElement("span");return t.textContent="\n",void(e.parentElement&&e.parentElement.replaceChild(t,e))}},hasCustomCopyTextElement=e=>Boolean(e.querySelector("[data-custom-copy-text]")),supportClipboard=()=>"undefined"!=typeof navigator&&!lodash_es_isUndefined(navigator.clipboard)&&!lodash_es_isUndefined(navigator.clipboard.read)&&!lodash_es_isUndefined(navigator.clipboard.write)&&"undefined"!=typeof ClipboardItem,parseHtmlToDocumentFragment=e=>{const t=document.createDocumentFragment(),n=document.createElement("div");return n.innerHTML=e,t.append(...n.childNodes),t},useCopy=()=>async()=>{try{const e=window.getSelection();if(!(null==e?void 0:e.rangeCount))return;const t=e.getRangeAt(0).cloneContents();if(!hasCustomCopyTextElement(t)||!supportClipboard())return;const n=await navigator.clipboard.read(),r=lodash_es_head(n);if(assert(r),!r.types.includes("text/html"))return;const s=await r.getType("text/html"),i=await s.text(),a=parseHtmlToDocumentFragment(i);replaceToText(a);const o=a.textContent??"",l=(new XMLSerializer).serializeToString(a);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([l],{type:"text/html"}),"text/plain":new Blob([o],{type:"text/plain"})})])}catch(e){console.warn("[Calypso] Enhanced replication failed, possibly due to the user's refusal of replication permission. The default replication behavior takes effect, and the original error is:",e)}},isTextType=e=>"text"===e.type,isEndlineText=e=>isTextType(e)&&/^\n+$/.test(getInnerText(e)),isElementType=(e,...t)=>"attribs"in e&&"object"==typeof e.attribs&&("tag"===e.type&&(!(null==t?void 0:t.length)||t.some((t=>lodash_es_isRegExp(t)?t.test(e.name):t===e.name)))),getInnerText=e=>isTextType(e)?e.data:isElementType(e)?e.children.map(getInnerText).join(""):"",detectIsChinese=e=>/[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FD5\uF900-\uFA6D\uFA70-\uFAD9]/.test(e),renderDom=e=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact([e])}),renderReactElement=(e,t,n)=>"markdown-root"===t.className?(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:n}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:(0,react.createElement)(e,t,(null==n?void 0:n.length)?n:void 0)}),createShallowedProvider=e=>{const t=e.Provider;return({value:e,afterMemoedProcess:n,children:r})=>{const s=useCustomMemoValue(e,shallowEqual),i=(0,react.useMemo)((()=>n?n(s):s),[s]);return (0,jsx_runtime.jsx)(t,{value:i,children:r})}},CalypsoConfigContext=(0,react.createContext)({theme:"default",mode:"light"}),CalypsoConfigProvider=createShallowedProvider(CalypsoConfigContext),useCalypsoConfig=()=>(0,react.useContext)(CalypsoConfigContext),CalypsoSlotsInnerContext=(0,react.createContext)(null),CalypsoSlotsInnerProvider=createShallowedProvider$1(CalypsoSlotsInnerContext),useCalypsoSlots=()=>{const e=(0,react.useContext)(CalypsoSlotsInnerContext);if(!e)throw Error("[Calypso Internal Bugs] CalypsoSlotsInnerContext Required");return e},createSlotConsumer=(e,t)=>{const n=n=>{const r=useCalypsoSlots()[e]??t;return r?(0,jsx_runtime.jsx)(r,{...n}):null};return n.displayName=e,n},CalypsoI18nContext=(0,react.createContext)(null),CalypsoI18nProvider=createShallowedProvider(CalypsoI18nContext),AUTO_HIDE_LAST_SIBLING_BR_CLASS="auto-hide-last-sibling-br",BlockElement=({node:e,renderRest:t,style:n,className:r,children:s})=>{const{BreakLine:i}=useCalypsoSlots(),{style:a,className:o,...l}=attributesToProps((null==e?void 0:e.attribs)??{});return (0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[e&&(0,react.createElement)(e.name,{...l,style:{...a,...n},className:classnames(o,r,"auto-hide-last-sibling-br")},...e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:null==t?void 0:t(e)},n)))),lodash_es_isFunction(s)?s({className:classnames("auto-hide-last-sibling-br")}):s,i&&(0,jsx_runtime.jsx)(i,{})]})},ComposedTable=createSlotConsumer("Table"),renderTable=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"table"))return;const{className:r,...s}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:i})=>(0,jsx_runtime.jsx)(ComposedTable,{...s,raw:e,parents:n,className:classnames(r,i),children:domToReact(e.children,{replace:t})})})},ComposedStrong=createSlotConsumer("Strong"),renderStrong=(e,{renderRest:t,parents:n})=>{if(isElementType(e,"strong"))return (0,jsx_runtime.jsx)(ComposedStrong,{node:e,raw:e,parents:n,children:domToReact(e.children,{replace:t})})},ComposedBreakLine=createSlotConsumer("BreakLine"),ComposedBlockquote=createSlotConsumer("Blockquote"),renderSimpleHtml=(e,{renderRest:t,renderHtml:n,renderDataSlot:r,parents:s})=>{if(!isElementType(e))return;const i=e.name.toLowerCase(),a=attributesToProps(e.attribs),o=e.children.length?e.children.map(((e,n)=>(0,jsx_runtime.jsx)(react.Fragment,{children:t(e)},n))):void 0;if(r&&["data-inline","data-block"].includes(i)){const{type:e,value:t,alt:n}=a;return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r({display:"data-inline"===i?"inline":"block",type:e,value:parseJSONWithNull(he.decode(t,{strict:!1})),alt:n,children:o})??n})}let l;if(n&&(l=null==n?void 0:n({tagName:i,props:a,children:o,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.childNodes)})),!lodash_es_isUndefined(l))return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:l});if("br"===i)return (0,jsx_runtime.jsx)(ComposedBreakLine,{raw:e,parents:s});if("blockquote"===i)return (0,jsx_runtime.jsx)(ComposedBlockquote,{raw:e,node:e,parents:s,renderRest:t});if("hr"===i)return (0,jsx_runtime.jsx)(BlockElement,{node:e,renderRest:t});if(1===e.children.length){const t=e.children[0];if(isTextType(t)&&!t.data.trim())return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})}return renderReactElement(i,a,o)},ComposedParagraph=createSlotConsumer("Paragraph"),renderParagraph=(e,{renderRest:t,forceBrInterSpacing:n,parents:r})=>{if(!isElementType(e,"p"))return;const{className:s,...i}=attributesToProps(e.attribs);return (0,jsx_runtime.jsx)(BlockElement,{children:({className:a})=>(0,jsx_runtime.jsx)(ComposedParagraph,{...i,raw:e,parents:r,className:classnames(s,a),forceBrInterSpacing:n,children:domToReact(e.children,{replace:t})})})},ComposedTex=createSlotConsumer("Tex"),renderMath=(e,t={})=>{const{parents:n}=t;if(!isElementType(e,"span"))return;const r=e.attribs["data-type"],s=e.attribs["data-value"];if(s)try{const t=node_modules_buffer.Buffer.from(s,"base64").toString("utf8").trim();if("block-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"display"});if("inline-math"===r)return (0,jsx_runtime.jsx)(ComposedTex,{raw:e,parents:n,tex:t,mode:"inline"})}catch(e){return void console.error("[Math Render Error]",e)}},ComposedList=createSlotConsumer("List"),all_in_one_index_renderList=(e,{renderRest:t,parents:n})=>{if(!isElementType(e,"ol","ul"))return;const r=e.children.every((e=>isTextType(e)||isElementType(e,"li")&&!lodash_es_isUndefined(e.children[0])&&isElementType(e.children[0],"input")&&"checkbox"===e.children[0].attribs.type))?"tasklist":void 0;return (0,jsx_runtime.jsx)(ComposedList,{className:r,node:e,raw:e,parents:n,renderRest:t})},ComposedLink=createSlotConsumer("Link"),renderLink=(e,{renderRest:t,customLink:n,callbacks:r={},parents:s})=>{if(!isElementType(e,"a"))return;const{href:i,title:a,...o}=e.attribs,l="autolink"===a;return (0,jsx_runtime.jsx)(ComposedLink,{...attributesToProps(o),raw:e,parents:s,href:i,customLink:n,type:l?"autolink":"markdown",title:l?void 0:a,...lodash_es_pick(r,"onLinkRender","onLinkClick","onSendMessage"),children:domToReact(e.children,{replace:t})})},renderInsertElement=(e,t)=>{var n;const{insertedElements:r=[]}=t;if(!isElementType(e,"span"))return;if("insert_element_extension"!==e.attribs["data-type"])return;const s=e.attribs["data-index"],i=e.attribs["data-raw"];if(lodash_es_isUndefined(s))return;const a=parseInt(s);return a>r.length||null==(n=r[a])?void 0:n.render(i&&node_modules_buffer.Buffer.from(i,"base64").toString("utf-8"))},ComposedIndicator=createSlotConsumer("Indicator"),renderIndicator=(e,t={})=>{var n;const{parents:r}=t;if(isElementType(e,"span")&&"indicator"===(null==(n=e.attribs)?void 0:n.class))return (0,jsx_runtime.jsx)(ComposedIndicator,{raw:e,parents:r})},ComposedImage=createSlotConsumer("Image"),hasSiblingText=(e,t={})=>{const{regardSiblingBrAsText:n=!0}=t,r={hasLeftText:!1,hasRightText:!1};if(!e.parent)return r;const{children:s}=e.parent,i=s.indexOf(e);if(i<0)return r;const a=e=>e<s.length&&e>=0&&(isTextType(s[e])||!!n&&isElementType(s[e],"br"));return{hasLeftText:a(i-1),hasRightText:a(i+1)}},renderImage=(e,t={})=>{const{callbacks:n={},imageOptions:r,marginWithSiblingBr:s=!0,parents:i}=t,{onImageRender:a,onImageClick:o}=n;if(!isElementType(e,"img"))return;const{src:l,alt:c,width:u,height:d}=e.attribs,p=Number(u),m=Number(d),{hasLeftText:g,hasRightText:h}=hasSiblingText(e,{regardSiblingBrAsText:s});return (0,jsx_runtime.jsx)(ComposedImage,{...attributesToProps(e.attribs),raw:e,parents:i,src:safeParseUrl(l)&&l,onImageClick:o,onImageRender:a,imageOptions:{alt:c,objectFit:"cover",objectPosition:"center",height:isNaN(m)?256:m,width:isNaN(p)?400:p,...r},style:{borderRadius:12,overflow:"hidden"},wrapperStyle:{marginTop:g?12:void 0,marginBottom:h?12:void 0},...n})},header$1="_header_1rhdj_1",styles$d={header:header$1},ComposedHeader=createSlotConsumer("Header"),all_in_one_index_renderHeader=(e,{renderRest:t,parents:n})=>{if(isElementType(e,/^h[0-9]+$/))return (0,jsx_runtime.jsx)(ComposedHeader,{className:styles$d.header,node:e,raw:e,parents:n,renderRest:t})},ComposedEmphasis=createSlotConsumer("Emphasis"),renderEm=(e,{renderRest:t,spacingAfterChineseEm:n,parents:r})=>{if(!isElementType(e,"em"))return;const s=void 0!==n&&!1!==n&&detectIsChinese(getInnerText(e).slice(-1)??"")&&!lodash_es_isNull(e.nextSibling)&&(isElementType(e.nextSibling)||isTextType(e.nextSibling))&&detectIsChinese(getInnerText(e.nextSibling).slice(0,1)??"");return (0,jsx_runtime.jsx)(ComposedEmphasis,{style:{marginRight:s?"boolean"==typeof n?2:n:void 0},node:e,raw:e,parents:r,children:domToReact(e.children,{replace:t})})},renderDanger=e=>{if("tag"!==e.type&&"text"!==e.type&&"root"!==e.type)return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{})},DEFAULT_LANGUAGE="plaintext",getCodeElement=e=>isElementType(e,"code")?e:isElementType(e,"pre")?e.childNodes.find((e=>isElementType(e,"code"))):void 0,getLanguageFromElement=(e,t="plaintext")=>{var n,r,s;const i=getCodeElement(e);return i&&(null==(s=null==(r=null==(n=i.attribs)?void 0:n.class)?void 0:r.match(/language-(.*)/))?void 0:s[1])||t},getMetaFromElement=(e,t=!0)=>{const n=getCodeElement(e),r=null==n?void 0:n.attribs["data-meta"];if(r)return t?r.split(/\s+/).filter((e=>!e.match(/^__[^_].*/))).join(" ")||void 0:r},getIndentFromCodeElememt=e=>{var t;const n=getMetaFromElement(e,!1);if(!n)return 0;const r=n.match(/(\s|^)__indent=(?<indent>[0-9]+)(\s|$)/);if(!r)return 0;const s=Number(null==(t=r.groups)?void 0:t.indent);return isNaN(s)?0:s},HIDE_HEADER_LANGUAGES=["result","stderr","stdout"],styles$c={"code-group-item--begin":"_code-group-item--begin_1wdrc_1","code-group-item--center":"_code-group-item--center_1wdrc_5","code-group-item--end":"_code-group-item--end_1wdrc_8"},INDENT_WIDTH=18,ComposedCodeBlock=createSlotConsumer("CodeBlock"),isCodeBlockElement=e=>{if(!isElementType(e,"pre"))return!1;const{childNodes:t}=e;return!!t.find((e=>isElementType(e,"code")))},EmptyWrapperElement=({children:e})=>(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e()}),renderCodeBlocks=(e,t)=>{const{autoHideCodeHeaderLanguage:n=HIDE_HEADER_LANGUAGES,renderRest:r,parents:s,callbacks:i={},indentTabs:a=0,loading:o}=t,{onCopyCodeBlock:l}=i,c=Array.isArray(n)?n:[n],u=BlockElement;return (0,jsx_runtime.jsx)(EmptyWrapperElement,{children:({className:t}={className:""})=>e.map((({target:n},i)=>{if(!isCodeBlockElement(n))return null;const d=styles$c["code-group-item--"+(e.length,"normal")],{childNodes:p=[]}=n;return p.map(((e,n)=>(0,jsx_runtime.jsx)(u,{children:()=>{if(isElementType(e,"code")){const t=getLanguageFromElement(e),r=getMetaFromElement(e);return (0,jsx_runtime.jsx)(ComposedCodeBlock,{parents:s,code:getInnerText(e),language:t,meta:r,showHeader:!c.includes(t.toLowerCase()),className:d,onCopyCode:l,style:{marginLeft:a?18*a+"px":void 0},loading:o},n)}return isElementType(e)?(0,jsx_runtime.jsx)("pre",{className:t,children:r(e)},n):(0,jsx_runtime.jsx)("pre",{className:t,children:domToReact([e])},n)}})))}))})},splitToCodeBlockGroup=({children:e,adjacentCodeAsGroup:t=!0})=>{const n=[];let r=null;for(const s of e)if(isCodeBlockElement(s)){const e=elementAt(n,n.length-1),r={target:s,language:getLanguageFromElement(s,""),code:innerText(s)};(null==e?void 0:e.isCodeBlockGroup)&&t?e.codeBlocks.push(r):n.push({isCodeBlockGroup:!0,codeBlocks:[r]})}else isEndlineText(s)?r=s:(r&&(n.push({isCodeBlockGroup:!1,target:r,code:innerText(r)}),r=null),n.push({isCodeBlockGroup:!1,target:s,code:isElementType(s)||isTextType(s)?innerText(s):""}));return n},renderCodeBlock=(e,{renderRest:t,adjacentCodeAsGroup:n,callbacks:r={}})=>{if(!isElementType(e))return;const{childNodes:s}=e;if(s.every((e=>!isCodeBlockElement(e))))return;const i=splitToCodeBlockGroup({children:s,adjacentCodeAsGroup:n});return renderReactElement(e.name,attributesToProps(e.attribs),i.map(((e,n)=>{if(e.isCodeBlockGroup){const{codeBlocks:s}=e,a=n===i.length-1,o=Math.min(8,...s.map((e=>Math.floor(getIndentFromCodeElememt(e.target)/2))));return renderCodeBlocks(s,{renderRest:t,callbacks:r,indentTabs:o,loading:a,autoHideCodeHeaderLanguage:[]})}return (0,jsx_runtime.jsx)(react.Fragment,{children:t(e.target)},n)})))},renderCustomNode=(e,t={})=>{const{parents:n=[],callbacks:r={},insertedElements:s,imageOptions:i,adjacentCodeAsGroup:a,forceBrInterSpacing:o,spacingAfterChineseEm:l,customLink:c,renderHtml:u,renderRawHtml:d,renderDataSlot:p}=t,m=r=>renderCustomNode(r,{...t,parents:[e,...n]}),g=isElementType(e)?e.name.toLowerCase():"",h=isElementType(e)?attributesToProps(e.attribs):{};return(()=>{if(d&&isElementType(e))return d({tagName:g,props:h,parents:n,renderRest:m,node:e,currentHTML:stringifyDomNode(e),childrenHTML:stringifyDomNode(e.children)})})()??renderMath(e,{parents:n})??(s&&renderInsertElement(e,{insertedElements:s}))??renderDanger(e)??renderLink(e,{callbacks:r,customLink:c,parents:n,renderRest:m})??renderImage(e,{callbacks:r,imageOptions:i,marginWithSiblingBr:!o,parents:n})??renderCodeBlock(e,{adjacentCodeAsGroup:a,callbacks:r,renderRest:m})??renderIndicator(e,{parents:n})??renderParagraph(e,{forceBrInterSpacing:o,parents:n,renderRest:m})??renderTable(e,{parents:n,renderRest:m})??all_in_one_index_renderList(e,{parents:n,renderRest:m})??all_in_one_index_renderHeader(e,{parents:n,renderRest:m})??renderEm(e,{parents:n,renderRest:m,spacingAfterChineseEm:l})??renderStrong(e,{parents:n,renderRest:m})??renderSimpleHtml(e,{parents:n,renderRest:m,renderDataSlot:p,renderHtml:u})??renderDom(e)},wrapHtmlByMarkdownRoot=e=>`<div class="markdown-root">${e}</div>`,Markdown=({markDown:e,smartypants:t=!1,enabledHtmlTags:n,purifyHtml:r=!0,purifyHtmlConfig:s,modifyHtmlNode:i,...a})=>{const o=(0,react.useMemo)((()=>new CalypsoTokenizer),[]),l=useDeepCompareMemo((()=>getCalypsoRenderer({enabledHtmlTags:n})),[n]),c=useDeepCompareMemo((()=>{const e=new Marked({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]});return e.setOptions({gfm:!0,silent:!0,breaks:!0}),e.use({extensions:[insertElementSlotExtension(),inlineTex(),displayTex()]}),e.use(mangle()),t&&e.use(markedSmartypants()),e}),[t,n]),u=pipe((e=>c.parse(e,{tokenizer:o,renderer:l})),transformSelfClosing,(e=>{const t=(()=>{const e=lodash_es_isArray(n)?n:void 0,t={ALLOW_UNKNOWN_PROTOCOLS:!0,RETURN_DOM:!1};e&&(t.ADD_TAGS=e);const r=lodash_es_isFunction(s)?s(t):s;if(r){const{ALLOW_UNKNOWN_PROTOCOLS:e,RETURN_DOM:n,...s}=r;lodash_es_isUndefined(e)||(t.ALLOW_UNKNOWN_PROTOCOLS=e),lodash_es_isUndefined(n)||(t.RETURN_DOM=n),lodash_es_assign(t,s)}return t})();return lodash_es_isFunction(r)?r(e,t):r?purifyHtml(e,t):e}),wrapHtmlByMarkdownRoot),d=(0,react.useMemo)((()=>u(e)),[e,c]),p=(0,react.useMemo)((()=>{const e=htmlToDOM(d);return(null==i?void 0:i(e))??e}),[d]);return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:domToReact(p,{replace:e=>renderCustomNode(e,a)})})},container$6="_container_7mgzw_1",all_in_one_index_active="_active_7mgzw_7",blink="_blink_7mgzw_35",all_in_one_index_frame="_frame_7mgzw_631",all_in_one_index_enabled="_enabled_7mgzw_792",cursorAnimation="_cursorAnimation_7mgzw_1",styles$b={container:container$6,active:all_in_one_index_active,blink:blink,"no-list":"_no-list_7mgzw_553",frame:all_in_one_index_frame,"align-center":"_align-center_7mgzw_654","align-right":"_align-right_7mgzw_669","float-left":"_float-left_7mgzw_684","float-right":"_float-right_7mgzw_693",enabled:all_in_one_index_enabled,cursorAnimation:cursorAnimation},CalypsoSlotsContext=(0,react.createContext)(null);createShallowedProvider$1(CalypsoSlotsContext);const emptySlots={BreakLine:null,Tex:null,CodeBlockHighlighter:null,CodeBlock:null,Table:null,Image:null,Indicator:null,Paragraph:null,Link:null,Emphasis:null,Strong:null,Header:null,List:null,Blockquote:null},MarkdownEngine=(0,react.forwardRef)((function({className:e,style:t,mode:n="light",markDown:r,eventCallbacks:s,showIndicator:i=!1,autoFixSyntax:a=!0,smooth:o=!1,insertedElements:l=[],showEllipsis:c=!1,imageOptions:u,autoFitRTL:d=!1,forceBrInterSpacing:p,spacingAfterChineseEm:m=2,indentFencedCode:g,indentedCode:h,smartypants:f,enhancedCopy:x=!1,autolink:y,customLink:k,autoSpacing:T,slots:C={},translate:v={},enabledHtmlTags:E,purifyHtml:P,purifyHtmlConfig:S,astPlugins:w,sourcePlugins:_,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R,onAstChange:N,onHop:I,...M},$){const H=(0,react.useContext)(CalypsoSlotsContext),B={...emptySlots,...H,...C},j={theme:"default",mode:n},{Indicator:O}=B,{text:F,flushCursor:D}=useSmoothText(r,o),{katex:z,autoFixEnding:U,imageEmphasisTitle:q}=lodash_es_defaults(lodash_es_isBoolean(a)?{}:a,{autoFixEnding:!1}),Z=(0,react.useMemo)((()=>R&&!0!==E?[...E||[],"data-block","data-inline"]:E),[E,Boolean(R)]),{source:W,ast:V}=useProcessMarkdown({source:F,processAst:Boolean(a),showEllipsis:c,showIndicator:i,imageEmphasisTitle:q,indentFencedCode:g,indentedCode:h,insertedElements:l,autolink:y,autoSpacing:T,astPlugins:w,sourcePlugins:_,fixEnding:U,enabledHtmlTags:Z,looseTruncateDataSlot:Boolean(R),katex:z}),G=useIsRTL(d?V:void 0),K=useCopy(),X=(0,react.useRef)(null);useHop({onHop:I,ast:V,text:F,getRenderedText:()=>{var e;return(null==(e=X.current)?void 0:e.textContent)??""}}),(0,react.useEffect)((()=>{null==N||N(V)}),[V]),(0,react.useImperativeHandle)($,(()=>({getRootElement:()=>X.current,flushSmoothCursor:D})),[]);return W.trim()?(0,jsx_runtime.jsx)(CalypsoConfigProvider,{value:j,children:(0,jsx_runtime.jsx)(CalypsoSlotsInnerProvider,{value:B,afterMemoedProcess:e=>e?{...e}:e,children:(0,jsx_runtime.jsx)(CalypsoI18nProvider,{value:v,children:(0,jsx_runtime.jsx)("div",{...M,ref:X,"theme-mode":n,className:classnames(styles$b.container,"flow-markdown-body",styles$b[`theme-${j.theme}`],e),style:t,dir:G?"rtl":"ltr","data-show-indicator":i,onCopy:x?K:void 0,children:(0,jsx_runtime.jsx)(Markdown,{markDown:W,callbacks:s,insertedElements:l,imageOptions:u,forceBrInterSpacing:p,spacingAfterChineseEm:m,smartypants:f,customLink:k,enabledHtmlTags:Z,purifyHtml:P,purifyHtmlConfig:S,modifyHtmlNode:b,renderHtml:A,renderRawHtml:L,renderDataSlot:R})})})})}):(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[c&&"...",i&&O&&(0,jsx_runtime.jsx)(O,{})]})})),CalypsoCore=(0,react.forwardRef)((function({plugins:e=[],slots:t={},astPlugins:n=[],sourcePlugins:r=[],modifyHtmlNode:s,renderHtml:i,renderRawHtml:a,...o},l){const c=(0,react.useMemo)((()=>aggregatePlugins(e)),[e]),u=(0,react.useMemo)((()=>({...c.slots,...t})),[t,c.slots]);function d(e){return e?"function"==typeof e?e([]):e:[]}const p=[...d(n),...c.astPlugins],m=[...d(r),...c.sourcePlugins],g=c.modifyHtmlNode||s,h=c.renderHtml||i,f=c.renderRawHtml||a;return (0,jsx_runtime.jsx)(MarkdownEngine,{ref:l,slots:u,astPlugins:p,sourcePlugins:m,modifyHtmlNode:g,renderHtml:h,renderRawHtml:f,...o})}));function composeModifyHtmlNode(e){if(e.length)return t=>{let n=t;return e.forEach((e=>{const t=e(n);t&&(n=t)})),n}}function composeRenderer(e){if(e.length)return t=>{for(const n of e){const e=n(t);if(null!=e)return e}}}function aggregatePlugins(e){let t={};const n=[],r=[],s=[],i=[],a=[];return e.forEach((e=>{var o,l;e.slots&&(t={...t,...e.slots}),(null==(o=e.astPlugins)?void 0:o.length)&&n.push(...e.astPlugins),(null==(l=e.sourcePlugins)?void 0:l.length)&&r.push(...e.sourcePlugins),e.modifyHtmlNode&&s.push(e.modifyHtmlNode),e.renderHtml&&i.push(e.renderHtml),e.renderRawHtml&&a.push(e.renderRawHtml)})),{slots:t,astPlugins:n,sourcePlugins:r,modifyHtmlNode:composeModifyHtmlNode(s),renderHtml:composeRenderer(i),renderRawHtml:composeRenderer(a)}}const LightTex=({tex:e,mode:t,className:n,style:r})=>(0,jsx_runtime.jsx)("span",{className:classnames("math-inline",n),style:r,children:e}),texLightPlugin={name:"tex-light",slots:{Tex:LightTex}},styles$a={"table-container":"_table-container_18bux_1"},all_in_one_index_Table=({children:e,className:t,raw:n,parents:r,...s})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$a["table-container"]),...s,children:(0,jsx_runtime.jsx)("table",{children:e})}),tablePlugin={name:"table",slots:{Table:all_in_one_index_Table}},Strong=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("strong",{className:e,style:t,children:n}),strongPlugin={name:"strong",slots:{Strong:Strong}},all_in_one_index_paragraph="_paragraph_1b2re_1",styles$9={paragraph:all_in_one_index_paragraph},all_in_one_index_Paragraph=({children:e,className:t,forceBrInterSpacing:n=!1,raw:r,parents:s,...i})=>(0,jsx_runtime.jsx)("div",{className:classnames(t,styles$9.paragraph,"paragraph-element",{"br-paragraph-space":n}),...i,children:(0,react.isValidElement)(e)?(0,react.cloneElement)(e,{key:"0"}):e}),paragraphPlugin={name:"paragraph",slots:{Paragraph:all_in_one_index_Paragraph}},all_in_one_index_List=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),listPlugin={name:"list",slots:{List:all_in_one_index_List}},all_in_one_index_link="_link_eyymc_1",styles$8={link:all_in_one_index_link},isHttpLink=e=>{const t=safeParseUrl(e);return!!t&&("http:"===t.protocol||"https:"===t.protocol)},all_in_one_index_Link=({className:e,style:t,href:n,children:r,customLink:s=!0,onLinkClick:i,onLinkRender:a,onOpenLink:o,type:l,raw:c,parents:u,...d})=>{const p=n?safeParseUrl(n):null,m=useComputeValue((()=>!!n&&(!!isHttpLink(n)||(lodash_es_isFunction(s)?s(n):s)))),g=e=>{o?null==o||o(e):window.open(e)};return (0,react.useEffect)((()=>{n&&p&&(null==a||a({url:n,parsedUrl:p}))}),[n]),m?(0,jsx_runtime.jsx)("a",{...lodash_es_omit(d,"href"),className:classnames(styles$8.link,e),style:t,onClick:e=>{n&&p?isHttpLink(n)&&(i?i(e,{url:n,parsedUrl:p,exts:{type:LinkType.normal},openLink:g}):(e.preventDefault(),e.stopPropagation(),g(n))):e.preventDefault()},href:p?n:void 0,target:"_blank",children:r}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:r})},linkPlugin={name:"link",slots:{Link:all_in_one_index_Link}},styles$7={},all_in_one_index_Indicator=({className:e,style:t})=>(0,jsx_runtime.jsx)("span",{className:styles$7.container,children:(0,jsx_runtime.jsx)("span",{className:classnames(styles$7.indicator,styles$7.flashing,e),style:t,"data-testid":"indicator"})}),indicatorPlugin={name:"indicator",slots:{Indicator:all_in_one_index_Indicator}},all_in_one_index_SvgIconError=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 21.375C6.82233 21.375 2.625 17.1777 2.625 12C2.625 6.82233 6.82233 2.625 12 2.625C17.1777 2.625 21.375 6.82233 21.375 12C21.375 17.1777 17.1777 21.375 12 21.375ZM0.75 12C0.75 5.7868 5.7868 0.75 12 0.75C18.2132 0.75 23.25 5.7868 23.25 12C23.25 18.2132 18.2132 23.25 12 23.25C5.7868 23.25 0.75 18.2132 0.75 12ZM11.9911 13.6761C11.3638 13.6761 11.0393 13.3623 11.0174 12.7348L10.8752 7.87488C10.8606 7.55381 10.9591 7.29476 11.1706 7.09774C11.3821 6.89342 11.6519 6.79126 11.9801 6.79126C12.3083 6.79126 12.5818 6.89342 12.8006 7.09774C13.0194 7.30206 13.1215 7.56475 13.107 7.88583L12.9429 12.7238C12.921 13.3587 12.6037 13.6761 11.9911 13.6761ZM11.9911 17.1349C11.6483 17.1349 11.3529 17.0255 11.1049 16.8066C10.8642 16.5877 10.7439 16.3104 10.7439 15.9747C10.7439 15.639 10.8642 15.3617 11.1049 15.1428C11.3456 14.9239 11.641 14.8144 11.9911 14.8144C12.3412 14.8144 12.6365 14.9239 12.8772 15.1428C13.1252 15.3617 13.2492 15.639 13.2492 15.9747C13.2492 16.3177 13.1252 16.5986 12.8772 16.8175C12.6365 17.0291 12.3412 17.1349 11.9911 17.1349Z",fill:"#999999"})),container$5="_container_hux85_1",centered="_centered_hux85_8",all_in_one_index_image="_image_hux85_11",fallbackIcon="_fallbackIcon_hux85_30",square="_square_hux85_40",all_in_one_index_clickable="_clickable_hux85_45",all_in_one_index_title="_title_hux85_48",styles$6={container:container$5,centered:centered,image:all_in_one_index_image,"loading-image":"_loading-image_hux85_16","error-wrapper":"_error-wrapper_hux85_21",fallbackIcon:fallbackIcon,"image-wrapper":"_image-wrapper_hux85_35",square:square,clickable:all_in_one_index_clickable,title:all_in_one_index_title},convertHttpToHttps=e=>{const t=new URL(e);return"http:"===t.protocol&&(t.protocol="https:"),t.toString()},all_in_one_index_Image=({className:e,style:t,raw:n,parents:r,wrapperClassName:s,wrapperStyle:i,src:a=null,otherFormatSrc:o,onImageClick:l,onImageRender:c,imageOptions:u={layout:"intrinsic",objectFit:"contain"},errorClassName:d,children:p,onImageLoadComplete:m,useCustomPlaceHolder:g=!1,customPlaceHolder:h,onImageContextMenu:f,onImageMouseEnter:x,...y})=>{const{squareContainer:k=!1,forceHttps:T=!1,responsiveNaturalSize:C=!1,width:v=400,height:E=256,showTitle:P=!1,centered:S=!1,...w}=u,{alt:_}=u,[b,A]=(0,react.useState)(v),[L,R]=(0,react.useState)(E);(0,react.useEffect)((()=>{(v||E)&&(A(v),R(E))}),[v,E]);const{minHeight:N,minWidth:I,maxHeight:M,maxWidth:$}=lodash_es_defaults(lodash_es_isBoolean(C)?{}:{...C},{minHeight:0,minWidth:0,maxWidth:v??400,maxHeight:E??256}),H=a&&(T?convertHttpToHttps(a):a),[B,j]=(0,react.useState)(ImageStatus.Loading),O=B!==ImageStatus.Loading,F={src:H,status:B},D=(C||g)&&!O;(0,react.useEffect)((()=>{H&&(null==c||c(F))}),[H]);const z=lodash_es_isNumber(b)&&lodash_es_isNumber(L)&&{width:"100%",height:0,paddingBottom:`min(${L/b*100}%, ${L}px)`,maxWidth:b};return (0,jsx_runtime.jsxs)("div",{className:classnames(styles$6.container,{[styles$6.centered]:S}),style:i,children:[(0,jsx_runtime.jsx)("div",{onClick:e=>{l&&F&&(l(e,F),e.stopPropagation())},className:classnames(styles$6["image-wrapper"],{[styles$6.clickable]:Boolean(l),[styles$6.square]:k},s),style:{...z},"data-testid":"calypso_image",children:p||(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[C&&!O&&!g&&(0,jsx_runtime.jsx)("span",{className:styles$6["loading-image"],children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,height:L,width:b,placeholder:"skeleton",src:""})}),(0,jsx_runtime.jsx)("span",{style:{display:"inline-block",...D?{width:0,height:0}:{}},children:(0,jsx_runtime.jsx)(Viewer,{...y,...w,onContextMenu:f,onMouseEnter:x,height:L,width:b,alt:"image",src:H??"",formats:["avif","webp"],placeholder:"skeleton",loader:({extra:{origin:e},format:t})=>(null==o?void 0:o.avifSrc)&&"avis"===t?null==o?void 0:o.avifSrc:(null==o?void 0:o.webpSrc)&&"awebp"===t?null==o?void 0:o.webpSrc:H??e,error:(0,jsx_runtime.jsx)("div",{className:classnames(styles$6["error-wrapper"],d,"error-wrapper"),ref:()=>{j(ImageStatus.Failed),null==m||m()},children:(0,jsx_runtime.jsx)(all_in_one_index_SvgIconError,{className:styles$6.fallbackIcon})}),onLoadingComplete:e=>{var t;j(ImageStatus.Success),null==m||m();const{naturalWidth:n,naturalHeight:r}=e;if(C&&n&&r){const e=resizeImage({width:n,height:r,minHeight:N,minWidth:I,maxHeight:M,maxWidth:$});A(e.width),R(e.height)}null==(t=w.onLoadingComplete)||t.call(w,e)},className:classnames(e,styles$6.image),style:t})}),g&&!O&&h]})}),P&&_&&(0,jsx_runtime.jsx)("div",{className:styles$6.title,children:_})]})},imagePlugin={name:"samantha-image",slots:{Image:all_in_one_index_Image}},all_in_one_index_Header=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),headerPlugin={name:"header",slots:{Header:all_in_one_index_Header}},Emphasis=({className:e,style:t,children:n})=>(0,jsx_runtime.jsx)("em",{className:e,style:t,children:n}),emphasisPlugin={name:"emphasis",slots:{Emphasis:Emphasis}};let fullLanguages=null;const fetchFullLanguagePacks=async()=>{if(!fullLanguages){const{languages:e=null}=await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 847, 19));fullLanguages=e}return fullLanguages},useLanguagePack=e=>{const[t,n]=(0,react.useState)(fullLanguages||prism.languages);return (0,react.useEffect)((()=>{t[e]||(async()=>{const e=await fetchFullLanguagePacks();e&&e!==t&&n(e)})()}),[t,e]),t[e]||t.plaintext},useHighLight=(e,t)=>{const n=t.toLowerCase(),r=useLanguagePack(n);return (0,react.useMemo)((()=>{try{return (0,prism.highlight)(e,r,n)}catch(t){return console.error("Fail to highlight code by prism",t),e}}),[n,e,r])},container$4="_container_g7n3b_57",dark$1="_dark_g7n3b_176",styles$5={container:container$4,dark:dark$1},PrismCodeBlockHighlighter=({code:e,language:t="",className:n,style:r,dark:s=!1})=>{const i=useHighLight(e,t);return (0,jsx_runtime.jsx)("pre",{className:classnames(styles$5.container,n,t&&`language-${t}`,{[styles$5.dark]:s}),style:r,children:(0,jsx_runtime.jsx)("code",{className:t&&`language-${t}`,dangerouslySetInnerHTML:{__html:purifyHtml(i)}})})},index$2=Object.freeze(Object.defineProperty({__proto__:null,PrismCodeBlockHighlighter:PrismCodeBlockHighlighter,default:PrismCodeBlockHighlighter},Symbol.toStringTag,{value:"Module"})),codeHighlighterPrismPlugin={name:"code-highlighter-prism",slots:{CodeBlockHighlighter:PrismCodeBlockHighlighter}},detectLanguage=e=>{},PLAIN_TEXT="plaintext",useAutoDetectLanguage=(e,t=PLAIN_TEXT)=>{const[n,r]=(0,react.useState)(t);return (0,react.useEffect)((()=>{r(t)}),[t]),(0,react.useEffect)((()=>{(async()=>{if(n===PLAIN_TEXT){const e=await detectLanguage();e&&r(e)}})()}),[e,n]),n},SvgDoneIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{d:"M9.2267 16.1272L19.9535 5.40038C20.4274 4.92644 21.1958 4.92644 21.6698 5.40038C22.1437 5.87432 22.1437 6.64272 21.6698 7.11666L10.0848 18.7016C9.61091 19.1755 8.8425 19.1755 8.36856 18.7016L2.36156 12.6946C1.88762 12.2207 1.88762 11.4522 2.36156 10.9783C2.8355 10.5044 3.6039 10.5044 4.07784 10.9783L9.2267 16.1272Z",fill:"currentColor"})),SvgCopyIcon=e=>react.createElement("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.5 3.5V17C21.5 18.1046 20.6046 19 19.5 19H17.5V21C17.5 22.1046 16.5406 23 15.3571 23H4.64286C3.45939 23 2.5 22.1046 2.5 21V7.5C2.5 6.39543 3.45939 5.5 4.64286 5.5H6.5V3.5C6.5 2.39543 7.39543 1.5 8.5 1.5H19.5C20.6046 1.5 21.5 2.39543 21.5 3.5ZM8.5 5.5H15.3571C16.5406 5.5 17.5 6.39543 17.5 7.5V17H19.5V3.5H8.5V5.5ZM15.3571 7.5H4.64286L4.64286 21H15.3571V7.5Z",fill:"currentColor"})),SvgCodeIcon=e=>react.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7 9V15H5.2V9H7ZM7 8V16H5C4.44771 16 4 15.7015 4 15.3333V8.66667C4 8.29848 4.44771 8 5 8H7Z",fill:"currentColor"}),react.createElement("path",{d:"M8.5 10L11.5 12L8.5 14",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{d:"M15.5 15H11.5",stroke:"currentColor",strokeLinejoin:"bevel"}),react.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17 9V15H18.8V9H17ZM17 8V16H19C19.5523 16 20 15.7015 20 15.3333V8.66667C20 8.29848 19.5523 8 19 8H17Z",fill:"currentColor"})),container$3="_container_vmcsy_1",dark="_dark_vmcsy_13",all_in_one_index_header="_header_vmcsy_32",all_in_one_index_text="_text_vmcsy_44",all_in_one_index_icon="_icon_vmcsy_53",all_in_one_index_actions="_actions_vmcsy_56",all_in_one_index_item="_item_vmcsy_61",all_in_one_index_img="_img_vmcsy_82",all_in_one_index_content="_content_vmcsy_85",hoverable="_hoverable_vmcsy_98",styles$4={container:container$3,dark:dark,"code-area":"_code-area_vmcsy_20",header:all_in_one_index_header,text:all_in_one_index_text,icon:all_in_one_index_icon,actions:all_in_one_index_actions,item:all_in_one_index_item,img:all_in_one_index_img,content:all_in_one_index_content,hoverable:hoverable,"light-scrollbar":"_light-scrollbar_vmcsy_121"},CodeBlock=({className:e,style:t,code:n,language:r,onCopyCode:s,showHeader:i=!0,raw:a,parents:o})=>{const{mode:l}=useCalypsoConfig(),c="dark"===l,{CodeBlockHighlighter:u}=useCalypsoSlots(),[d,p]=(0,react.useState)(!1),m=useAutoDetectLanguage(n,r);return (0,jsx_runtime.jsx)("div",{"data-testid":"code_block",className:classnames(styles$4.container,e,"hide-indicator",{[styles$4.dark]:c}),style:t,children:(0,jsx_runtime.jsxs)("div",{className:classnames(styles$4["code-area"]),dir:"ltr",children:[i&&(0,jsx_runtime.jsxs)("div",{className:styles$4.header,children:[(0,jsx_runtime.jsxs)("div",{className:styles$4.text,children:[(0,jsx_runtime.jsx)(SvgCodeIcon,{className:styles$4.icon}),m]}),(0,jsx_runtime.jsx)("div",{className:styles$4.actions,children:(0,jsx_runtime.jsx)("div",{className:styles$4.item,onClick:()=>{d||(copy_to_clipboard(n),null==s||s(n),p(!0),setTimeout((()=>{p(!1)}),3e3))},children:(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.icon,styles$4.hoverable),"data-testid":"code_block_copy",children:(0,jsx_runtime.jsx)(d?SvgDoneIcon:SvgCopyIcon,{className:styles$4.img})})})})]}),(0,jsx_runtime.jsx)("div",{className:classnames(styles$4.content,styles$4[`content--${m.toLowerCase()}`]),children:u&&(0,jsx_runtime.jsx)(u,{code:n,language:r,raw:a,parents:o,dark:c})})]})})},codeBlockPlugin={name:"code-block",slots:{CodeBlock:CodeBlock}},all_in_one_index_wrapper="_wrapper_aaa8t_1",wrapperStyles={wrapper:all_in_one_index_wrapper},container$2="_container_1lt86_9",styles$3={container:container$2},BreakLine=({className:e,style:t})=>(0,jsx_runtime.jsx)("br",{className:classnames(styles$3.container,e),style:t}),withCalypsoBreakLine=e=>function({className:t,...n}){return (0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:e&&(0,jsx_runtime.jsx)(e,{className:classnames(wrapperStyles.wrapper,t,{[styles$3["non-select"]]:!all_in_one_index_isSafari()}),...n})})},WrappedBreakLine=withCalypsoBreakLine(BreakLine),breakLinePlugin={name:"break-line",slots:{BreakLine:WrappedBreakLine}},Blockquote=({className:e,style:t,node:n,children:r,renderRest:s})=>(0,jsx_runtime.jsx)(BlockElement,{className:e,style:t,node:n,renderRest:s,children:r}),blockquotePlugin={name:"blockquote",slots:{Blockquote:Blockquote}},defaultPlugins=[breakLinePlugin,texLightPlugin,codeHighlighterPrismPlugin,codeBlockPlugin,tablePlugin,imagePlugin,indicatorPlugin,paragraphPlugin,linkPlugin,emphasisPlugin,strongPlugin,headerPlugin,listPlugin,blockquotePlugin],CalypsoLite=(0,react.forwardRef)((function(e,t){return (0,jsx_runtime.jsx)(CalypsoCore,{ref:t,plugins:defaultPlugins,...e})})),safeKatexTexToHtml=(e,t={})=>{try{return katex["default"].renderToString(e,{throwOnError:!1,strict:!1,output:"html",trust:!1,...t})}catch(e){return null}},adaptor=(0,liteAdaptor.liteAdaptor)();(0,handlers_html.RegisterHTMLHandler)(adaptor);const all_in_one_index_tex=new tex.TeX({packages:[...AllPackages.AllPackages.sort().join(", ").split(/\s*,\s*/),"physics","mhchem"],macros:{equalparallel:"{\\lower{2.6pt}{\\arrowvert\\hspace{-4.2pt}\\arrowvert}\\above{-2pt}\\raise{7.5pt}{=}}",number:["{#1}",1],unit:["{#1}",1],div:"{÷}"}}),all_in_one_index_svg=new output_svg.SVG({fontCache:"none"}),all_in_one_index_html=mathjax.mathjax.document("",{InputJax:all_in_one_index_tex,OutputJax:all_in_one_index_svg}),texToSvg=e=>{var t;const n=xregexp_lib.replace(e,xregexp_lib(String.raw`[^\P{C}\n\t]+`,"ug"),"");try{const e=all_in_one_index_html.convert(n,{display:!0,em:16,ex:8,containerWidth:1280});return adaptor.outerHTML(null==(t=null==e?void 0:e.children)?void 0:t[0])}catch(t){return safeKatexTexToHtml(e)??e}},container$1="_container_1dcs1_1",single$1="_single_1dcs1_16",all_in_one_index_error="_error_1dcs1_44",styles$2={container:container$1,single:single$1,error:all_in_one_index_error},RawMathjaxTex=(0,react.forwardRef)((function({className:e,style:t,tex:n,html:r},s){const i=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(n.trim())),[n]),a=Boolean(null==r?void 0:r.includes("data-mjx-error")),o=!lodash_es_isUndefined(r)&&!a;return (0,jsx_runtime.jsx)("span",{ref:s,className:classnames(styles$2.container,e,"math-inline",{[styles$2.single]:i,[styles$2.error]:a}),style:t,dangerouslySetInnerHTML:o?{__html:r}:void 0,"data-custom-copy-text":`\\(${n}\\)`,children:o?null:n})})),MathJaxTex=({className:e,style:t,tex:n,mode:r})=>{const s=(0,react.useMemo)((()=>purifyHtml(texToSvg(n))),[n]);return (0,jsx_runtime.jsx)(RawMathjaxTex,{className:e,style:t,tex:n,html:s})},Calypso=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,...n},r){return (0,jsx_runtime.jsx)(CalypsoLite,{ref:r,slots:lodash_es_defaults(e,{Tex:MathJaxTex,CodeBlockHighlighter:PrismCodeBlockHighlighter}),autoFixSyntax:t&&{katex:katex["default"],...lodash_es_isBoolean(t)?{}:t},...n})}));class DefaultParseError extends Error{constructor(e,t,n){super(),this.message=e,this.lexer=t,this.position=n}}const useLazyKatex=()=>{const[e,t]=(0,react.useState)(),n=(0,react.useCallback)((async()=>{if(e)return;const{default:n}=await retryLoad((()=>Promise.resolve(/* import() */).then(__webpack_require__.bind(__webpack_require__, 97234))));t(n)}),[e]),r=(0,react.useMemo)((()=>{var e;return(e=class{static render(){throw n(),new DefaultParseError("DefaultKatex.render has called",{},0)}static renderToString(){throw n(),new DefaultParseError("DefaultKatex.renderToString has called",{},0)}}).ParseError=DefaultParseError,e}),[n]);return e??r},withSuspense=(e,t)=>{const n=n=>(0,jsx_runtime.jsx)(react.Suspense,{fallback:t&&(0,jsx_runtime.jsx)(t,{...n}),children:(0,jsx_runtime.jsx)(e,{...n})});return n.displayName=e.displayName??(null==t?void 0:t.displayName),n},useLazyComponent=(e,t,n={})=>{const{retryTimes:r=5,retryInterval:s=100}=n;return (0,react.useMemo)((()=>withSuspense(react.lazy(withRetry(e,{tryTimes:r,interval:s,fallback:{default:t}})),t)),[r,s])},styles$1={"light-scrollbar":"_light-scrollbar_1ks9r_1"},LightCodeBlockHighlighter=({language:e,code:t,className:n,style:r})=>(0,jsx_runtime.jsx)("pre",{className:classnames(e&&`language-${e}`,styles$1["light-scrollbar"],n),style:r,children:(0,jsx_runtime.jsx)("code",{children:t})}),CalypsoLazy=(0,react.forwardRef)((function({slots:e={},autoFixSyntax:t=!0,retryTimes:n=5,retryInterval:r=100,...s},i){const a=useLazyKatex(),o=useLazyComponent((()=>Promise.resolve().then((()=>index$1))),LightTex,{retryTimes:n,retryInterval:r}),l=useLazyComponent((()=>Promise.resolve().then((()=>all_in_one_index_index))),o,{retryTimes:n,retryInterval:r}),c=useLazyComponent((()=>Promise.resolve().then((()=>index$2))),LightCodeBlockHighlighter,{retryTimes:n,retryInterval:r});return (0,jsx_runtime.jsx)(CalypsoLite,{ref:i,slots:lodash_es_defaults(e,{Tex:l,CodeBlockHighlighter:c}),autoFixSyntax:t&&{katex:a,...lodash_es_isBoolean(t)?{}:t},...s})})),AsyncLazyMathJaxTex=({className:e,style:t,tex:n})=>{const[r,s]=useState(),[i,a]=useState(!1),o=useRef(null);return useEffect((()=>{i&&s(texToSvg(n))}),[n,i]),useEffect((()=>{const e=new IntersectionObserver((t=>{if(!(null==t?void 0:t[0]))return;const{intersectionRatio:n}=t[0];n>0&&(a(!0),e.disconnect())}));return o.current&&e.observe(o.current),()=>{e.disconnect()}}),[]),jsx(RawMathjaxTex,{ref:o,className:e,style:t,tex:n,html:r})},asyncLazyMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"async-lazy-mathjax-tex",slots:{Tex:AsyncLazyMathJaxTex}})),codeHighlighterLightPlugin=(/* unused pure expression or super */ null && ({name:"code-highlighter-light",slots:{CodeBlockHighlighter:LightCodeBlockHighlighter}})),all_in_one_index_container="_container_imek1_1",all_in_one_index_single="_single_imek1_6",all_in_one_index_block="_block_imek1_9",all_in_one_index_styles={container:all_in_one_index_container,single:all_in_one_index_single,block:all_in_one_index_block},KatexTex=({tex:e,mode:t,className:n,style:r,fallback:s,katexOptions:i})=>{const a=useDeepCompareMemo((()=>safeKatexTexToHtml(e,i)),[e,i]),o=useDeepCompareMemo((()=>a?null:safeKatexTexToHtml(e,{...i,displayMode:!0})),[e,i,Boolean(a)]),l=(0,react.useMemo)((()=>/^[a-zA-Z0-9\s]+$/.test(e.trim())),[e]);return!s||a||o?(0,jsx_runtime.jsx)("span",{className:classnames(all_in_one_index_styles.container,n,"math-inline",{[all_in_one_index_styles.single]:l,[all_in_one_index_styles.block]:Boolean(o)}),style:r,dangerouslySetInnerHTML:{__html:purifyHtml((a||o)??e)},"data-custom-copy-text":l?e:`\\(${e}\\)`}):(0,jsx_runtime.jsx)(jsx_runtime.Fragment,{children:s})},index$1=Object.freeze(Object.defineProperty({__proto__:null,KatexTex:KatexTex,default:KatexTex},Symbol.toStringTag,{value:"Module"})),katexTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-tex",slots:{Tex:KatexTex}})),KatexMathjaxTex=e=>(0,jsx_runtime.jsx)(KatexTex,{...e,katexOptions:{strict:!0,throwOnError:!0},fallback:(0,jsx_runtime.jsx)(MathJaxTex,{...e})}),all_in_one_index_index=Object.freeze(Object.defineProperty({__proto__:null,KatexMathjaxTex:KatexMathjaxTex,default:KatexMathjaxTex},Symbol.toStringTag,{value:"Module"})),katexMathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"katex-mathjax-tex",slots:{Tex:KatexMathjaxTex}})),mathjaxTexPlugin=(/* unused pure expression or super */ null && ({name:"mathjax-tex",slots:{Tex:MathJaxTex}}));
295966
296437
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/context/onboarding/index.ts
295967
296438
  /*
295968
296439
  * Copyright 2025 coze-dev Authors
@@ -299866,7 +300337,7 @@ function useEventListener_useEventListener(eventName, handler, options) {
299866
300337
  if (options === void 0) {
299867
300338
  options = {};
299868
300339
  }
299869
- var handlerRef = es_useLatest(handler);
300340
+ var handlerRef = useLatest(handler);
299870
300341
  utils_useEffectWithTarget(function () {
299871
300342
  var targetElement = getTargetElement(options.target, window);
299872
300343
  if (!(targetElement === null || targetElement === void 0 ? void 0 : targetElement.addEventListener)) {
@@ -299933,7 +300404,7 @@ var getShadow = function (node) {
299933
300404
  }
299934
300405
  return node.getRootNode();
299935
300406
  };
299936
- var getDocumentOrShadow_getDocumentOrShadow = function (target) {
300407
+ var getDocumentOrShadow = function (target) {
299937
300408
  if (!target || !document.getRootNode) {
299938
300409
  return document;
299939
300410
  }
@@ -299943,7 +300414,7 @@ var getDocumentOrShadow_getDocumentOrShadow = function (target) {
299943
300414
  }
299944
300415
  return document;
299945
300416
  };
299946
- /* ESM default export */ const getDocumentOrShadow = (getDocumentOrShadow_getDocumentOrShadow);
300417
+ /* ESM default export */ const utils_getDocumentOrShadow = (getDocumentOrShadow);
299947
300418
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useClickAway/index.js
299948
300419
 
299949
300420
 
@@ -299953,7 +300424,7 @@ function useClickAway(onClickAway, target, eventName) {
299953
300424
  if (eventName === void 0) {
299954
300425
  eventName = 'click';
299955
300426
  }
299956
- var onClickAwayRef = es_useLatest(onClickAway);
300427
+ var onClickAwayRef = useLatest(onClickAway);
299957
300428
  utils_useEffectWithTarget(function () {
299958
300429
  var handler = function (event) {
299959
300430
  var targets = Array.isArray(target) ? target : [target];
@@ -299965,7 +300436,7 @@ function useClickAway(onClickAway, target, eventName) {
299965
300436
  }
299966
300437
  onClickAwayRef.current(event);
299967
300438
  };
299968
- var documentOrShadow = getDocumentOrShadow(target);
300439
+ var documentOrShadow = utils_getDocumentOrShadow(target);
299969
300440
  var eventNames = Array.isArray(eventName) ? eventName : [eventName];
299970
300441
  eventNames.forEach(function (event) {
299971
300442
  return documentOrShadow.addEventListener(event, handler);
@@ -300276,14 +300747,14 @@ MessageContentTime.displayName = 'MessageContentTime';
300276
300747
 
300277
300748
 
300278
300749
 
300279
- function useDebounceFn(fn, options) {
300750
+ function useDebounceFn_useDebounceFn(fn, options) {
300280
300751
  var _a;
300281
300752
  if (isDev) {
300282
300753
  if (!utils_isFunction(fn)) {
300283
300754
  console.error("useDebounceFn expected parameter is a function, got ".concat(typeof fn));
300284
300755
  }
300285
300756
  }
300286
- var fnRef = es_useLatest(fn);
300757
+ var fnRef = useLatest(fn);
300287
300758
  var wait = (_a = options === null || options === void 0 ? void 0 : options.wait) !== null && _a !== void 0 ? _a : 1000;
300288
300759
  var debounced = (0,react.useMemo)(function () {
300289
300760
  return debounce_default()(function () {
@@ -300303,7 +300774,7 @@ function useDebounceFn(fn, options) {
300303
300774
  flush: debounced.flush
300304
300775
  };
300305
300776
  }
300306
- /* ESM default export */ const es_useDebounceFn = (useDebounceFn);
300777
+ /* ESM default export */ const useDebounceFn = (useDebounceFn_useDebounceFn);
300307
300778
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-uikit/src/hooks/use-observe-card-container.ts
300308
300779
  /*
300309
300780
  * Copyright 2025 coze-dev Authors
@@ -300325,7 +300796,7 @@ function useDebounceFn(fn, options) {
300325
300796
  const useObserveCardContainer = (param)=>{
300326
300797
  let { messageId, cardContainerRef, onResize } = param;
300327
300798
  const eventCenter = useUiKitEventCenter();
300328
- /** If there is no change within 30s, the observer will be automatically cleared. */ const debouncedDisconnect = es_useDebounceFn((getResizeObserver)=>{
300799
+ /** If there is no change within 30s, the observer will be automatically cleared. */ const debouncedDisconnect = useDebounceFn((getResizeObserver)=>{
300329
300800
  const resizeObserver = getResizeObserver();
300330
300801
  resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.disconnect();
300331
300802
  }, {
@@ -301261,8 +301732,8 @@ function useKeyPress_useKeyPress(keyFilter, eventHandler, option) {
301261
301732
  exactMatch = _c === void 0 ? false : _c,
301262
301733
  _d = _a.useCapture,
301263
301734
  useCapture = _d === void 0 ? false : _d;
301264
- var eventHandlerRef = es_useLatest(eventHandler);
301265
- var keyFilterRef = es_useLatest(keyFilter);
301735
+ var eventHandlerRef = useLatest(eventHandler);
301736
+ var keyFilterRef = useLatest(keyFilter);
301266
301737
  useDeepCompareWithTarget(function () {
301267
301738
  var e_2, _a;
301268
301739
  var _b;
@@ -301351,10 +301822,10 @@ const useAudioRecordInteraction = (param)=>{
301351
301822
  let { target, events, options = {} } = param;
301352
301823
  const { onStart, onEnd, onMoveEnter, onMoveLeave } = events;
301353
301824
  const { shortcutKey = ()=>false, getIsShortcutKeyDisabled, enabled = true, getActiveZoneTarget } = options;
301354
- const onStartRef = es_useLatest(onStart);
301355
- const onEndRef = es_useLatest(onEnd);
301356
- const onMoveEnterRef = es_useLatest(onMoveEnter);
301357
- const onMoveLeaveRef = es_useLatest(onMoveLeave);
301825
+ const onStartRef = useLatest(onStart);
301826
+ const onEndRef = useLatest(onEnd);
301827
+ const onMoveEnterRef = useLatest(onMoveEnter);
301828
+ const onMoveLeaveRef = useLatest(onMoveLeave);
301358
301829
  const isKeydown = (0,react.useRef)(false);
301359
301830
  const isMouseOrTouchDown = (0,react.useRef)(false);
301360
301831
  const isMoveLeave = (0,react.useRef)(false);
@@ -383888,9 +384359,11 @@ var suggestion_index_module_update = injectStylesIntoStyleTag_default()(suggesti
383888
384359
 
383889
384360
 
383890
384361
  const SuggestionInChat = ()=>{
384362
+ var _suggestionBatch_suggestions;
383891
384363
  const { useMessagesStore, useSuggestionsStore } = use_chat_area_context_useChatAreaStoreSet();
383892
384364
  const { enableMention } = usePreference();
383893
- // Before fixme, it is unreliable to directly take the last message for processing, and there are still problems after modification. Consider the suggestion stored in the sender_id
384365
+ // Before fixme, it is unreliable to directly take the last message for processing,
384366
+ // and there are still problems after modification. Consider the suggestion stored in the sender_id
383894
384367
  const latestGroup = useMessagesStore((state)=>state.messageGroupList.at(0));
383895
384368
  const senderId = useMessagesStore((state)=>{
383896
384369
  var _state_messages_find;
@@ -383900,10 +384373,14 @@ const SuggestionInChat = ()=>{
383900
384373
  // So it must not be possible to reverse index based on replyId
383901
384374
  const replyId = latestGroup === null || latestGroup === void 0 ? void 0 : latestGroup.groupId;
383902
384375
  const { latestSectionHasMessage } = useMessagesOverview();
383903
- const suggestionBatch = useSuggestionsStore((state)=>latestSectionHasMessage ? state.getSuggestions(replyId) : undefined);
384376
+ // Always try to get suggestions, even if latestSectionHasMessage is false
384377
+ // This ensures suggestions are displayed even when section state is temporarily inconsistent
384378
+ const suggestionBatch = useSuggestionsStore((state)=>state.getSuggestions(replyId));
383904
384379
  const { selectable, messageWidth, layout } = usePreference();
383905
384380
  const showBackground = useShowBackGround();
383906
- if (!latestSectionHasMessage) {
384381
+ // Only hide suggestions if there are no messages in the latest section AND no suggestions exist
384382
+ // This prevents suggestions from disappearing when section state is temporarily inconsistent
384383
+ if (!latestSectionHasMessage && !(suggestionBatch === null || suggestionBatch === void 0 ? void 0 : (_suggestionBatch_suggestions = suggestionBatch.suggestions) === null || _suggestionBatch_suggestions === void 0 ? void 0 : _suggestionBatch_suggestions.length)) {
383907
384384
  return null;
383908
384385
  }
383909
384386
  if (suggestionBatch === null || suggestionBatch === void 0 ? void 0 : suggestionBatch.isError) {
@@ -384190,20 +384667,17 @@ const MessageGroupWrapper = /*#__PURE__*/ (0,react.memo)((param)=>{
384190
384667
  const { useMessageMetaStore } = use_chat_area_context_useChatAreaStoreSet();
384191
384668
  const { messageGroupWrapper } = componentTypesMap;
384192
384669
  const Wrapper = messageGroupWrapper || BuiltinMessageGroupWrapper;
384193
- const { memberSet: { userMessageId }, groupId, showContextDivider, isLatest } = messageGroup;
384670
+ const { memberSet: { userMessageId }, groupId, isLatest } = messageGroup;
384194
384671
  const userMessageMeta = useMessageMetaStore((state)=>{
384195
384672
  if (!userMessageId) {
384196
384673
  return;
384197
384674
  }
384198
384675
  return message_findMessageById(state.metaList, userMessageId);
384199
384676
  }, lodash_es_isEqual);
384200
- // TODO: Current server level does not support interrupting local messages. Sending messages cannot be deleted. This status needs to be flagged
384677
+ // TODO: Current server level does not support interrupting local messages.
384678
+ // Sending messages cannot be deleted. This status needs to be flagged
384201
384679
  const isSendingMessage = Boolean(userMessageMeta === null || userMessageMeta === void 0 ? void 0 : userMessageMeta.isSending);
384202
384680
  const deleteMessageGroup = use_delete_message_group_useDeleteMessageGroup();
384203
- const { showClearContextDivider: showClearContextDividerByPreference } = usePreference();
384204
- console.log('showClearContextDividerByPreference', showClearContextDividerByPreference);
384205
- console.log('showContextDivider', showContextDivider);
384206
- const showContextDividerWithOnboarding = showClearContextDividerByPreference && showContextDivider;
384207
384681
  const customMessageGroupFooterPlugin = use_plugin_custom_components_usePluginCustomComponents('MessageGroupFooter').at(0);
384208
384682
  const renderFooter = ()=>{
384209
384683
  const usedFooter = customMessageGroupFooterPlugin;
@@ -384225,7 +384699,7 @@ const MessageGroupWrapper = /*#__PURE__*/ (0,react.memo)((param)=>{
384225
384699
  renderFooter === null || renderFooter === void 0 ? void 0 : renderFooter(),
384226
384700
  isLatest ? /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
384227
384701
  children: [
384228
- !showContextDividerWithOnboarding && /*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionInChat, {}),
384702
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(SuggestionInChat, {}),
384229
384703
  /*#__PURE__*/ (0,jsx_runtime.jsx)(WaitGenerating, {})
384230
384704
  ]
384231
384705
  }) : null,
@@ -385065,7 +385539,7 @@ var intersection_observer = __webpack_require__(3685);
385065
385539
 
385066
385540
 
385067
385541
 
385068
- function useInViewport_useInViewport(target, options) {
385542
+ function useInViewport(target, options) {
385069
385543
  var _a = __read((0,react.useState)(), 2),
385070
385544
  state = _a[0],
385071
385545
  setState = _a[1];
@@ -385106,7 +385580,7 @@ function useInViewport_useInViewport(target, options) {
385106
385580
  }, [options === null || options === void 0 ? void 0 : options.rootMargin, options === null || options === void 0 ? void 0 : options.threshold], target);
385107
385581
  return [state, ratio];
385108
385582
  }
385109
- /* ESM default export */ const useInViewport = (useInViewport_useInViewport);
385583
+ /* ESM default export */ const es_useInViewport = (useInViewport);
385110
385584
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-area/src/components/message-box/reveal-trigger.tsx
385111
385585
  /*
385112
385586
  * Copyright 2025 coze-dev Authors
@@ -385133,7 +385607,7 @@ const RevealTrigger = ()=>{
385133
385607
  const { message } = message_box_useMessageBoxContext();
385134
385608
  const reportMarkRead = useMarkMessageRead();
385135
385609
  const { eventCallback } = use_chat_area_context_useChatAreaContext();
385136
- const [inViewport] = useInViewport(()=>boxBottomRef.current);
385610
+ const [inViewport] = es_useInViewport(()=>boxBottomRef.current);
385137
385611
  (0,react.useEffect)(()=>{
385138
385612
  var _eventCallback_onMessageBottomShow;
385139
385613
  if (!inViewport) {
@@ -396389,7 +396863,7 @@ const LoadMore = (param)=>{
396389
396863
  const { loadByScrollPrev, loadByScrollNext } = useLoadMoreClient();
396390
396864
  const load = isForPrev ? loadByScrollPrev : loadByScrollNext;
396391
396865
  const spinRef = (0,react.useRef)(null);
396392
- const [inViewport] = useInViewport(()=>spinRef.current);
396866
+ const [inViewport] = es_useInViewport(()=>spinRef.current);
396393
396867
  // Prevent two consecutive requests from being triggered (loading changes earlier than explicit changes in the IconSpin component)
396394
396868
  const deferredLoading = (0,react.useDeferredValue)(loading);
396395
396869
  (0,react.useEffect)(()=>{
@@ -398646,7 +399120,7 @@ var useCountdown = function (options) {
398646
399120
  }), 2),
398647
399121
  timeLeft = _c[0],
398648
399122
  setTimeLeft = _c[1];
398649
- var onEndRef = es_useLatest(onEnd);
399123
+ var onEndRef = useLatest(onEnd);
398650
399124
  (0,react.useEffect)(function () {
398651
399125
  if (!target) {
398652
399126
  // for stop
@@ -404266,7 +404740,9 @@ class InitStoreService {
404266
404740
  }
404267
404741
  /**
404268
404742
  * Clear Store Set
404269
- */ clearStoreSet() {
404743
+ * @param options - Options for clearing store set
404744
+ * @param options.preserveSuggestions - If true, preserve suggestions during clear (useful for re-initialization)
404745
+ */ clearStoreSet(options) {
404270
404746
  if (!this.storeSet) {
404271
404747
  return;
404272
404748
  }
@@ -404279,7 +404755,11 @@ class InitStoreService {
404279
404755
  useWaitingStore.getState().clearAllUnsettledUnconditionally();
404280
404756
  useOnboardingStore.getState().clearOnboardingStore();
404281
404757
  useFileStore.getState().clear();
404282
- useSuggestionsStore.getState().clearSuggestions();
404758
+ // Preserve suggestions during re-initialization to avoid losing follow_up messages
404759
+ // that were received via streaming but not yet saved to message history
404760
+ if (!(options === null || options === void 0 ? void 0 : options.preserveSuggestions)) {
404761
+ useSuggestionsStore.getState().clearSuggestions();
404762
+ }
404283
404763
  useSelectionStore.getState().clearSelectedReplyIdList();
404284
404764
  useSenderInfoStore.getState().clearSenderInfoStore();
404285
404765
  useBatchFileUploadStore.getState().clearAllData();
@@ -404513,7 +404993,11 @@ class InitService {
404513
404993
  /**
404514
404994
  * Function to clear side effects
404515
404995
  */ clearInitSideEffect() {
404516
- this.initStoreService.clearStoreSet();
404996
+ // Preserve suggestions during re-initialization to avoid losing follow_up messages
404997
+ // that were received via streaming but not yet saved to message history
404998
+ this.initStoreService.clearStoreSet({
404999
+ preserveSuggestions: true
405000
+ });
404517
405001
  this.preInitStoreService.clearStoreSet();
404518
405002
  }
404519
405003
  /**
@@ -406980,7 +407464,7 @@ var useDebouncePlugin = function (fetchInstance, _a) {
406980
407464
  /* ESM default export */ const plugins_useDebouncePlugin = (useDebouncePlugin);
406981
407465
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/src/plugins/useLoadingDelayPlugin.js
406982
407466
 
406983
- var useLoadingDelayPlugin_useLoadingDelayPlugin = function (fetchInstance, _a) {
407467
+ var useLoadingDelayPlugin = function (fetchInstance, _a) {
406984
407468
  var loadingDelay = _a.loadingDelay,
406985
407469
  ready = _a.ready;
406986
407470
  var timerRef = (0,react.useRef)();
@@ -407017,7 +407501,7 @@ var useLoadingDelayPlugin_useLoadingDelayPlugin = function (fetchInstance, _a) {
407017
407501
  }
407018
407502
  };
407019
407503
  };
407020
- /* ESM default export */ const useLoadingDelayPlugin = (useLoadingDelayPlugin_useLoadingDelayPlugin);
407504
+ /* ESM default export */ const plugins_useLoadingDelayPlugin = (useLoadingDelayPlugin);
407021
407505
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/src/utils/isDocumentVisible.js
407022
407506
 
407023
407507
  function isDocumentVisible() {
@@ -407496,8 +407980,8 @@ function useRequestImplement_useRequestImplement(service, options, plugins) {
407496
407980
  var fetchOptions = tslib_es6_assign({
407497
407981
  manual: manual
407498
407982
  }, rest);
407499
- var serviceRef = es_useLatest(service);
407500
- var update = es_useUpdate();
407983
+ var serviceRef = useLatest(service);
407984
+ var update = useUpdate();
407501
407985
  var fetchInstance = useCreation(function () {
407502
407986
  var initState = plugins.map(function (p) {
407503
407987
  var _a;
@@ -407557,7 +408041,7 @@ function useRequestImplement_useRequestImplement(service, options, plugins) {
407557
408041
  // plugins?: Plugin<TData, TParams>[],
407558
408042
  // ): Result<TData, TParams>
407559
408043
  function useRequest_useRequest(service, options, plugins) {
407560
- return useRequestImplement(service, options, tslib_es6_spreadArray(tslib_es6_spreadArray([], __read(plugins || []), false), [plugins_useDebouncePlugin, useLoadingDelayPlugin, usePollingPlugin, plugins_useRefreshOnWindowFocusPlugin, useThrottlePlugin, plugins_useAutoRunPlugin, plugins_useCachePlugin, plugins_useRetryPlugin], false));
408044
+ return useRequestImplement(service, options, tslib_es6_spreadArray(tslib_es6_spreadArray([], __read(plugins || []), false), [plugins_useDebouncePlugin, plugins_useLoadingDelayPlugin, usePollingPlugin, plugins_useRefreshOnWindowFocusPlugin, useThrottlePlugin, plugins_useAutoRunPlugin, plugins_useCachePlugin, plugins_useRetryPlugin], false));
407561
408045
  }
407562
408046
  /* ESM default export */ const src_useRequest = (useRequest_useRequest);
407563
408047
  ;// CONCATENATED MODULE: ../../../../../common/temp/default/node_modules/.pnpm/ahooks@3.7.8_patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i_react@18.2.0/node_modules/ahooks/es/useRequest/index.js
@@ -420473,9 +420957,6 @@ class MessageParser {
420473
420957
  }
420474
420958
  }
420475
420959
  }
420476
- if (isComplete && message.content_type === types_ContentType.Text && message.type === 'answer') {
420477
- message.content = '';
420478
- }
420479
420960
  message.section_id = message.section_id || this.sectionId;
420480
420961
  return {
420481
420962
  event: 'message',
@@ -421120,6 +421601,22 @@ class MessageParser {
421120
421601
  console.error('onBeforeSendMessage: conversationId is empty after creation');
421121
421602
  throw new Error('conversationId is required for sending message');
421122
421603
  }
421604
+ // 更新会话列表中的 updated_at,确保每次发送消息时都会更新会话的更新时间
421605
+ // 这样会话列表可以正确排序,显示最近活跃的会话
421606
+ const existingConversation = refConversations.current.find((c)=>c.id === conversationId);
421607
+ if (existingConversation && refUpdateConversations.current) {
421608
+ const updatedConversation = {
421609
+ id: conversationId,
421610
+ updated_at: Math.floor(Date.now() / 1000)
421611
+ };
421612
+ refUpdateConversations.current([
421613
+ updatedConversation
421614
+ ], 'update');
421615
+ console.log('onBeforeSendMessage: Updated conversation updated_at in list', {
421616
+ conversationId,
421617
+ updated_at: updatedConversation.updated_at
421618
+ });
421619
+ }
421123
421620
  // 使用计算后的 API URL
421124
421621
  const url = `${finalApiUrl}/v1/workflows/chat?conversation_id=${conversationId}`;
421125
421622
  // 根据 chatType 选择正确的 parameters 来源
@@ -421143,14 +421640,18 @@ class MessageParser {
421143
421640
  hasBody: !!body,
421144
421641
  bodyLength: body === null || body === void 0 ? void 0 : body.length
421145
421642
  });
421643
+ // 确保 headers 是一个数组
421644
+ const headers = Array.isArray(requestConfig.headers) ? [
421645
+ ...requestConfig.headers
421646
+ ] : [];
421146
421647
  Object.keys((debug === null || debug === void 0 ? void 0 : debug.cozeApiRequestHeader) || {}).forEach((key)=>{
421147
421648
  var _debug_cozeApiRequestHeader;
421148
- requestConfig.headers.push([
421649
+ headers.push([
421149
421650
  key,
421150
421651
  (debug === null || debug === void 0 ? void 0 : (_debug_cozeApiRequestHeader = debug.cozeApiRequestHeader) === null || _debug_cozeApiRequestHeader === void 0 ? void 0 : _debug_cozeApiRequestHeader[key]) || ''
421151
421652
  ]);
421152
421653
  });
421153
- requestConfig.headers.push([
421654
+ headers.push([
421154
421655
  'Accept-Language',
421155
421656
  intl.language === 'zh-CN' ? 'zh' : 'en'
421156
421657
  ]);
@@ -421159,7 +421660,7 @@ class MessageParser {
421159
421660
  body,
421160
421661
  url,
421161
421662
  method: requestConfig.method || 'POST',
421162
- headers: requestConfig.headers || []
421663
+ headers
421163
421664
  };
421164
421665
  console.log('onBeforeSendMessage: Returning config', {
421165
421666
  url: finalConfig.url,
@@ -422955,6 +423456,542 @@ const QuoteMessage = (props)=>{
422955
423456
  };
422956
423457
  QuoteMessage.displayName = 'QuoteMessage';
422957
423458
 
423459
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/context.tsx
423460
+ /*
423461
+ * Copyright 2025 coze-dev Authors
423462
+ *
423463
+ * Licensed under the Apache License, Version 2.0 (the "License");
423464
+ * you may not use this file except in compliance with the License.
423465
+ * You may obtain a copy of the License at
423466
+ *
423467
+ * http://www.apache.org/licenses/LICENSE-2.0
423468
+ *
423469
+ * Unless required by applicable law or agreed to in writing, software
423470
+ * distributed under the License is distributed on an "AS IS" BASIS,
423471
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423472
+ * See the License for the specific language governing permissions and
423473
+ * limitations under the License.
423474
+ */
423475
+ const CommentContext = /*#__PURE__*/ (0,react.createContext)({});
423476
+ const CommentProvider = CommentContext.Provider;
423477
+
423478
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/comment/index.ts
423479
+ /*
423480
+ * Copyright 2025 coze-dev Authors
423481
+ *
423482
+ * Licensed under the Apache License, Version 2.0 (the "License");
423483
+ * you may not use this file except in compliance with the License.
423484
+ * You may obtain a copy of the License at
423485
+ *
423486
+ * http://www.apache.org/licenses/LICENSE-2.0
423487
+ *
423488
+ * Unless required by applicable law or agreed to in writing, software
423489
+ * distributed under the License is distributed on an "AS IS" BASIS,
423490
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423491
+ * See the License for the specific language governing permissions and
423492
+ * limitations under the License.
423493
+ */
423494
+
423495
+ // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423496
+ var comment_message_index_module = __webpack_require__(94148);
423497
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.module.less
423498
+
423499
+
423500
+
423501
+
423502
+
423503
+
423504
+
423505
+
423506
+
423507
+
423508
+
423509
+ var comment_message_index_module_options = {};
423510
+
423511
+ comment_message_index_module_options.styleTagTransform = (styleTagTransform_default());
423512
+ comment_message_index_module_options.setAttributes = (setAttributesWithoutAttributes_default());
423513
+
423514
+ comment_message_index_module_options.insert = insertBySelector_default().bind(null, "head");
423515
+
423516
+ comment_message_index_module_options.domAPI = (styleDomAPI_default());
423517
+ comment_message_index_module_options.insertStyleElement = (insertStyleElement_default());
423518
+
423519
+ var comment_message_index_module_update = injectStylesIntoStyleTag_default()(comment_message_index_module/* ["default"] */.A, comment_message_index_module_options);
423520
+
423521
+
423522
+
423523
+
423524
+ /* ESM default export */ const components_comment_message_index_module = (comment_message_index_module/* ["default"] */.A && comment_message_index_module/* ["default"].locals */.A.locals ? comment_message_index_module/* ["default"].locals */.A.locals : undefined);
423525
+
423526
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/feedback-dialog.tsx
423527
+ /*
423528
+ * Copyright 2025 coze-dev Authors
423529
+ *
423530
+ * Licensed under the Apache License, Version 2.0 (the "License");
423531
+ * you may not use this file except in compliance with the License.
423532
+ * You may obtain a copy of the License at
423533
+ *
423534
+ * http://www.apache.org/licenses/LICENSE-2.0
423535
+ *
423536
+ * Unless required by applicable law or agreed to in writing, software
423537
+ * distributed under the License is distributed on an "AS IS" BASIS,
423538
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423539
+ * See the License for the specific language governing permissions and
423540
+ * limitations under the License.
423541
+ */
423542
+
423543
+
423544
+
423545
+
423546
+
423547
+ const DEFAULT_FEEDBACK_OPTIONS = [
423548
+ {
423549
+ value: 'HARMFUL',
423550
+ label: '有害/不安全'
423551
+ },
423552
+ {
423553
+ value: 'FALSE_INFO',
423554
+ label: '虚假信息'
423555
+ },
423556
+ {
423557
+ value: 'NOT_HELPFUL',
423558
+ label: '没有帮助'
423559
+ },
423560
+ {
423561
+ value: 'OTHER',
423562
+ label: '其他'
423563
+ }
423564
+ ];
423565
+ function findChatAreaContainer() {
423566
+ // 方式1: 尝试通过类名查找(CSS modules 可能生成哈希类名)
423567
+ let chatAreaMain = document.querySelector('.chat-area-main');
423568
+ // 方式2: 如果找不到,尝试查找包含 "chat-area-main" 的类名(部分匹配)
423569
+ if (!chatAreaMain) {
423570
+ const allElements = document.querySelectorAll('*');
423571
+ for (const el of allElements){
423572
+ const classList = Array.from(el.classList);
423573
+ if (classList.some((cls)=>cls.includes('chat-area-main'))) {
423574
+ chatAreaMain = el;
423575
+ break;
423576
+ }
423577
+ }
423578
+ }
423579
+ // 方式3: 如果还是找不到,使用 document.body 作为容器(使用 fixed 定位)
423580
+ return chatAreaMain || document.body;
423581
+ }
423582
+ const FeedbackDialog = (param)=>{
423583
+ let { visible, onConfirm, onCancel, feedbackTypes } = param;
423584
+ const [selectedFeedbackType, setSelectedFeedbackType] = (0,react.useState)(null);
423585
+ const [comment, setComment] = (0,react.useState)('');
423586
+ const [container, setContainer] = (0,react.useState)(null);
423587
+ (0,react.useEffect)(()=>{
423588
+ setContainer(visible ? findChatAreaContainer() : null);
423589
+ }, [
423590
+ visible
423591
+ ]);
423592
+ if (!visible) {
423593
+ return null;
423594
+ }
423595
+ // 使用接口返回的反馈类型,如果没有则使用默认值
423596
+ const feedbackOptions = feedbackTypes && feedbackTypes.length > 0 ? feedbackTypes.map((item)=>({
423597
+ value: item.value,
423598
+ label: item.label
423599
+ })) : DEFAULT_FEEDBACK_OPTIONS;
423600
+ const handleConfirm = ()=>{
423601
+ if (selectedFeedbackType) {
423602
+ onConfirm(selectedFeedbackType, comment);
423603
+ // 重置状态
423604
+ setSelectedFeedbackType(null);
423605
+ setComment('');
423606
+ }
423607
+ };
423608
+ const handleCancel = ()=>{
423609
+ setSelectedFeedbackType(null);
423610
+ setComment('');
423611
+ onCancel();
423612
+ };
423613
+ const isBodyContainer = container === document.body;
423614
+ const modalContent = /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423615
+ className: components_comment_message_index_module["feedback-overlay"],
423616
+ "data-container-is-body": isBodyContainer,
423617
+ onClick: handleCancel,
423618
+ children: /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423619
+ className: components_comment_message_index_module["feedback-dialog"],
423620
+ onClick: (e)=>{
423621
+ e.stopPropagation();
423622
+ },
423623
+ children: [
423624
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423625
+ className: components_comment_message_index_module["feedback-header"],
423626
+ children: [
423627
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("h3", {
423628
+ className: components_comment_message_index_module["feedback-title"],
423629
+ children: "反馈意见"
423630
+ }),
423631
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423632
+ type: "button",
423633
+ className: components_comment_message_index_module["feedback-close"],
423634
+ onClick: handleCancel,
423635
+ "aria-label": "关闭",
423636
+ children: "\xd7"
423637
+ })
423638
+ ]
423639
+ }),
423640
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423641
+ className: components_comment_message_index_module["feedback-content"],
423642
+ children: [
423643
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423644
+ className: components_comment_message_index_module["feedback-types"],
423645
+ children: feedbackOptions.map((option)=>/*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423646
+ type: "button",
423647
+ className: classnames_default()(components_comment_message_index_module["feedback-type-btn"], {
423648
+ [components_comment_message_index_module["feedback-type-btn-selected"]]: selectedFeedbackType === option.value
423649
+ }),
423650
+ onClick: ()=>{
423651
+ setSelectedFeedbackType(option.value);
423652
+ },
423653
+ children: option.label
423654
+ }, option.value))
423655
+ }),
423656
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("div", {
423657
+ className: components_comment_message_index_module["feedback-comment"],
423658
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)("textarea", {
423659
+ className: components_comment_message_index_module["feedback-textarea"],
423660
+ placeholder: "请告诉我们改进意见。",
423661
+ value: comment,
423662
+ onChange: (e)=>{
423663
+ setComment(e.target.value);
423664
+ },
423665
+ rows: 4
423666
+ })
423667
+ })
423668
+ ]
423669
+ }),
423670
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423671
+ className: components_comment_message_index_module["feedback-footer"],
423672
+ children: [
423673
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423674
+ type: "button",
423675
+ className: components_comment_message_index_module["feedback-btn-cancel"],
423676
+ onClick: handleCancel,
423677
+ children: "取消"
423678
+ }),
423679
+ /*#__PURE__*/ (0,jsx_runtime.jsx)("button", {
423680
+ type: "button",
423681
+ className: components_comment_message_index_module["feedback-btn-confirm"],
423682
+ onClick: handleConfirm,
423683
+ disabled: !selectedFeedbackType,
423684
+ children: "确认"
423685
+ })
423686
+ ]
423687
+ })
423688
+ ]
423689
+ })
423690
+ });
423691
+ // 如果找到了容器,使用 Portal 渲染;否则直接渲染
423692
+ if (container) {
423693
+ return /*#__PURE__*/ (0,react_dom.createPortal)(modalContent, container);
423694
+ }
423695
+ return modalContent;
423696
+ };
423697
+
423698
+ ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/components/comment-message/index.tsx
423699
+ /*
423700
+ * Copyright 2025 coze-dev Authors
423701
+ *
423702
+ * Licensed under the Apache License, Version 2.0 (the "License");
423703
+ * you may not use this file except in compliance with the License.
423704
+ * You may obtain a copy of the License at
423705
+ *
423706
+ * http://www.apache.org/licenses/LICENSE-2.0
423707
+ *
423708
+ * Unless required by applicable law or agreed to in writing, software
423709
+ * distributed under the License is distributed on an "AS IS" BASIS,
423710
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
423711
+ * See the License for the specific language governing permissions and
423712
+ * limitations under the License.
423713
+ */ /* eslint-disable @coze-arch/max-line-per-function -- 评论组件功能完整,拆分会影响可读性 */
423714
+
423715
+
423716
+
423717
+
423718
+
423719
+
423720
+
423721
+
423722
+
423723
+ /**
423724
+ * 从枚举数据中获取点赞按钮文字
423725
+ */ function getLikeLabel(enumsData, currentComment) {
423726
+ if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423727
+ return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423728
+ }
423729
+ const likeOption = enumsData.comment_names.find((item)=>item.value === 'LIKE');
423730
+ if (likeOption) {
423731
+ return currentComment === 'LIKE' ? `取消${likeOption.label}` : likeOption.label;
423732
+ }
423733
+ return currentComment === 'LIKE' ? '取消点赞' : '点赞';
423734
+ }
423735
+ /**
423736
+ * 从枚举数据中获取点踩按钮文字
423737
+ */ function getDislikeLabel(enumsData, currentComment) {
423738
+ if (!(enumsData === null || enumsData === void 0 ? void 0 : enumsData.comment_names)) {
423739
+ return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423740
+ }
423741
+ const dislikeOption = enumsData.comment_names.find((item)=>item.value === 'DISLIKE');
423742
+ if (dislikeOption) {
423743
+ return currentComment === 'DISLIKE' ? `取消${dislikeOption.label}` : dislikeOption.label;
423744
+ }
423745
+ return currentComment === 'DISLIKE' ? '取消点踩' : '点踩';
423746
+ }
423747
+ const CommentMessage = (param)=>{
423748
+ let { className, isMustGroupLastAnswerMessage = true, ...props } = param;
423749
+ var _enumsData_feedback_types;
423750
+ const { message, meta } = message_box_useMessageBoxContext();
423751
+ const { commentApiService, extractMessageParams } = (0,react.useContext)(CommentContext);
423752
+ const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
423753
+ const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
423754
+ const [currentComment, setCurrentComment] = (0,react.useState)(null);
423755
+ const [showFeedbackDialog, setShowFeedbackDialog] = (0,react.useState)(false);
423756
+ const [loading, setLoading] = (0,react.useState)(false);
423757
+ const [enumsData, setEnumsData] = (0,react.useState)(null);
423758
+ const trigger = use_tooltip_trigger_useTooltipTrigger('hover');
423759
+ // 提取消息参数,优先使用 store 中的 conversationId
423760
+ const messageParams = extractMessageParams ? extractMessageParams(message, conversationIdFromStore || undefined) : null;
423761
+ // 在组件加载时获取枚举数据和查询当前消息的评论状态
423762
+ (0,react.useEffect)(()=>{
423763
+ if (!commentApiService || !messageParams) {
423764
+ return;
423765
+ }
423766
+ const fetchEnums = async ()=>{
423767
+ if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentEnums)) {
423768
+ return;
423769
+ }
423770
+ try {
423771
+ const response = await commentApiService.getCommentEnums();
423772
+ setEnumsData(response.data);
423773
+ } catch (error) {
423774
+ console.error('[Comment Message] Failed to fetch enums:', error);
423775
+ }
423776
+ };
423777
+ const fetchCommentStatus = async ()=>{
423778
+ if (!(commentApiService === null || commentApiService === void 0 ? void 0 : commentApiService.getCommentsByChatID)) {
423779
+ return;
423780
+ }
423781
+ try {
423782
+ var _response_data_results, _response_data;
423783
+ const requestParams = {
423784
+ app_id: messageParams.appId,
423785
+ conversation_id: messageParams.conversationId,
423786
+ chat_ids: [
423787
+ messageParams.chatId
423788
+ ]
423789
+ };
423790
+ const response = await commentApiService.getCommentsByChatID(requestParams);
423791
+ const chatComments = (_response_data = response.data) === null || _response_data === void 0 ? void 0 : (_response_data_results = _response_data.results) === null || _response_data_results === void 0 ? void 0 : _response_data_results.find((item)=>item.chat_id === messageParams.chatId);
423792
+ if (chatComments === null || chatComments === void 0 ? void 0 : chatComments.comments.length) {
423793
+ const sortedComments = [
423794
+ ...chatComments.comments
423795
+ ].sort((a, b)=>b.created_at - a.created_at);
423796
+ const latestComment = sortedComments[0];
423797
+ if (latestComment) {
423798
+ setCurrentComment(latestComment.name);
423799
+ }
423800
+ }
423801
+ } catch (error) {
423802
+ console.error('[Comment Message] Failed to fetch comment status:', error);
423803
+ }
423804
+ };
423805
+ fetchEnums();
423806
+ fetchCommentStatus();
423807
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- messageParams 是对象,使用其属性作为依赖
423808
+ }, [
423809
+ commentApiService,
423810
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.chatId,
423811
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.appId,
423812
+ messageParams === null || messageParams === void 0 ? void 0 : messageParams.conversationId
423813
+ ]);
423814
+ const handleLike = (0,react.useCallback)(async ()=>{
423815
+ if (loading || !commentApiService || !messageParams) {
423816
+ return;
423817
+ }
423818
+ setLoading(true);
423819
+ try {
423820
+ // 如果已经点赞,则取消点赞(再次点击)
423821
+ if (currentComment === 'LIKE') {
423822
+ if (commentApiService.cancelComment) {
423823
+ await commentApiService.cancelComment({
423824
+ chat_id: messageParams.chatId,
423825
+ app_id: messageParams.appId,
423826
+ conversation_id: messageParams.conversationId
423827
+ });
423828
+ }
423829
+ setCurrentComment(null);
423830
+ } else {
423831
+ await commentApiService.createComment({
423832
+ chat_id: messageParams.chatId,
423833
+ app_id: messageParams.appId,
423834
+ conversation_id: messageParams.conversationId,
423835
+ name: 'LIKE'
423836
+ });
423837
+ setCurrentComment('LIKE');
423838
+ }
423839
+ } catch (error) {
423840
+ console.error('[Comment Message] Failed to handle like comment:', error);
423841
+ // 发生错误时保持当前状态
423842
+ } finally{
423843
+ setLoading(false);
423844
+ }
423845
+ }, [
423846
+ commentApiService,
423847
+ messageParams,
423848
+ currentComment,
423849
+ loading
423850
+ ]);
423851
+ const handleCancelDislike = (0,react.useCallback)(async ()=>{
423852
+ if (!commentApiService || !messageParams) {
423853
+ return;
423854
+ }
423855
+ setLoading(true);
423856
+ try {
423857
+ if (commentApiService.cancelComment) {
423858
+ await commentApiService.cancelComment({
423859
+ chat_id: messageParams.chatId,
423860
+ app_id: messageParams.appId,
423861
+ conversation_id: messageParams.conversationId
423862
+ });
423863
+ }
423864
+ setCurrentComment(null);
423865
+ } catch (error) {
423866
+ console.error('[Comment Message] Failed to cancel dislike comment:', error);
423867
+ // 发生错误时保持当前状态
423868
+ } finally{
423869
+ setLoading(false);
423870
+ }
423871
+ }, [
423872
+ commentApiService,
423873
+ messageParams
423874
+ ]);
423875
+ const handleDislike = (0,react.useCallback)(async ()=>{
423876
+ if (loading || !commentApiService || !messageParams) {
423877
+ return;
423878
+ }
423879
+ // 如果已经点踩,则取消点踩(再次点击)
423880
+ if (currentComment === 'DISLIKE') {
423881
+ await handleCancelDislike();
423882
+ return;
423883
+ }
423884
+ // 显示反馈对话框
423885
+ setShowFeedbackDialog(true);
423886
+ }, [
423887
+ commentApiService,
423888
+ messageParams,
423889
+ currentComment,
423890
+ loading,
423891
+ handleCancelDislike
423892
+ ]);
423893
+ const handleFeedbackConfirm = (0,react.useCallback)(async (feedbackType, comment)=>{
423894
+ if (loading || !commentApiService || !messageParams) {
423895
+ return;
423896
+ }
423897
+ setLoading(true);
423898
+ setShowFeedbackDialog(false);
423899
+ try {
423900
+ await commentApiService.createComment({
423901
+ chat_id: messageParams.chatId,
423902
+ app_id: messageParams.appId,
423903
+ conversation_id: messageParams.conversationId,
423904
+ name: 'DISLIKE',
423905
+ feedback_type: feedbackType,
423906
+ comment: comment || undefined
423907
+ });
423908
+ setCurrentComment('DISLIKE');
423909
+ } catch (error) {
423910
+ console.error('[Comment Message] Failed to create dislike comment:', error);
423911
+ setCurrentComment(null);
423912
+ } finally{
423913
+ setLoading(false);
423914
+ }
423915
+ }, [
423916
+ commentApiService,
423917
+ messageParams,
423918
+ loading
423919
+ ]);
423920
+ const handleFeedbackCancel = (0,react.useCallback)(()=>{
423921
+ setShowFeedbackDialog(false);
423922
+ }, []);
423923
+ const iconClassNames = classnames_default()(className, 'w-[14px] h-[14px]');
423924
+ const likeIconClassNames = classnames_default()(iconClassNames, {
423925
+ [components_comment_message_index_module["icon-selected"]]: currentComment === 'LIKE'
423926
+ });
423927
+ const dislikeIconClassNames = classnames_default()(iconClassNames, {
423928
+ [components_comment_message_index_module["icon-selected"]]: currentComment === 'DISLIKE'
423929
+ });
423930
+ // 如果没有提供 API 服务,则不显示评论按钮
423931
+ if (!commentApiService || !extractMessageParams) {
423932
+ return null;
423933
+ }
423934
+ // 只在最终答案消息时显示
423935
+ if (!meta.isGroupLastAnswerMessage && isMustGroupLastAnswerMessage) {
423936
+ return null;
423937
+ }
423938
+ // 如果无法提取消息参数,则不显示
423939
+ if (!messageParams) {
423940
+ return null;
423941
+ }
423942
+ return /*#__PURE__*/ (0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
423943
+ children: [
423944
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(FeedbackDialog, {
423945
+ visible: showFeedbackDialog,
423946
+ onConfirm: handleFeedbackConfirm,
423947
+ onCancel: handleFeedbackCancel,
423948
+ feedbackTypes: (enumsData === null || enumsData === void 0 ? void 0 : (_enumsData_feedback_types = enumsData.feedback_types) === null || _enumsData_feedback_types === void 0 ? void 0 : _enumsData_feedback_types.DISLIKE) || undefined
423949
+ }),
423950
+ /*#__PURE__*/ (0,jsx_runtime.jsxs)("div", {
423951
+ className: components_comment_message_index_module.container,
423952
+ children: [
423953
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423954
+ content: getLikeLabel(enumsData, currentComment),
423955
+ trigger: trigger,
423956
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423957
+ "data-testid": "chat-area.answer-action.comment-like-button",
423958
+ size: "small",
423959
+ icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbsup, {
423960
+ className: likeIconClassNames
423961
+ }),
423962
+ color: "secondary",
423963
+ className: classnames_default()({
423964
+ [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'LIKE'
423965
+ }),
423966
+ onClick: handleLike,
423967
+ disabled: loading,
423968
+ ...props
423969
+ })
423970
+ }),
423971
+ /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_Tooltip, {
423972
+ content: getDislikeLabel(enumsData, currentComment),
423973
+ trigger: trigger,
423974
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(esm_webpack_exports_IconButton, {
423975
+ "data-testid": "chat-area.answer-action.comment-dislike-button",
423976
+ size: "small",
423977
+ icon: /*#__PURE__*/ (0,jsx_runtime.jsx)(__webpack_exports__IconCozThumbdown, {
423978
+ className: dislikeIconClassNames
423979
+ }),
423980
+ color: "secondary",
423981
+ className: classnames_default()({
423982
+ [components_comment_message_index_module["icon-button-selected"]]: currentComment === 'DISLIKE'
423983
+ }),
423984
+ onClick: handleDislike,
423985
+ disabled: loading,
423986
+ ...props
423987
+ })
423988
+ })
423989
+ ]
423990
+ })
423991
+ ]
423992
+ });
423993
+ };
423994
+
422958
423995
  ;// CONCATENATED MODULE: ../../../common/chat-area/chat-answer-action/src/context/store/context.tsx
422959
423996
  /*
422960
423997
  * Copyright 2025 coze-dev Authors
@@ -423385,6 +424422,8 @@ const BotTriggerConfigButtonGroup = (param)=>{
423385
424422
 
423386
424423
 
423387
424424
 
424425
+
424426
+
423388
424427
 
423389
424428
 
423390
424429
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/plugin/hooks/use-cur-message-info.ts
@@ -423778,6 +424817,9 @@ const ChatMessageFooterContent = ()=>{
423778
424817
  isUseExternalContent: true,
423779
424818
  externalContent: lastMessageText
423780
424819
  }, "copy"),
424820
+ !!lastMessageText && /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentMessage, {
424821
+ className: buttonClass
424822
+ }, "comment"),
423781
424823
  isShowDelete && /*#__PURE__*/ (0,jsx_runtime.jsx)(delete_message_DeleteMessage, {
423782
424824
  className: classnames_default()(buttonClass)
423783
424825
  }, "delete"),
@@ -424301,6 +425343,154 @@ const useBgBackgroundPlugin = ()=>{
424301
425343
  };
424302
425344
  };
424303
425345
 
425346
+ ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/comment-provider.tsx
425347
+ /*
425348
+ * Copyright 2025 coze-dev Authors
425349
+ *
425350
+ * Licensed under the Apache License, Version 2.0 (the "License");
425351
+ * you may not use this file except in compliance with the License.
425352
+ * You may obtain a copy of the License at
425353
+ *
425354
+ * http://www.apache.org/licenses/LICENSE-2.0
425355
+ *
425356
+ * Unless required by applicable law or agreed to in writing, software
425357
+ * distributed under the License is distributed on an "AS IS" BASIS,
425358
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
425359
+ * See the License for the specific language governing permissions and
425360
+ * limitations under the License.
425361
+ */
425362
+
425363
+
425364
+
425365
+
425366
+
425367
+
425368
+ /**
425369
+ * 从消息对象中提取评论所需的参数
425370
+ */ function extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext) {
425371
+ var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _chatConfig_appInfo;
425372
+ if (!message || typeof message !== 'object') {
425373
+ return null;
425374
+ }
425375
+ const msg = message;
425376
+ // 从 extra_info 中提取
425377
+ const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
425378
+ // conversationId 可以从多个地方获取(按优先级):
425379
+ // 1. conversationIdFromContext (从 chat area context 获取,最优先)
425380
+ // 2. extra_info.conversation_id
425381
+ // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
425382
+ // 4. reply_id (最后的 fallback)
425383
+ const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
425384
+ // 从 chatConfig 中获取 app_id
425385
+ const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || (chatConfig === null || chatConfig === void 0 ? void 0 : (_chatConfig_appInfo = chatConfig.appInfo) === null || _chatConfig_appInfo === void 0 ? void 0 : _chatConfig_appInfo.appId) || (chatConfig === null || chatConfig === void 0 ? void 0 : chatConfig.bot_id) || '';
425386
+ if (!chatId || !conversationId || !appId) {
425387
+ return null;
425388
+ }
425389
+ return {
425390
+ chatId: String(chatId),
425391
+ conversationId: String(conversationId),
425392
+ appId: String(appId)
425393
+ };
425394
+ }
425395
+ /**
425396
+ * 使用 fetch 直接调用评论 API(绕过 CozeAPI 的响应拦截器)
425397
+ */ async function requestCommentApi(config, endpoint) {
425398
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
425399
+ const url = `${config.apiUrl}${endpoint}`;
425400
+ const response = await fetch(url, {
425401
+ ...options,
425402
+ headers: {
425403
+ 'Content-Type': 'application/json',
425404
+ Authorization: `Bearer ${config.token}`,
425405
+ ...options.headers
425406
+ }
425407
+ });
425408
+ const data = await response.json();
425409
+ if (!response.ok) {
425410
+ const error = data;
425411
+ throw new Error(error.message || `HTTP error! status: ${response.status}`);
425412
+ }
425413
+ return data;
425414
+ }
425415
+ /**
425416
+ * 创建评论
425417
+ */ async function createCommentWithFetch(apiUrl, token, params) {
425418
+ return requestCommentApi({
425419
+ apiUrl,
425420
+ token
425421
+ }, '/api/workflow_api/comment/create', {
425422
+ method: 'POST',
425423
+ body: JSON.stringify(params)
425424
+ });
425425
+ }
425426
+ /**
425427
+ * 查询评论列表
425428
+ */ async function getCommentsByChatIDWithFetch(apiUrl, token, params) {
425429
+ return requestCommentApi({
425430
+ apiUrl,
425431
+ token
425432
+ }, '/api/workflow_api/comment/list', {
425433
+ method: 'POST',
425434
+ body: JSON.stringify(params)
425435
+ });
425436
+ }
425437
+ /**
425438
+ * 获取评论枚举值
425439
+ */ async function getCommentEnumsWithFetch(apiUrl, token) {
425440
+ return requestCommentApi({
425441
+ apiUrl,
425442
+ token
425443
+ }, '/api/workflow_api/comment/enums', {
425444
+ method: 'GET'
425445
+ });
425446
+ }
425447
+ /**
425448
+ * 取消评论
425449
+ */ async function cancelCommentWithFetch(apiUrl, token, params) {
425450
+ return requestCommentApi({
425451
+ apiUrl,
425452
+ token
425453
+ }, '/api/workflow_api/comment/cancel', {
425454
+ method: 'POST',
425455
+ body: JSON.stringify(params)
425456
+ });
425457
+ }
425458
+ /**
425459
+ * 为 BuilderChat 提供评论功能的 Provider
425460
+ */ const BuilderChatCommentProvider = (param)=>{
425461
+ let { children } = param;
425462
+ const { chatConfig } = context_useChatAppProps();
425463
+ const { token, apiUrl } = context_useChatAppStore(shallow_useShallow((s)=>({
425464
+ token: s.token,
425465
+ apiUrl: s.apiUrl
425466
+ })));
425467
+ const { useGlobalInitStore } = use_chat_area_context_useChatAreaStoreSet();
425468
+ const conversationIdFromStore = useGlobalInitStore((state)=>state.conversationId);
425469
+ const commentContextValue = (0,react.useMemo)(()=>{
425470
+ if (!token || !apiUrl) {
425471
+ return {};
425472
+ }
425473
+ return {
425474
+ commentApiService: {
425475
+ createComment: async (params)=>createCommentWithFetch(apiUrl, token, params),
425476
+ getCommentsByChatID: async (params)=>getCommentsByChatIDWithFetch(apiUrl, token, params),
425477
+ getCommentEnums: async ()=>getCommentEnumsWithFetch(apiUrl, token),
425478
+ cancelComment: async (params)=>cancelCommentWithFetch(apiUrl, token, params)
425479
+ },
425480
+ extractMessageParams: (message, conversationIdFromContext)=>extractMessageParamsForBuilderChat(message, chatConfig, conversationIdFromContext || conversationIdFromStore || undefined)
425481
+ };
425482
+ }, [
425483
+ token,
425484
+ apiUrl,
425485
+ chatConfig,
425486
+ conversationIdFromStore
425487
+ ]);
425488
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
425489
+ value: commentContextValue,
425490
+ children: children
425491
+ });
425492
+ };
425493
+
424304
425494
  ;// CONCATENATED MODULE: ../open-chat/src/components/studio-open-chat/provider/coz-sdk/chat-provider.tsx
424305
425495
  /*
424306
425496
  * Copyright 2025 coze-dev Authors
@@ -424340,6 +425530,7 @@ const useBgBackgroundPlugin = ()=>{
424340
425530
 
424341
425531
 
424342
425532
 
425533
+
424343
425534
 
424344
425535
 
424345
425536
  const ChatProviderFuncComp = /*#__PURE__*/ (0,react.forwardRef)((param, ref)=>{
@@ -424647,9 +425838,11 @@ const ChatProviderImpl = (param)=>{
424647
425838
  ],
424648
425839
  showBackground: isShowBackground,
424649
425840
  enableDragUpload: false,
424650
- children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
424651
- ref: refChatFunc,
424652
- children: children
425841
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChatCommentProvider, {
425842
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(ChatProviderFuncComp, {
425843
+ ref: refChatFunc,
425844
+ children: children
425845
+ })
424653
425846
  })
424654
425847
  });
424655
425848
  };
@@ -439198,6 +440391,169 @@ const BuilderChatWeb = /*#__PURE__*/ (0,react.forwardRef)((props, ref)=>{
439198
440391
 
439199
440392
  const BuilderChat = BuilderChatWeb;
439200
440393
 
440394
+ ;// CONCATENATED MODULE: ./src/util/extract-message-params.ts
440395
+ /*
440396
+ * Copyright 2025 coze-dev Authors
440397
+ *
440398
+ * Licensed under the Apache License, Version 2.0 (the "License");
440399
+ * you may not use this file except in compliance with the License.
440400
+ * You may obtain a copy of the License at
440401
+ *
440402
+ * http://www.apache.org/licenses/LICENSE-2.0
440403
+ *
440404
+ * Unless required by applicable law or agreed to in writing, software
440405
+ * distributed under the License is distributed on an "AS IS" BASIS,
440406
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440407
+ * See the License for the specific language governing permissions and
440408
+ * limitations under the License.
440409
+ */ /**
440410
+ * 从消息对象中提取评论所需的参数
440411
+ */ /* eslint-disable complexity -- 需要处理多个可选字段的提取逻辑 */ function extract_message_params_extractMessageParams(message, client, conversationIdFromContext) {
440412
+ var _msg_extra_info, _msg_extra_info1, _msg_extra_info2, _msg_extra_info3, _msg_extra_info4, _client_options_config_appInfo, _client_options_config, _client_options, _client_options_config1, _client_options1;
440413
+ if (!message || typeof message !== 'object') {
440414
+ return null;
440415
+ }
440416
+ const msg = message;
440417
+ // 从 extra_info 中提取
440418
+ const chatId = ((_msg_extra_info = msg.extra_info) === null || _msg_extra_info === void 0 ? void 0 : _msg_extra_info.chat_id) || ((_msg_extra_info1 = msg.extra_info) === null || _msg_extra_info1 === void 0 ? void 0 : _msg_extra_info1.coze_api_chat_id) || ((_msg_extra_info2 = msg.extra_info) === null || _msg_extra_info2 === void 0 ? void 0 : _msg_extra_info2.conversation_id) || msg.message_id || msg.reply_id;
440419
+ // conversationId 可以从多个地方获取(按优先级):
440420
+ // 1. conversationIdFromContext (从 chat area context 获取,最优先)
440421
+ // 2. extra_info.conversation_id
440422
+ // 3. section_id (作为 fallback,但通常 section_id 不等于 conversation_id)
440423
+ // 4. reply_id (最后的 fallback)
440424
+ const conversationId = conversationIdFromContext || ((_msg_extra_info3 = msg.extra_info) === null || _msg_extra_info3 === void 0 ? void 0 : _msg_extra_info3.conversation_id) || msg.section_id || msg.reply_id;
440425
+ // 从 client options 中获取 app_id
440426
+ const appId = ((_msg_extra_info4 = msg.extra_info) === null || _msg_extra_info4 === void 0 ? void 0 : _msg_extra_info4.app_id) || ((_client_options = client.options) === null || _client_options === void 0 ? void 0 : (_client_options_config = _client_options.config) === null || _client_options_config === void 0 ? void 0 : (_client_options_config_appInfo = _client_options_config.appInfo) === null || _client_options_config_appInfo === void 0 ? void 0 : _client_options_config_appInfo.appId) || ((_client_options1 = client.options) === null || _client_options1 === void 0 ? void 0 : (_client_options_config1 = _client_options1.config) === null || _client_options_config1 === void 0 ? void 0 : _client_options_config1.botId) || '';
440427
+ if (!chatId || !conversationId || !appId) {
440428
+ return null;
440429
+ }
440430
+ return {
440431
+ chatId: String(chatId),
440432
+ conversationId: String(conversationId),
440433
+ appId: String(appId)
440434
+ };
440435
+ }
440436
+
440437
+ ;// CONCATENATED MODULE: ./src/services/comment-api.ts
440438
+ /*
440439
+ * Copyright 2025 coze-dev Authors
440440
+ *
440441
+ * Licensed under the Apache License, Version 2.0 (the "License");
440442
+ * you may not use this file except in compliance with the License.
440443
+ * You may obtain a copy of the License at
440444
+ *
440445
+ * http://www.apache.org/licenses/LICENSE-2.0
440446
+ *
440447
+ * Unless required by applicable law or agreed to in writing, software
440448
+ * distributed under the License is distributed on an "AS IS" BASIS,
440449
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440450
+ * See the License for the specific language governing permissions and
440451
+ * limitations under the License.
440452
+ */
440453
+ /**
440454
+ * 获取认证 token
440455
+ */ async function comment_api_getAuthToken(client) {
440456
+ try {
440457
+ var _client_authClient_options_auth_onRefreshToken, _client_authClient_options_auth;
440458
+ const token = await ((_client_authClient_options_auth = client.authClient.options.auth) === null || _client_authClient_options_auth === void 0 ? void 0 : (_client_authClient_options_auth_onRefreshToken = _client_authClient_options_auth.onRefreshToken) === null || _client_authClient_options_auth_onRefreshToken === void 0 ? void 0 : _client_authClient_options_auth_onRefreshToken.call(_client_authClient_options_auth, ''));
440459
+ return token || null;
440460
+ } catch (error) {
440461
+ console.error('[Comment API] Failed to get auth token:', error);
440462
+ return null;
440463
+ }
440464
+ }
440465
+ /**
440466
+ * 发起 API 请求
440467
+ */ async function comment_api_request(client, endpoint) {
440468
+ let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
440469
+ const token = await comment_api_getAuthToken(client);
440470
+ if (!token) {
440471
+ throw new Error('Authentication token is required');
440472
+ }
440473
+ const url = `${client.apiUrl}${endpoint}`;
440474
+ const response = await fetch(url, {
440475
+ ...options,
440476
+ headers: {
440477
+ 'Content-Type': 'application/json',
440478
+ Authorization: `Bearer ${token}`,
440479
+ ...options.headers
440480
+ }
440481
+ });
440482
+ const data = await response.json();
440483
+ if (!response.ok) {
440484
+ const error = data;
440485
+ throw new Error(error.message || `HTTP error! status: ${response.status}`);
440486
+ }
440487
+ return data;
440488
+ }
440489
+ /**
440490
+ * 创建评论(点赞/点踩)
440491
+ */ async function createComment(client, params) {
440492
+ return comment_api_request(client, '/api/workflow_api/comment/create', {
440493
+ method: 'POST',
440494
+ body: JSON.stringify(params)
440495
+ });
440496
+ }
440497
+ /**
440498
+ * 查询评论列表(支持单个或批量chat_id)
440499
+ */ async function getCommentsByChatID(client, params) {
440500
+ return comment_api_request(client, '/api/workflow_api/comment/list', {
440501
+ method: 'POST',
440502
+ body: JSON.stringify(params)
440503
+ });
440504
+ }
440505
+ /**
440506
+ * 获取评论相关枚举值
440507
+ */ async function getCommentEnums(client) {
440508
+ return comment_api_request(client, '/api/workflow_api/comment/enums', {
440509
+ method: 'GET'
440510
+ });
440511
+ }
440512
+ /**
440513
+ * 取消评论(取消点赞/点踩)
440514
+ */ async function cancelComment(client, params) {
440515
+ return comment_api_request(client, '/api/workflow_api/comment/cancel', {
440516
+ method: 'POST',
440517
+ body: JSON.stringify(params)
440518
+ });
440519
+ }
440520
+
440521
+ ;// CONCATENATED MODULE: ./src/components/comment/comment-provider.tsx
440522
+ /*
440523
+ * Copyright 2025 coze-dev Authors
440524
+ *
440525
+ * Licensed under the Apache License, Version 2.0 (the "License");
440526
+ * you may not use this file except in compliance with the License.
440527
+ * You may obtain a copy of the License at
440528
+ *
440529
+ * http://www.apache.org/licenses/LICENSE-2.0
440530
+ *
440531
+ * Unless required by applicable law or agreed to in writing, software
440532
+ * distributed under the License is distributed on an "AS IS" BASIS,
440533
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
440534
+ * See the License for the specific language governing permissions and
440535
+ * limitations under the License.
440536
+ */
440537
+
440538
+
440539
+
440540
+ const CommentProviderWrapper = (param)=>{
440541
+ let { client, children } = param;
440542
+ const commentContextValue = {
440543
+ commentApiService: {
440544
+ createComment: async (params)=>createComment(client, params),
440545
+ getCommentsByChatID: async (params)=>getCommentsByChatID(client, params),
440546
+ getCommentEnums: async ()=>getCommentEnums(client),
440547
+ cancelComment: async (params)=>cancelComment(client, params)
440548
+ },
440549
+ extractMessageParams: (message, conversationIdFromContext)=>extract_message_params_extractMessageParams(message, client, conversationIdFromContext)
440550
+ };
440551
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProvider, {
440552
+ value: commentContextValue,
440553
+ children: children
440554
+ });
440555
+ };
440556
+
439201
440557
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!./src/components/widget/non-iframe-app/index.module.less
439202
440558
  var non_iframe_app_index_module = __webpack_require__(81562);
439203
440559
  ;// CONCATENATED MODULE: ./src/components/widget/non-iframe-app/index.module.less
@@ -439248,6 +440604,7 @@ var non_iframe_app_index_module_update = injectStylesIntoStyleTag_default()(non_
439248
440604
 
439249
440605
 
439250
440606
 
440607
+
439251
440608
  const NonIframeApp = (param)=>{
439252
440609
  let { client, onImageClick, uiKitCustomComponents, contentBox } = param;
439253
440610
  var _options_ui_header, _options_ui, _options_ui_chatBot, _options_ui1, _options_ui_chatBot1, _options_ui2, _options_ui_chatBot2, _options_ui3, _options_ui_chatBot3, _options_ui4, _options_ui_chatBot4, _options_ui5, _options_ui_chatBot5, _options_ui6, _options_ui_chatBot6, _options_ui7, _options_ui_header1, _options_ui8, _options_ui_base, _options_ui9, _options_ui10, _options_ui11, _options_ui_chatBot7, _options_ui12, _options_ui_input, _options_ui13, _options_ui_input1, _options_ui14, _options_ui_input2, _options_ui15, _options_ui_input3, _options_ui16, _options_ui_input4, _options_ui17, _options_ui_input5, _options_ui18, _options_ui19, _options_ui20, _options_ui21, _options_config_appInfo, _options_config, _options_config_appInfo1, _options_config1, _options_config_appInfo2, _options_config2, _options_config_appInfo3, _options_config3, _options_config_appInfo4, _options_config4, _options_ui_base1, _options_ui22, _options_config_appInfo5, _options_userInfo, _options_userInfo1, _options_userInfo2, _options_auth, _options_auth1;
@@ -439289,41 +440646,44 @@ const NonIframeApp = (param)=>{
439289
440646
  onboarding: options === null || options === void 0 ? void 0 : (_options_ui20 = options.ui) === null || _options_ui20 === void 0 ? void 0 : _options_ui20.onboarding,
439290
440647
  getMessageRenderIndex: options === null || options === void 0 ? void 0 : (_options_ui21 = options.ui) === null || _options_ui21 === void 0 ? void 0 : _options_ui21.getMessageRenderIndex
439291
440648
  };
439292
- return /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
439293
- // 传递 apiUrl(需要在 BuilderChat props 中支持)
439294
- apiUrl: apiUrl,
439295
- workflow: {
439296
- id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
439297
- // 直接传递引用,不创建副本,这样参数更新会立即生效
439298
- parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
439299
- },
439300
- project: {
439301
- type: 'app',
439302
- // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
439303
- // 如果没有设置 draft_mode,则根据环境判断
439304
- mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
439305
- id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
439306
- conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
439307
- layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
439308
- version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
439309
- },
439310
- userInfo: {
439311
- url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
439312
- nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
439313
- id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
439314
- },
439315
- areaUi: areaUi,
439316
- auth: {
439317
- type: 'external',
439318
- token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
439319
- refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
439320
- },
439321
- eventCallbacks: {
439322
- onImageClick,
439323
- onThemeChange: setThemeType
439324
- },
439325
- uiKitCustomComponents: uiKitCustomComponents,
439326
- contentBox: contentBox
440649
+ return /*#__PURE__*/ (0,jsx_runtime.jsx)(CommentProviderWrapper, {
440650
+ client: client,
440651
+ children: /*#__PURE__*/ (0,jsx_runtime.jsx)(BuilderChat, {
440652
+ // 传递 apiUrl(需要在 BuilderChat props 中支持)
440653
+ apiUrl: apiUrl,
440654
+ workflow: {
440655
+ id: options === null || options === void 0 ? void 0 : (_options_config = options.config) === null || _options_config === void 0 ? void 0 : (_options_config_appInfo = _options_config.appInfo) === null || _options_config_appInfo === void 0 ? void 0 : _options_config_appInfo.workflowId,
440656
+ // 直接传递引用,不创建副本,这样参数更新会立即生效
440657
+ parameters: (options === null || options === void 0 ? void 0 : (_options_config1 = options.config) === null || _options_config1 === void 0 ? void 0 : (_options_config_appInfo1 = _options_config1.appInfo) === null || _options_config_appInfo1 === void 0 ? void 0 : _options_config_appInfo1.parameters) || {}
440658
+ },
440659
+ project: {
440660
+ type: 'app',
440661
+ // 根据 appInfo.draft_mode 设置 mode:draft_mode: true -> 'draft', draft_mode: false -> 'websdk'
440662
+ // 如果没有设置 draft_mode,则根据环境判断
440663
+ mode: (options === null || options === void 0 ? void 0 : (_options_config2 = options.config) === null || _options_config2 === void 0 ? void 0 : (_options_config_appInfo2 = _options_config2.appInfo) === null || _options_config_appInfo2 === void 0 ? void 0 : _options_config_appInfo2.draft_mode) !== undefined ? options.config.appInfo.draft_mode ? 'draft' : 'websdk' : false ? 0 : 'websdk',
440664
+ id: (options === null || options === void 0 ? void 0 : (_options_config3 = options.config) === null || _options_config3 === void 0 ? void 0 : (_options_config_appInfo3 = _options_config3.appInfo) === null || _options_config_appInfo3 === void 0 ? void 0 : _options_config_appInfo3.appId) || '',
440665
+ conversationName: options === null || options === void 0 ? void 0 : (_options_config4 = options.config) === null || _options_config4 === void 0 ? void 0 : (_options_config_appInfo4 = _options_config4.appInfo) === null || _options_config_appInfo4 === void 0 ? void 0 : _options_config_appInfo4.conversationName,
440666
+ layout: options === null || options === void 0 ? void 0 : (_options_ui22 = options.ui) === null || _options_ui22 === void 0 ? void 0 : (_options_ui_base1 = _options_ui22.base) === null || _options_ui_base1 === void 0 ? void 0 : _options_ui_base1.layout,
440667
+ version: options === null || options === void 0 ? void 0 : (_options_config_appInfo5 = options.config.appInfo) === null || _options_config_appInfo5 === void 0 ? void 0 : _options_config_appInfo5.version
440668
+ },
440669
+ userInfo: {
440670
+ url: (options === null || options === void 0 ? void 0 : (_options_userInfo = options.userInfo) === null || _options_userInfo === void 0 ? void 0 : _options_userInfo.url) || '',
440671
+ nickname: (options === null || options === void 0 ? void 0 : (_options_userInfo1 = options.userInfo) === null || _options_userInfo1 === void 0 ? void 0 : _options_userInfo1.nickname) || '',
440672
+ id: (options === null || options === void 0 ? void 0 : (_options_userInfo2 = options.userInfo) === null || _options_userInfo2 === void 0 ? void 0 : _options_userInfo2.id) || ''
440673
+ },
440674
+ areaUi: areaUi,
440675
+ auth: {
440676
+ type: 'external',
440677
+ token: options === null || options === void 0 ? void 0 : (_options_auth = options.auth) === null || _options_auth === void 0 ? void 0 : _options_auth.token,
440678
+ refreshToken: options === null || options === void 0 ? void 0 : (_options_auth1 = options.auth) === null || _options_auth1 === void 0 ? void 0 : _options_auth1.onRefreshToken
440679
+ },
440680
+ eventCallbacks: {
440681
+ onImageClick,
440682
+ onThemeChange: setThemeType
440683
+ },
440684
+ uiKitCustomComponents: uiKitCustomComponents,
440685
+ contentBox: contentBox
440686
+ })
439327
440687
  });
439328
440688
  };
439329
440689
 
@@ -439683,227 +441043,6 @@ const CozeClientWidget = (props)=>/*#__PURE__*/ (0,jsx_runtime.jsx)(GlobalStoreP
439683
441043
  });
439684
441044
  /* ESM default export */ const widget = (CozeClientWidget);
439685
441045
 
439686
- ;// CONCATENATED MODULE: ./src/util/webcomponent-adapter.tsx
439687
- /*
439688
- * Copyright 2025 coze-dev Authors
439689
- *
439690
- * Licensed under the Apache License, Version 2.0 (the "License");
439691
- * you may not use this file except in compliance with the License.
439692
- * You may obtain a copy of the License at
439693
- *
439694
- * http://www.apache.org/licenses/LICENSE-2.0
439695
- *
439696
- * Unless required by applicable law or agreed to in writing, software
439697
- * distributed under the License is distributed on an "AS IS" BASIS,
439698
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
439699
- * See the License for the specific language governing permissions and
439700
- * limitations under the License.
439701
- */
439702
-
439703
- /**
439704
- * 组件包装器缓存
439705
- * 改进:避免重复创建相同 tagName 的包装器组件
439706
- */ const wrapperCache = new Map();
439707
- /**
439708
- * 将对象转换为 Web Component 的属性
439709
- * 改进:处理 null、undefined、数组等特殊情况,添加错误处理
439710
- */ function setWebComponentProps(element, props) {
439711
- Object.entries(props).forEach((param)=>{
439712
- let [key, value] = param;
439713
- try {
439714
- // 跳过 undefined
439715
- if (value === undefined) {
439716
- return;
439717
- }
439718
- // null 设置为空字符串
439719
- if (value === null) {
439720
- element.setAttribute(key, '');
439721
- return;
439722
- }
439723
- // 复杂对象(包括数组)设置为属性
439724
- if (typeof value === 'object' || Array.isArray(value)) {
439725
- element[key] = value;
439726
- } else if (typeof value === 'function') {
439727
- // 函数类型设置为属性(事件处理器等)
439728
- element[key] = value;
439729
- } else {
439730
- // 基本类型设置为 attribute
439731
- element.setAttribute(key, String(value));
439732
- }
439733
- } catch (error) {
439734
- console.warn(`[WebComponent] Failed to set property "${key}" on ${element.tagName}:`, error);
439735
- }
439736
- });
439737
- }
439738
- /**
439739
- * 创建一个 React 组件包装器,用于渲染 Web Component
439740
- * 改进:
439741
- * 1. 使用 React.memo 避免不必要的重渲染
439742
- * 2. 优化 props 比较,避免无限循环
439743
- * 3. 添加清理逻辑,防止内存泄漏
439744
- * 4. 添加缓存机制,提升性能
439745
- */ function createWebComponentWrapper(tagName) {
439746
- // 检查缓存
439747
- const cachedWrapper = wrapperCache.get(tagName);
439748
- if (cachedWrapper) {
439749
- return cachedWrapper;
439750
- }
439751
- const WrapperComponent = /*#__PURE__*/ react.memo((props)=>{
439752
- const elementRef = (0,react.useRef)(null);
439753
- const propsRef = (0,react.useRef)(props);
439754
- const cleanupRef = (0,react.useRef)(null);
439755
- const isInitialMountRef = (0,react.useRef)(true);
439756
- // 使用 useMemo 进行深度比较,避免每次都触发更新
439757
- const propsChanged = (0,react.useMemo)(()=>{
439758
- try {
439759
- return JSON.stringify(propsRef.current) !== JSON.stringify(props);
439760
- } catch (error) {
439761
- // JSON.stringify 可能失败(循环引用等),降级为浅比较
439762
- console.warn('[WebComponent] Failed to compare props:', error);
439763
- return propsRef.current !== props;
439764
- }
439765
- }, [
439766
- props
439767
- ]);
439768
- (0,react.useEffect)(()=>{
439769
- // 首次挂载或 props 变化时,都需要调用 updateProps
439770
- const shouldUpdate = isInitialMountRef.current || propsChanged && elementRef.current;
439771
- if (shouldUpdate && elementRef.current) {
439772
- if (isInitialMountRef.current) {
439773
- isInitialMountRef.current = false;
439774
- }
439775
- propsRef.current = props;
439776
- // 设置属性
439777
- setWebComponentProps(elementRef.current, props);
439778
- // 如果 Web Component 定义了更新方法,调用它
439779
- const customElement = elementRef.current;
439780
- if (typeof customElement.updateProps === 'function') {
439781
- try {
439782
- customElement.updateProps(props);
439783
- } catch (error) {
439784
- console.error(`[WebComponent] Error calling updateProps on ${tagName}:`, error);
439785
- }
439786
- }
439787
- // 保存清理函数
439788
- if (typeof customElement.cleanup === 'function') {
439789
- cleanupRef.current = ()=>{
439790
- try {
439791
- var _customElement_cleanup;
439792
- (_customElement_cleanup = customElement.cleanup) === null || _customElement_cleanup === void 0 ? void 0 : _customElement_cleanup.call(customElement);
439793
- } catch (error) {
439794
- console.error(`[WebComponent] Error during cleanup of ${tagName}:`, error);
439795
- }
439796
- };
439797
- }
439798
- }
439799
- // 返回清理函数
439800
- return ()=>{
439801
- if (cleanupRef.current) {
439802
- cleanupRef.current();
439803
- cleanupRef.current = null;
439804
- }
439805
- };
439806
- // tagName 是外部作用域的值,不需要作为依赖项
439807
- }, [
439808
- propsChanged,
439809
- props
439810
- ]);
439811
- // 使用 React.createElement 创建自定义元素
439812
- return /*#__PURE__*/ react.createElement(tagName, {
439813
- ref: elementRef
439814
- });
439815
- }, // 自定义比较函数,使用深度比较
439816
- (prevProps, nextProps)=>{
439817
- try {
439818
- return JSON.stringify(prevProps) === JSON.stringify(nextProps);
439819
- } catch (error) {
439820
- // JSON.stringify 可能失败(循环引用等),降级为浅比较
439821
- console.warn('[WebComponent] Failed to compare props in memo:', error);
439822
- return prevProps === nextProps;
439823
- }
439824
- });
439825
- // 缓存组件(类型安全的 cast)
439826
- wrapperCache.set(tagName, WrapperComponent);
439827
- return WrapperComponent;
439828
- }
439829
- /**
439830
- * 支持的 UIKit 组件类型
439831
- * 改进:使用常量定义,便于扩展和维护
439832
- * 与 UIKitCustomComponentsMap 保持对齐
439833
- */ const SUPPORTED_COMPONENTS = [
439834
- 'JsonItem',
439835
- 'MentionOperateTool',
439836
- 'SendButton',
439837
- 'AvatarWrap'
439838
- ];
439839
- /**
439840
- * 将 Web Component 配置转换为 React 组件映射
439841
- * 改进:
439842
- * 1. 使用循环处理,避免重复代码
439843
- * 2. 添加错误处理
439844
- * 3. 返回类型更明确
439845
- */ function adaptWebComponentsToReact(webComponents) {
439846
- if (!webComponents) {
439847
- return undefined;
439848
- }
439849
- try {
439850
- const reactComponents = {};
439851
- // 动态处理所有支持的组件
439852
- SUPPORTED_COMPONENTS.forEach((componentName)=>{
439853
- const tagName = webComponents[componentName];
439854
- if (tagName) {
439855
- // 验证 Web Component 是否已注册
439856
- if (!customElements.get(tagName)) {
439857
- console.warn(`[WebChatClient] Web Component "${tagName}" for ${componentName} is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
439858
- }
439859
- // 创建包装器组件
439860
- // 使用类型断言,因为每个组件的 props 类型不同
439861
- reactComponents[componentName] = createWebComponentWrapper(tagName);
439862
- }
439863
- });
439864
- return Object.keys(reactComponents).length > 0 ? reactComponents : undefined;
439865
- } catch (error) {
439866
- console.error('[WebChatClient] Failed to adapt Web Components:', error);
439867
- return undefined;
439868
- }
439869
- }
439870
- /**
439871
- * 适配 contentBox Web Component
439872
- * 改进:添加错误处理和类型安全
439873
- */ function adaptContentBoxWebComponent(tagName) {
439874
- if (!tagName) {
439875
- return undefined;
439876
- }
439877
- try {
439878
- // 验证 Web Component 是否已注册
439879
- if (!customElements.get(tagName)) {
439880
- console.warn(`[WebChatClient] Web Component "${tagName}" is not registered. ` + 'Please register it using customElements.define() before initializing the chat client.');
439881
- }
439882
- return createWebComponentWrapper(tagName);
439883
- } catch (error) {
439884
- console.error(`[WebChatClient] Failed to adapt contentBox Web Component "${tagName}":`, error);
439885
- return undefined;
439886
- }
439887
- }
439888
- /**
439889
- * 检查浏览器是否支持 Web Components
439890
- */ function checkWebComponentsSupport() {
439891
- const missing = [];
439892
- if (!window.customElements) {
439893
- missing.push('Custom Elements');
439894
- }
439895
- if (!('attachShadow' in Element.prototype)) {
439896
- missing.push('Shadow DOM');
439897
- }
439898
- if (!('content' in document.createElement('template'))) {
439899
- missing.push('HTML Templates');
439900
- }
439901
- return {
439902
- supported: missing.length === 0,
439903
- missing
439904
- };
439905
- }
439906
-
439907
441046
  // EXTERNAL MODULE: ../../../../../common/temp/default/node_modules/.pnpm/css-loader@6.11.0_@rspack+core@1.5.8_webpack@5.91.0/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].use[1]!../../../../../common/temp/default/node_modules/.pnpm/postcss-loader@7.3.4_postcss@8.5.6_typescript@5.8.2_webpack@5.91.0/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].use[2]!../../../../../common/temp/default/node_modules/.pnpm/less-loader@11.1.4_less@4.4.2_webpack@5.91.0/node_modules/less-loader/dist/cjs.js??ruleSet[1].rules[7].use[3]!../../../common/assets/style/index.less
439908
441047
  var assets_style = __webpack_require__(2092);
439909
441048
  ;// CONCATENATED MODULE: ../../../common/assets/style/index.less