devfab 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  ### 核心概念
44
44
 
45
- - **FileRequire**:AMD 模块加载器。实施侧用 `define` / `provideScript` 注册二开产物,宿主侧用 `require` / `injectScript` 加载使用。
45
+ - **FileRequire**:AMD 模块加载器。实施侧用 `provide` / `provideScript` 注册二开产物,宿主侧用 `inject` / `injectScript` 加载使用。
46
46
  - **扩展脚本(Extend.js)**:一段返回 `{ doAction(name, viewModel) }` 的脚本,加载后被宿主按约定触发(如 `doAction('init', vm)`),用来注入业务逻辑。
47
47
  - **自定义组件**:用 JSX 写的普通组件,整体注册成一个模块,宿主加载后按组件名渲染。
48
48
 
@@ -111,9 +111,8 @@ devfab/
111
111
  ├── src/
112
112
  │ ├── index.js # 入口:挂载 window.__devfab,暴露 define / require / utils
113
113
  │ └── FileRequire/ # 运行时模块加载器(二开核心)
114
- │ ├── file.js # FileRequire 类:define / provideScript / require / injectScript / loadModules
114
+ │ ├── file.js # FileRequire 类:provide / provideScript / inject / injectScript / loadModules
115
115
  │ ├── policy.js # 加载策略:清单登记、域名白名单、版本锁、sha256 校验
116
- │ ├── guard.js # 全局污染检测:加载前后 diff window
117
116
  │ ├── requirejs.js # 内嵌 RequireJS 2.3.2 + 本地 domain 适配层
118
117
  │ └── index.js # 导出并挂载 window.__devfab.FileRequire
119
118
  ├── example/
@@ -177,8 +176,8 @@ sequenceDiagram
177
176
  participant RS as RequireJS(内嵌)
178
177
  participant Ext as 扩展脚本 / 组件产物
179
178
 
180
- Note over Ext: 脚本内 window.__devfab.define([], factory)<br/>组件内 provideScript(components)
181
- Host->>FR: require(path, files, cb)<br/>或 injectScript([url], cb)
179
+ Note over Ext: 脚本内 window.__devfab.provide([], factory)<br/>组件内 provideScript(components)
180
+ Host->>FR: inject(path, files, cb)<br/>或 injectScript([url], cb)
182
181
  FR->>RS: 按 domain 拼接路径,动态注入 ⟨script⟩ 加载
183
182
  Ext-->>RS: define() 注册模块
184
183
  RS-->>FR: 返回模块内容 contents[]
@@ -198,41 +197,72 @@ sequenceDiagram
198
197
 
199
198
  | 全局对象 | 说明 |
200
199
  | --- | --- |
201
- | `window.devfab` | UMD 导出对象,含 `define` / `require` / `FileRequire` / `utils` / `debug` |
202
- | `window.__devfab` | 源码入口显式挂载的同一份能力(`Object.assign({}, window.__devfab, devfab)`) |
203
- | `window.__devfab.FileRequire` | `FileRequire` 类 |
204
- | `window.__devfab_requirejs` | 内嵌 RequireJS 的 `require` / `define`(含 domain 适配) |
200
+ | `window.__devfab` | **推荐入口**。源码显式挂载的门面:`provide` / `inject` / `provideScript` / `injectScript` / `FileRequire` / `utils` / `debug`(`define` / `require` 保留为兼容别名) |
201
+ | `window.devfab` | UMD 导出对象。门面在 `.default` 上,所以 `window.devfab.define` 是 `undefined` |
202
+ | `window.__devfab.FileRequire` | 加载器**单例**(全局唯一,没有 `.create()`) |
205
203
 
206
- > 扩展脚本里统一写 `window.__devfab.define(...)`。`window.devfab` 是 UMD 导出对象,
207
- > 只导出 `default`(`src/index.js` 没有具名导出),所以 `window.devfab.define` 是
208
- > `undefined` —— 两者**并不等价**,别照抄网上的写法。
204
+ > 扩展脚本里统一写 `window.__devfab.provide(...)` / `window.__devfab.inject(...)`。
205
+ > `window.devfab` 是 UMD 的命名空间,门面挂在 `.default` 上 —— 两者**并不等价**,别照抄网上的写法。
206
+ >
207
+ > 内嵌的 RequireJS **不再挂 `window.__devfab_requirejs`**:那个全局会被第二个 bundle 无条件覆盖,
208
+ > 导致两个 RequireJS context 并存、`define` 与 `require` 的注册表对不上。加载器只认内嵌那一份。
209
209
 
210
210
  ### 核心 API
211
211
 
212
- `FileRequire.create(args?)` 返回一个实例。`args` 同时接受两类配置:
212
+ **加载器是单例,没有 `create()`。** 原因很实际:清单、白名单、版本锁都是
213
+ **部署级**约定,一个页面只应有一套。以前每次 `create()` 都派生一份全新的 policy,
214
+ 宿主在实例 A 上配的清单,扩展脚本主链路(`_extend.js`)用的实例 B 完全不知道 —— 配了等于没配。
215
+
216
+ ```js
217
+ const fileRequire = window.__devfab.FileRequire
218
+
219
+ fileRequire.configure({
220
+ version: '2026.10.20', // 进 RequireJS urlArgs,换文件后不吃缓存
221
+ timeout: 8000, // 早于 RequireJS 的 waitSeconds 兜底
222
+ retry: 2, // 失败重试(重试前自动 undef)
223
+ manifest, // 构建期产出的清单,未登记模块直接 403
224
+ lockVersion: '1.0.0', // 版本锁,防止现场悄悄换包
225
+ })
226
+ ```
227
+
228
+ `configure(options)` 接受三类字段:
213
229
 
214
230
  | 分区 | 字段 | 说明 |
215
231
  | --- | --- | --- |
216
- | 底层加载器 | `define` / `require` / `undef` / `requireConfig` / `importer` | 覆盖默认加载器,默认取 `window.__devfab_requirejs` |
217
- | 加载策略 | `version` / `timeout` / `retry` / `strict` / `baseUrl` | 见下方「加载策略与合规」 |
232
+ | 加载策略 | `version` / `timeout` / `retry` / `baseUrl` | 见下方「加载策略与合规」 |
218
233
  | 合规 | `manifest` / `origins` / `lockVersion` / `verifyHash` / `fetch` | 见下方「加载策略与合规」 |
219
- | 污染检测 | `pollution` / `watch` / `maxPollution` / `target` | `pollution: false` 可关闭 |
234
+ | 调试 | `debug` | 等价于 `window.__devfab.debug = true` |
235
+
236
+ > **加载器不可替换。** AMD 通道固定走内嵌的 RequireJS 2.3.2,构造函数不再接受
237
+ > `define` / `require` / `undef` / `requireConfig` 覆盖。旧版允许覆盖,结果是
238
+ > 「宿主传了自己的 require,但 undef 仍取内嵌那份」,两套注册表混用且覆盖是静默的。
239
+ > 要换通道请用 `loadModules()`(ESM),不要替换加载器。
220
240
 
221
241
  | 方法 | 签名 | 作用 |
222
242
  | --- | --- | --- |
223
- | `define` | `define(deps, factory)` | 注册 AMD 模块(匿名,`deps` 为依赖数组) |
243
+ | `provide` | `provide(path, files, factory)` / `provide(deps, factory)` | 注册 AMD 模块(`deps` 数组即匿名模块) |
224
244
  | `provideScript` | `provideScript(objOrFn)` | 把对象 / 函数包装成无依赖匿名模块注册 |
225
- | `require` | `require(path, files, callback)` | 加载模块,`callback` 收到统一结果对象 |
226
- | `load` | `load(path, files, callback)` | 与 `require` 等价,名字用来标记「这一处走完整策略」 |
245
+ | `inject` | `inject(path, files, callback)` / `inject(deps, callback)` | 加载模块,`callback` 收到统一结果对象 |
246
+ | `load` | `load(path, files, callback)` | 与 `inject` 等价,名字用来标记「这一处走完整策略」 |
227
247
  | `injectScript` | `injectScript(pathOrFiles, callback)` | 加载脚本,对每个模块分别回调 `(content, index)` |
228
248
  | `loadModules` | `loadModules(pathOrFiles, callback?)` | **ESM 通道**:原生 `import()`,返回 Promise |
229
249
  | `configure` | `configure(options)` | 运行时改策略(切版本、换清单、调重试次数) |
230
250
  | `setVersion` | `setVersion(version)` | 设置二开包版本,写进 RequireJS 的 `urlArgs` |
231
251
  | `describe` | `describe()` | 输出当前策略摘要,宿主启动时打一行日志 |
232
252
 
253
+ > **实例状态只有 `__data` 一个属性**。加载器句柄、时钟、`options` / `policy`
254
+ > 全部归纳在 `FileRequire.__data` 下,`FileRequire.options` / `.policy` 这些直接挂在实例上的
255
+ > 字段已经没有了。业务代码**不要读写 `__data`**,它是内部结构、随时可能调整;要看配置就 `describe()`,
256
+ > 要改配置就 `configure(options)`。
257
+ >
258
+ > ```js
259
+ > console.log(window.__devfab.FileRequire) // → { __data: {...} },展开才看到内部
260
+ > console.log(window.__devfab.FileRequire.describe()) // → 干净的策略摘要
261
+ > ```
262
+
233
263
  ### 加载结果契约
234
264
 
235
- `require` / `load` / `injectScript` / `loadModules` 的回调拿到统一结构:
265
+ `inject` / `load` / `injectScript` / `loadModules` 的回调拿到统一结构:
236
266
 
237
267
  ```js
238
268
  {
@@ -240,7 +270,7 @@ sequenceDiagram
240
270
  message: '', // 失败原因
241
271
  data: [], // 加载到的模块内容数组
242
272
  error: null, // 失败时的原始错误对象
243
- warnings: [], // 全局污染告警(见下)
273
+ warnings: [], // 保留位,本轮起不再有任何来源写入(见下)
244
274
  }
245
275
  ```
246
276
 
@@ -264,8 +294,9 @@ sequenceDiagram
264
294
  ### 版本:让「换了文件」真的生效
265
295
 
266
296
  ```js
267
- const fileRequire = window.__devfab.FileRequire.create({ version: '2026.10.20' })
268
- // 或运行时切:fileRequire.setVersion('2026.10.21')
297
+ const fileRequire = window.__devfab.FileRequire
298
+ fileRequire.setVersion('2026.10.20')
299
+ // 等价写法:fileRequire.configure({ version: '2026.10.20' })
269
300
  ```
270
301
 
271
302
  版本会作为 `?v=` 交给 RequireJS 的 `urlArgs`,进而进入模块缓存键。
@@ -277,7 +308,7 @@ const fileRequire = window.__devfab.FileRequire.create({ version: '2026.10.20' }
277
308
  ### 失败兜底:超时 + 重试
278
309
 
279
310
  ```js
280
- const fileRequire = window.__devfab.FileRequire.create({ timeout: 8000, retry: 2 })
311
+ window.__devfab.FileRequire.configure({ timeout: 8000, retry: 2 })
281
312
  ```
282
313
 
283
314
  - 超时先于 RequireJS 的 `waitSeconds`(默认 30s)触发,回 `code: 504`;
@@ -292,7 +323,7 @@ const fileRequire = window.__devfab.FileRequire.create({ timeout: 8000, retry: 2
292
323
  // node scripts/manifest.js example/vue3/static --name frontend-extends --version 1.0.0
293
324
 
294
325
  // 2) 运行时加载清单并启用检查
295
- const fileRequire = window.__devfab.FileRequire.create({
326
+ window.__devfab.FileRequire.configure({
296
327
  manifest, // 也可以传 URL 自己 fetch
297
328
  lockVersion: '1.0.0', // 锁定版本,防止「悄悄换文件」
298
329
  origins: ['https://cdn.example.com'], // 只允许从这些来源加载
@@ -312,25 +343,18 @@ const fileRequire = window.__devfab.FileRequire.create({
312
343
  > `crypto.subtle` 只在安全上下文(https / localhost)可用,不可用时会跳过并在结果里标注,
313
344
  > 不会静默通过。
314
345
 
315
- ### 全局污染检测
346
+ ### 关于全局污染检测(已移除)
316
347
 
317
- 二开脚本直接跑在宿主 `window` 上,A 客户的脚本改了一个全局变量,B 客户就跟着崩,
318
- 而且现场无法归因。加载器会在加载前后 diff `window` 的 key 集合:
348
+ 2.1.0 及之前的版本会在每次加载前后 diff `window` 的 key 集合,把二开脚本新增 / 覆盖的全局
349
+ 放进 `result.warnings`,`strict: true` 时还能升级成 `code: 500`。**已整体移除**,原因:
319
350
 
320
- ```js
321
- fileRequire.require(['extendjs', 'frontend'], ['xxx.js'], (result) => {
322
- if (result.warnings.length) {
323
- console.warn('[devfab] 二开脚本动了这些全局:', result.warnings)
324
- // [{ type: 'added', key: '__someSdk', watched: false }, ...]
325
- }
326
- })
327
- ```
351
+ - 它是**默认开启**的,而这一层的规矩是「不配置不生效」——它是唯一破例的模块;
352
+ - 每次加载要全量 `Object.keys(window)` 拍两次快照(实测空页面 237 个 key、其中 187 个是访问器,
353
+ 单次约 2.6ms),换来的 `warnings` 默认没人消费(`strict` 默认 `false`);
354
+ - 只比一层引用:`window.foo.bar = 1` 和 `delete window.foo` 都检测不到,并发加载归因也不准。
328
355
 
329
- - 命中盯防名单(`$` / `jQuery` / `define` / `window.__devfab` 等)立即告警;
330
- - 新增全局超过 `maxPollution`(默认 3)告警;
331
- - `strict: true` 时把告警升级为 `code: 500`(**开发期用**:脚本已经执行过了,
332
- 这是事后报错,不是拦截);
333
- - 这是**观测**不是隔离,并发加载时归因可能不准。
356
+ `result.warnings` 字段保留为空数组(契约形状不变),但**不再有任何来源写入**。
357
+ 需要「这脚本到底动了什么全局」时,正确做法是在接入期手工比对,或直接上 iframe 隔离。
334
358
 
335
359
  ### ESM 通道:给 RequireJS 的技术债留一条退路
336
360
 
@@ -343,7 +367,7 @@ const result = await fileRequire.loadModules(['extendjs/frontend/xxx.mjs'])
343
367
  result.data // 各模块的导出对象
344
368
 
345
369
  // 旧:AMD,保留给存量宿主
346
- fileRequire.require(['extendjs', 'frontend'], ['xxx.js'], (result) => {})
370
+ fileRequire.inject(['extendjs', 'frontend'], ['xxx.js'], (result) => {})
347
371
  ```
348
372
 
349
373
  - ESM 通道要求产物是**标准 ESM**,不参与 AMD 的匿名 `define` 匹配;
@@ -366,10 +390,10 @@ fileRequire.require(['extendjs', 'frontend'], ['xxx.js'], (result) => {})
366
390
  ```js
367
391
  /**
368
392
  * 扩展脚本示例
369
- * 运行时契约:用 window.__devfab.define([], factory) 注册匿名模块,
393
+ * 运行时契约:用 window.__devfab.provide([], factory) 注册匿名模块,
370
394
  * 模块返回 { doAction(name, viewModel) },加载后由宿主按约定调用。
371
395
  */
372
- window.__devfab.define([], function () {
396
+ window.__devfab.provide([], function () {
373
397
  return {
374
398
  doAction(name, viewModel) {
375
399
  if (name !== 'init') return
@@ -382,12 +406,12 @@ window.__devfab.define([], function () {
382
406
 
383
407
  > 扩展脚本按 `extendjs/{domainKey}/{pageKey}_FE.Extend.js` 的路径约定存放,`domainKey` 用来把脚本归类到不同客户 / 业务域。
384
408
 
385
- **第二步:宿主用 `require` 加载并触发。**
409
+ **第二步:宿主用 `inject` 加载并触发。**
386
410
 
387
- `require(path, files, callback)` 里 `path` 是目录前缀(可传数组),`files` 是文件列表,二者会被拼接成模块路径:
411
+ `inject(path, files, callback)` 里 `path` 是目录前缀(可传数组),`files` 是文件列表,二者会被拼接成模块路径:
388
412
 
389
413
  ```js
390
- window.__devfab.FileRequire.create().require(
414
+ window.__devfab.inject(
391
415
  ['extendjs', 'frontend'], // path:目录前缀 → 'extendjs/frontend'
392
416
  ['frontend_view_list_FE.Extend.js'], // files:文件列表
393
417
  function (result) {
@@ -418,7 +442,7 @@ function Message(props) {
418
442
  const components = { Test, Message }
419
443
 
420
444
  // 把整个组件表注册成一个无依赖的匿名模块
421
- window.__devfab?.FileRequire?.create().provideScript(components)
445
+ window.__devfab?.provideScript(components)
422
446
  ```
423
447
 
424
448
  > 组件源码正常写 JSX,构建时打进一个独立的 `components.js` 产物(`example/vue3/dist/components/vue-components.js`),加载该文件即完成注册。
@@ -432,7 +456,7 @@ function Test(props) {
432
456
  .text(`I am a test html5 component, props=${props.value}`)
433
457
  }
434
458
 
435
- window.__devfab?.FileRequire?.create().provideScript({ Test })
459
+ window.__devfab?.provideScript({ Test })
436
460
  ```
437
461
 
438
462
  **第二步:宿主用 `injectScript` 加载并使用。**
@@ -441,7 +465,7 @@ window.__devfab?.FileRequire?.create().provideScript({ Test })
441
465
 
442
466
  ```js
443
467
  useEffect(() => {
444
- window.__devfab.FileRequire.create().injectScript(
468
+ window.__devfab.injectScript(
445
469
  ['http://localhost:9010/components/vue-components.js'],
446
470
  function (result) {
447
471
  // provideScript 注册的是整个 components 对象,
@@ -467,6 +491,50 @@ const TestCom = state.Test
467
491
  1. **扩展脚本**:`extendjs/{domainKey}/{pageKey}_FE.Extend.js`,`define([], () => ({ doAction }))`,替换静态资源即生效;
468
492
  2. **自定义组件**:JSX 组件打包成 `components.js`,`provideScript(components)` 注册,宿主 `injectScript([url], cb)` 加载使用。
469
493
 
494
+ ### 宿主接入:`initViewModel` 与 `params.fileRequire`
495
+
496
+ 模型层(`utils.models.initViewModel`)负责把扩展脚本装配进 VM 生命周期。它**不再自己 import 加载器**,
497
+ 而是由宿主把单例传进来 —— 这是必须显式传的**必填参数**:
498
+
499
+ ```js
500
+ // ESM 宿主:import { initViewModel } from 'devfab/dist/common/utils.esm.js'
501
+ // 或直接用 UMD 挂载的门面:
502
+ const { initViewModel } = window.__devfab.utils.models
503
+
504
+ initViewModel(meta, {
505
+ fileRequire: window.__devfab.FileRequire, // ← 必填
506
+ extendScriptParams: {
507
+ enableJs: true, // 页面级:是否加载 *_FE.Extend.js
508
+ enableExtJs: true, // 数据级:是否加载 extscripturls 里的脚本
509
+ filepath: ['extendjs', 'frontend'], // 域前缀,与 require(path, files) 的 path 一致
510
+ scriptUrl: 'frontend_view_list_FE.Extend.js',
511
+ exturlsField: 'extscripturls', // 可选,默认 extscripturls
512
+ },
513
+ }, (vm) => {
514
+ // extendReady 之后回调
515
+ })
516
+ ```
517
+
518
+ **为什么不让模型层自己 import**:那样 `dist/common/models.js` 会内联一份 `file.js` + `policy.js`,
519
+ 于是同一个页面出现两个加载器单例 —— 宿主在 `window.__devfab.FileRequire` 上配的清单 / 版本锁,
520
+ 扩展脚本主链路完全看不到(配了等于没配)。参数注入之后模型层不再反向依赖加载器。
521
+
522
+ **从旧版迁移**(唯一需要改代码的地方):
523
+
524
+ ```diff
525
+ - initViewModel(meta, { requirejs: window.__devfab_requirejs, extendScriptParams })
526
+ + initViewModel(meta, { fileRequire: window.__devfab.FileRequire, extendScriptParams })
527
+ ```
528
+
529
+ 漏传的后果是**可诊断的**,不是崩溃:`loadScripts` 会回
530
+
531
+ ```js
532
+ { code: 404, message: 'params.fileRequire is required(…),the files: xxx.js', data: [], warnings: [] }
533
+ ```
534
+
535
+ 并且**一定会回调** —— `initExtendScripts` 只有拿到回调才会 `execute('extendReady')`,
536
+ 不回调就等于 ready 事件永远不发,宿主会卡在 loading。
537
+
470
538
  ---
471
539
 
472
540
  ## 开发与构建
@@ -1,3 +1,3 @@
1
- function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(i,a){var o=e.apply(n,r);function s(e){t(o,i,a,s,u,"next",e)}function u(e){t(o,i,a,s,u,"throw",e)}s(void 0)})}}function r(e,t,n){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function h(){
1
+ function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e,t,n,r,a,o,i){try{var s=e[o](i),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,a)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(a,o){var i=e.apply(n,r);function s(e){t(i,a,o,s,u,"next",e)}function u(e){t(i,a,o,s,u,"throw",e)}s(void 0)})}}function r(e,t,n){return t=u(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,l()?Reflect.construct(t,n||[],u(e).constructor):t.apply(e,n))}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_(r.key),r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(l=function(){return!!e})()}function f(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?f(Object(n),!0).forEach(function(t){s(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function v(){
2
2
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
3
- var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",i=n.toStringTag||"@@toStringTag";function a(n,r,i,a){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return v(c,"_invoke",function(n,r,i){var a,s,u,c=0,l=i||[],f=!1,d={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(t,n){return a=t,s=0,u=e,d.n=n,o}};function h(n,r){for(s=n,u=r,t=0;!f&&c&&!i&&t<l.length;t++){var i,a=l[t],h=d.p,v=a[2];n>3?(i=v===r)&&(u=a[(s=a[4])?5:(s=3,3)],a[4]=a[5]=e):a[0]<=h&&((i=n<2&&h<a[1])?(s=0,d.v=r,d.n=a[1]):h<v&&(i=n<3||a[0]>r||r>v)&&(a[4]=n,a[5]=r,d.n=v,s=0))}if(i||n>1)return o;throw f=!0,r}return function(i,l,v){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,v),s=l,u=v;(t=s<2?e:u)||!f;){a||(s?s<3?(s>1&&(d.n=-1),h(s,u)):d.n=u:d.v=u);try{if(c=2,a){if(s||(i="next"),t=a[i]){if(!(t=t.call(a,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=a.return)&&t.call(a),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);a=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==o)break}catch(t){a=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,i,a),!0),c}var o={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(v(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,v(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,v(f,"constructor",c),v(c,"constructor",u),u.displayName="GeneratorFunction",v(c,i,"GeneratorFunction"),v(f),v(f,i,"Generator"),v(f,r,function(){return this}),v(f,"toString",function(){return"[object Generator]"}),(h=function(){return{w:a,m:d}})()}function v(e,t,n,r){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}v=function(e,t,n,r){function a(t,n){v(e,t,function(e){return this._invoke(t,n,e)})}t?i?i(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(a("next",0),a("throw",1),a("return",2))},v(e,t,n,r)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],u=!0,c=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,i=e}finally{try{if(!u&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(c)throw i}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||b(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var k=function(){return o(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){this._data=Object.assign({},e)}},{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){var t;return null===(t=this._data)||void 0===t?void 0:t[e]}},{key:"delete",value:function(e){delete this._data[e]}},{key:"clear",value:function(){this._data={}}}])}();k.create=function(e){return new k};var w=function(){return o(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){var t;this.__ASYNC_EXECUTE__=null===(t=null==e?void 0:e.__ASYNC_EXECUTE__)||void 0===t||t,this._events=new Map,this._firstevents=new Map}},{key:"on",value:function(e,t,n){var r=this._events.get(e);Array.isArray(r)||(r=[]),r.push({callback:t,context:n}),this._events.set(e,r)}},{key:"onFirst",value:function(e,t,n){var r=this._firstevents.get(e);Array.isArray(r)||(r=[]),r.splice(0,0,{callback:t,context:n}),this._firstevents.set(e,r)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var i=this._events.get(e),a=this._firstevents.get(e);if(!i&&!a)return!0;var o=!0;return[].concat(g(a||[]),g(i||[])).forEach(function(e){if(!1!==o){var t=e.callback.apply(e.context||void 0,n);o=!1!==t&&o}}),o}},{key:"un",value:function(e,t){this._unEvents(e,t,this._events),this._unEvents(e,t,this._firstevents)}},{key:"_unEvents",value:function(e,t,n){if(e&&n.has(e))if(t){var r=n.get(e),i=null==r?void 0:r.findIndex(function(e){return e.callback===t});-1!==i&&(null==r||r.splice(i,1))}else n.delete(e)}},{key:"hasEvent",value:function(e){var t,n;return e?((null===(t=this._events.get(e))||void 0===t?void 0:t.length)||0)+((null===(n=this._firstevents.get(e))||void 0===n?void 0:n.length)||0):0}},{key:"fireEvent",value:function(e,t){this.execute("before".concat(e),t)&&(this.execute(e,t),this.execute("after".concat(e),t))}},{key:"_asyncExecute",value:function(e,t,n){for(var r,i=this,a=n.resolve,o=n.reject,s=n.args,u=!0,c=t||[],l=!1,f=function(t){var n,r=c[t];if(!1===u)return 0;if(l)return{v:void 0};if("development"===process.env.nodeEnv)n=r.callback.apply(r.context||i,s);else try{n=r.callback.apply(r.context||i,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(l=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===c.length-1&&(null==o||o())},resolve:function(n){t===c.length-1?(s.length>1&&(s[0]=n),null==a||a(s)):i._asyncExecute(e,c.slice(t+1),{resolve:a,reject:o,args:s})}})):(u=!1!==n&&u,t===c.length-1&&(u?null==a||a(s):null==o||o()))},d=0;d<c.length&&0!==(r=f(d));d++)if(r)return r.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,r){var i=this._events.get(e),a=this._firstevents.get(e);if(!((Array.isArray(i)?i.length:i)||(Array.isArray(a)?a.length:a)))return null==t?void 0:t();var o=[].concat(g(a||[]),g(i||[]));return this._asyncExecute(e,o,{resolve:t,reject:n,args:r})}},{key:"promiseExecute",value:function(e,t){var n=this,r=e,i=1;if("boolean"==typeof e&&(r=t,i=2),r){for(var a=arguments.length,o=new Array(a>2?a-2:0),s=2;s<a;s++)o[s-2]=arguments[s];var u=2===i?o:[t].concat(o);if(u.length){var c,l=u.length-1,f=u[l];if("function"!=typeof f){if("object"!==m(f)||!f[0]||"function"!=typeof f[0]||!f[1]||"function"!=typeof f[1])return;c=f[1],f=f[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(r,function(e){f.apply(n,e)},function(){c&&"function"==typeof c&&c()},u);u.splice(l,1),u.unshift(r);var d=this.execute.apply(this,u);if(d instanceof Promise){var h=this;d.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];f.apply(h,t)},function(){c&&"function"==typeof c&&c()})}else if(!d)return void(c&&"function"==typeof c&&c())}}}},{key:"clear",value:function(){this._events.clear(),this._firstevents.clear()}}])}();function x(e){return e||window.devfab&&window.devfab.debug}function P(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),n=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=n<0?t.substr(e+1):t.substring(e+1,n)).length>0)for(var r=(t=t.replace(/\+/g," ")).split("&"),i=0,a=r.length;i<a;i++){var o=r[i]||"";if(o){var s=o.indexOf("="),u="",c="";s<0?c=u=window.decode(o):(u=window.decode(o.substr(0,s)),c=window.decode(o.substr(s+1))),this.query[u]=c}}}else this.pathname=t},this.set=function(e,t){this.query[e]=t},this.get=function(e){return this.query[e]},this.del=function(e){delete this.query[e]},this.has=function(e){return null!=this.query[e]},this.toStr=function(){var e=["?"];for(var t in this.query)e.push(encodeURIComponent(t)),e.push("="),e.push(encodeURIComponent(this.query[t])),e.push("&");return 1===e.length?"":(e.splice(e.length-1,1),e.join(""))},this.init()}function S(e,t){if(!t)return e;var n=[],r=new P(e);for(var i in t)r.get(i)||n.push("".concat(i,"=").concat(t[i]));if(!n.length)return e;var a=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(a):"".concat(e,"?").concat(a)}w.create=function(e){return new w(e)},String.prototype.equalsIgnoreCase=function(e){return null!=e&&this.toLowerCase()===e.toLowerCase()};var j={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t,n=e.method||"GET",r=e.url;try{null!=e&&e.requestHeaders&&(t=e.requestHeaders,e.requestHeaders=void 0,delete e.requestHeaders)}catch(e){x()&&console.log('[devfab][ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{e.params&&e.params.requestHeaders&&(t=e.params.requestHeaders,e.params.requestHeaders=void 0,delete e.params.requestHeaders)}catch(e){x()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var i=null;if(n.equalsIgnoreCase("get")||n.equalsIgnoreCase("delete")?r=S(r,e.params):(n.equalsIgnoreCase("post")||n.equalsIgnoreCase("put"))&&(i=JSON.stringify(e.params)),e.jsonp)return this.getJsonp(r,e.callback);var a=this.getXMLHttpRequest();if(a){var o;if(a.open(n,r,!1!==e.async),e.timeout&&(a.timeout=e.timeout,a.setRequestHeader("timeout",e.timeout),a.ontimeout=function(){j.onerror(this,e,"timeout")}),e.contentType){if(a.setRequestHeader("Content-Type",e.contentType),e.contentType.indexOf("x-www-form-urlencoded")>=0)i=null===(o=new URLSearchParams(e.params))||void 0===o?void 0:o.toString()}else e.dateType?i=e.params:a.setRequestHeader("Content-Type","application/json;charset=utf-8");try{if(t&&"[object Object]"===Object.prototype.toString.call(t))for(var s in t)a.setRequestHeader(s,t[s])}catch(e){x()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}a.withCredentials=null==e||!e.hasOwnProperty("withCredentials")||e.withCredentials,e.onBeforeRequest&&e.onBeforeRequest(a,i);try{a.send(i)}catch(t){return{error:"NetWorkError",options:e}}if(!1===e.async)return this.onreadystatechange(a,e);a.onreadystatechange=function(){j.onreadystatechange(this,e)}}},onreadystatechange:function(e,t){if(4===e.readyState){if(200===e.status){var n;try{if("blob"===t.responseType){var r=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=p(e.split(": "),2),r=t[0],i=t[1];n[r]=i}),n}({xhr:e});n={code:e.status,data:{data:e.response,headers:r}}}else n=JSON.parse(e.responseText)}catch(n){j.onerror(e,t,e.responseText)}if(!1===t.async)return e.isBusy=!1,t.onAfterRequest&&t.onAfterRequest(n),j.parseAjaxResult(n,!1,null,null,t,e);j.parseAjaxResult(n,t.async,t.callback,t.context,t,e),t.onAfterRequest&&t.onAfterRequest(n)}else if(0===e.status)j.onerror(e,t,"The network connection has been disconnected. Please check the network status of the device and try.");else if(502===e.status||504===e.status)j.onerror(e,t,"An error has occurred with the service. Please try again later.");else{if(401!==e.status){var i={};try{i=JSON.parse(e.responseText)}catch(t){i={code:e.status,message:e.responseText}}return j.onerror(e,t,i)}j.onerror(e,t,"Login information has expired. Please log in again or contact technical staff.")}e.isBusy=!1}},onerror:function(e,t,n){var r="[devfab][ajax]: [onerror]: api error \n [code]: ".concat(e.status," \n [error]: ").concat(("object"===m(n)?JSON.stringify(n):n)||"空"," \n [url]: ").concat(t.url," \n [token]: ").concat(document.cookie);x()&&console.log(r);var i="object"===m(n)?n:{code:500,message:n};t.onAfterRequest&&t.onAfterRequest(i)},getXMLHttpRequest:function(){return this.createXMLHttpRequest()},createXMLHttpRequest:function(){return window.XMLHttpRequest?new XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):null},getJsonp:function(e,t){var n=e,r="callback"+this._jsonps.index++,i=document.createElement("script");this._jsonps[r]=function(e){try{t(e)}finally{document.body.removeChild(i)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxUtil._jsonps."+r,i.src=n,document.body.appendChild(i)},parseAjaxResult:function(e,t,n,r,i,a){if(e){if(!e.code)return!1===t?e:void(n&&n.call(r,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(r,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(r,e)}}}};function A(e,t){this.init&&this.init(e),this.queryParams=t}A.create=function(e,t){return new A(e,t)},A.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,r){return this.Do(e,t,n,null,r)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},A.prototype.Do=function(e,t,n,r,i){var a,o,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],c=u.url;this.queryParams||(this.queryParams={}),null!==(a=u.options)&&void 0!==a&&a.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(o=u.options)&&void 0!==o&&o.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(c=S(c,this.queryParams));var l=c,f=Object.assign({},u.options);return f.method=u.method||"GET","function"==typeof t?(f.callback=t,f.context=i||f.context||this):f.params=t,n&&(f.callback=n,f.context=i||f.context||this),!1===r&&(f.async=!1),this.ajax(l,f)}},A.prototype.ajax=function(e,t){return function(e,t){return t.url=e,j.doRequest(t)}(e,t)};var q=function(){return o(function e(t){i(this,e),this._init(t)},[{key:"_init",value:function(e){this._data={};var t=[];if(e)for(var n in e)t.push(n);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new k,this._data.events=new w}},{key:"_del_data",value:function(e){e&&delete this._data[e]}},{key:"_cls_data",value:function(){this._data.cache.clear(),this._data.events.clear(),this._data={components:[],propertyNames:[],cache:new k,events:new w}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var r=this._data.propertyNames||[];r.indexOf(e)<0&&r.push(e)}this._data[e]=t}}},{key:"_get_data",value:function(e){if(e)return this._data[e]}},{key:"getData",value:function(){return this._get_data("value")}},{key:"getState",value:function(e,t){var n;if(!t)return this._get_data(e);var r=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return r?null===(n=r.getState)||void 0===n?void 0:n.call(r,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var r={};r[e]=t,this.doPropertyChange("setState",r,n)}},{key:"doPropertyChange",value:function(e,t,n){var r=this,i=this._get_data("components")||[];if(!i.length)return i;var a=[];if(n){var o=i.find(function(e){return e.ctrlName===n});o&&!this.notifyComponent(o,e,t)&&a.push(o)}else i.forEach(function(n){r.notifyComponent(n,e,t)||a.push(n)});return a.length?a:void 0}},{key:"notifyComponent",value:function(e,t,n){return"function"==typeof e[t]&&(this.viewUpdater(e,t,n),!0)}},{key:"viewUpdater",value:function(e,t,n){if("setState"===t)e[t](n);else{var r=this.getCache("name");e[t](n,r)}}},{key:"get",value:function(e){return this._get_data(e)}},{key:"addComponent",value:function(e,t){if(e){t&&!e.ctrlName&&(e.ctrlName=t);var n=this._get_data("components")||[];n.indexOf(e)>=0||n.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],n=t.indexOf(e);n<0||t.splice(n,1)}},{key:"_applyState",value:function(e,t,n){var r=this;n||this._set_data(e,t,!0);var i="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),a=this.doPropertyChange(i,t,n);if(a){var o={};o[e]=t,a.forEach(function(e){r.notifyComponent(e,"setState",o)})}}},{key:"getVisible",value:function(e){return this.getState("visible",e)}},{key:"setVisible",value:function(e,t){this._applyState("visible",e,t)}},{key:"getValue",value:function(){return this.getData()}},{key:"setValue",value:function(e,t,n){var r=this,i=this.getValue();if(e!==i){var a={value:e,oldValue:i},o=this._get_data("forceFireEvent");t||o?this.promiseExecute("beforeValueChange",a,[function(){r._set_data("value",e,!0),r._applyState("value",e,n),r.execute("afterValueChange",a)},function(){r._set_data("value",i,!0),r._applyState("value",i,n)}]):(this._set_data("value",e,!0),this._applyState("value",e,n))}}},{key:"getDisabled",value:function(e){return this.getState("disabled",e)}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"setParent",value:function(e){this.setCache("parent",e)}},{key:"getParent",value:function(){return this.getCache("parent")}},{key:"getRootParent",value:function(){for(var e=this.getParent();null!==(t=e)&&void 0!==t&&t.getParent();){var t;e=e.getParent()}return e}},{key:"setName",value:function(e){this.setCache("name",e)}},{key:"getName",value:function(){return this.getCache("name")}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getDirtyData",value:function(e){var t=this.getData();return!1!==e&&this._get_data("isDirty")||t!==this._get_data("originalData")?t:void 0}},{key:"clear",value:function(e){void 0===e?this._set_data("value",this._get_data("cDefaultValue")):e||this._set_data("value",void 0),this._del_data("isDirty"),this._del_data("checking"),this._del_data("checkMsg")}},{key:"on",value:function(e,t,n){this._get_data("events").on(e,t,n)}},{key:"onFirst",value:function(e,t,n){this._get_data("events").onFirst(e,t,n)}},{key:"execute",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return(t=this._get_data("events")).execute.apply(t,[e].concat(r))}},{key:"un",value:function(e,t){this._get_data("events").un(e,t)}},{key:"hasEvent",value:function(e){return this._get_data("events").hasEvent(e)}},{key:"fireEvent",value:function(e,t){this._get_data("events").fireEvent(e,t)}},{key:"promiseExecute",value:function(e,t){for(var n,r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(i))}},{key:"setCache",value:function(e,t){this._get_data("cache").set(e,t)}},{key:"getCache",value:function(e){return this._get_data("cache").get(e)}},{key:"clearCache",value:function(e){this._get_data("cache").delete(e)}},{key:"setProxy",value:function(e){if(!(e instanceof A)){var t,n=this._get_data("__requestHeaders__");for(var r in e){var i,a,o;if(n&&(null===(i=e[r])||void 0===i||null===(i=i.options)||void 0===i||!i.requestHeaders))null!==(o=e[r])&&void 0!==o&&o.options||(e[r].options={}),e[r].options.requestHeaders=n;null!==(a=this.getProxy())&&void 0!==a&&a[r]&&window.devfab.debug&&console.warn("[devfab][baseModel.prototype.setProxy]: Proxy ".concat(r," already exists on the model. Please change the name of ").concat(r," and try again"))}return this._set_data("proxy",A.create(d(d({},(null===(t=this.getProxy())||void 0===t?void 0:t.config)||{}),e))),this.getProxy()}this._set_data("proxy",e)}},{key:"getProxy",value:function(){return this._get_data("proxy")}}])}(),C=function(){function e(){var t;i(this,e);for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return s(t=r(this,e,[].concat(a)),"modelType","SimpleModel"),t}return c(e,q),o(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e,t){this._applyState("readonly",e,t)}}])}(),O=Array.isArray;function E(e){if(O(e))return e.map(E);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===m(e)){var t={};for(var n in e)t[n]=E(e[n]);return t}return e}function M(e,t,n){var r=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var i=r,a=r.setProxy({queryData:e}),o=r._get_data("innerUsedAttrs").pageIndex,u={page:s(s({},r._get_data("innerUsedAttrs").pageSize,r.getPageSize()),o,r.getPageIndex())},c=Object.assign(t,u);r.setCache("proxyCache",{proxyConfig:e,params:c,callback:n});if(!1!==r.execute("beforeQueryData",c)){var l=E(c);a.queryData(l,function(e,t,r,i){if(!e){var a=t;this._set_data("dataSourceMode","remote");var o=function(e){if(!e)return[];if(O(e))return e;if(O(e.data))return e.data;if(O(e.records))return e.records;if(O(e.list))return e.list;if(O(e.rows))return e.rows;var t=e.data&&"object"===m(e.data)?e.data:e.result;return O(t)?t:t&&"object"===m(t)&&(t.records||t.list||t.rows||t.data)||[]}(a=Object.assign({},a));this.execute("afterQueryData",a),null==n||n.call(this,o)}},i)}})}function D(e){if(this.execute("beforeSetDataSource",e)){var t=this.getRowKeyField(),n={};e.forEach(function(e){n[e[t]]=e}),this._set_data("keyMap",n),this._set_data("dataSource",e,!0),this.doPropertyChange("setDataSource"),this.execute("afterSetDataSource",e)}}var R=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,e);var a,o=d(d({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",rowKeyField:"id",cellState:{},rowState:{},showCheckBox:!1,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:s(s(s({},(a={id:"_id",selected:"_selected",status:"_status",pageIndex:"pageNo",pageSize:"pageSize",pageCount:"total"}).pageIndex,1),a.pageSize,20),a.pageCount,0),innerUsedAttrs:a,multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);O(o.dataSource)||(o.dataSource=[]),O(o.rows)||(o.rows=[]);var u=function(){return d({},(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).proxyConfig||{})}(n);return o.proxyConfig=u,o.dataSourceMode=n.dataSourceMode||o.dataSourceMode,s(t=r(this,e,[o]),"modelType","GridModel"),t.initColumns(o.columns),t.initPageInfo(n.cPage||n.page),t.afterInit(),t}return c(e,q),o(e,[{key:"afterInit",value:function(){this.execute("afterInit")}},{key:"initColumns",value:function(e){var t=function(e){var t={};return(O(e)?e:Object.keys(e||{}).map(function(t){var n;return d(d({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var r=e.field||e.cFieldName||e.cName||"col_".concat(n);t[r]=d(d({},e),{},{field:r,label:e.label||e.title||e.cCaption||r,index:void 0===e.index?n:e.index})}}),t}(e);return this._set_data("columns",t,!0),t}},{key:"initPageInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({},this.getPageInfo()),n=this._get_data("innerUsedAttrs").pageIndex,r=this._get_data("innerUsedAttrs").pageSize;t[n]=e.pageNo||e.pageIndex||t.pageIndex||1,t[r]=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t[n]=-1),this._set_data("pageInfo",t)}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"setShowCheckbox",value:function(e){this._applyState("showCheckBox",!!e)}},{key:"setShowRowNo",value:function(e){this._applyState("showRowNo",!!e)}},{key:"getParams",value:function(){return d(d({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"getInnerUsedAttrs",value:function(e){var t=this._get_data("innerUsedAttrs");return e?t[e]:t}},{key:"getId",value:function(){return this.getInnerUsedAttrs("id")}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){D(O(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this.setPageIndex(1),M.call(this,e,n,function(e){D.call(t,e),null==r||r.call(t)})}}},{key:"reloadData",value:function(){var e=this,t=this.getCache("proxyCache");if(t){var n=t.proxyConfig,r=t.params,i=t.callback;M.call(this,n,r,function(t){null==i||i.call(e,t)})}else x()&&console.log("[devfab][GridModel] proxyConfig is null")}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e){return e?this._get_data("rows"):this._get_data("dataSource")}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0)}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")}},{key:"getPageIndex",value:function(){var e=this._get_data("innerUsedAttrs").pageIndex;return this.getPageInfo()[e]}},{key:"getPageSize",value:function(){var e=this._get_data("innerUsedAttrs").pageSize;return this.getPageInfo()[e]}},{key:"getTotalCount",value:function(){var e=this._get_data("innerUsedAttrs").pageCount;return this.getPageInfo()[e]}},{key:"setPageInfo",value:function(e){var t=this.getPageInfo();this._set_data("pageInfo",d(d({},t),e)),this.reloadData()}},{key:"setPageIndex",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s({},t,Math.max(1,e))))}}},{key:"setPageSize",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex,n=this._get_data("innerUsedAttrs").pageSize;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s(s({},n,Math.max(-1,e)),t,1)))}}},{key:"setTotalCount",value:function(e){var t=this._get_data("innerUsedAttrs").pageCount;this.getPageInfo()[t]=e}}])}(),I=function(){function e(){var t;i(this,e);for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return s(t=r(this,e,[].concat(a)),"modelType","ViewModel"),t}return c(e,q),o(e,[{key:"getParams",value:function(){return this._get_data("params")}},{key:"setParams",value:function(e){this._set_data("params",e,!0)}},{key:"set",value:function(e,t){t instanceof q&&(t.setParent(this),t.setName(e)),this._set_data(e,t,!0)}},{key:"setData",value:function(e){for(var t in e)this.addProperty(t,e[t])}},{key:"addProperty",value:function(e,t){var n=this.get(e);null!=n&&n.setData?n.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],n={};return t.forEach(function(t){var r,i=e.get(t);i instanceof q&&!1!==i._get_data("needCollect")&&(n[t]=null===(r=i.getData)||void 0===r?void 0:r.call(i))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],r={};return n.forEach(function(n){var i,a=t.get(n);if(a instanceof q&&!1!==a._get_data("needCollect")&&(!e||!a._get_data("isGrid"))){var o=null===(i=a.getData)||void 0===i?void 0:i.call(a);void 0!==o&&(r[n]=o)}}),r}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],n=t.indexOf(e);-1!==n&&t.splice(n,1),this._del_data(e)}},{key:"loadData",value:function(e){this.setCache("isLoadData",!0),this.clear(),this.setData(e),this.setDirty(!1),this.setCache("isLoadData",!1)}},{key:"clear",value:function(e){var t=this;(this._get_data("propertyNames")||[]).forEach(function(n){var r,i=t.get(n);i instanceof q&&!1!==i._get_data("needClear")&&(null===(r=i.clear)||void 0===r||r.call(i,e))})}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getGridModel",value:function(e){var t;if(e)return this.get(e);var n=this._get_data("gridModel");if(n)return n;var r=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(r)return this.get(r);for(var i=this._get_data("propertyNames"),a=0,o=i.length;a<o;a++){if((n=this.get(i[a]))instanceof R||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,r=e.length;n<r;n++){var i=this.get(e[n]);(i instanceof R||"GridModel"==i.modelType)&&t.push(i)}return t}},{key:"getGridFilterModel",value:function(e){return this.getGridModel(e).getCache("FilterViewModel")}}])}(),T=403;function U(e){return String(null==e?"":e).replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}var N=function(){return o(function e(t){i(this,e),this.manifest=null,this.origins=null,this.lockVersion=null,this.verifyHash=!0,this.fetch=null,this._index=null,this.configure(t)},[{key:"configure",value:function(e){var t=e||{};return void 0!==t.manifest&&(this.manifest=t.manifest||null),void 0!==t.origins&&(this.origins=t.origins?[].concat(t.origins).map(function(e){return String(e).trim().replace(/\/+$/,"")}):null),void 0!==t.lockVersion&&(this.lockVersion=t.lockVersion||null),void 0!==t.verifyHash&&(this.verifyHash=!!t.verifyHash),void 0!==t.fetch?this.fetch=t.fetch||null:this.fetch||"function"!=typeof fetch||(this.fetch=function(){return fetch.apply(void 0,arguments)}),this._index=null,this}},{key:"enabled",get:function(){return!!this.manifest}},{key:"_moduleIndex",value:function(){if(this._index)return this._index;var e={},t=this.manifest&&this.manifest.modules;return Array.isArray(t)?t.forEach(function(t){t&&t.path&&(e[U(t.path)]=t)}):t&&"object"===m(t)&&Object.keys(t).forEach(function(n){e[U(n)]=t[n]||{}}),this._index=e,e}},{key:"entryOf",value:function(e){return this.manifest&&this._moduleIndex()[U(e)]||null}},{key:"checkVersion",value:function(){if(!this.lockVersion||!this.manifest)return null;var e=String(this.manifest.version||"");return e===String(this.lockVersion)?null:{code:T,message:"清单版本 ".concat(e||"(未声明)"," 与锁定版本 ").concat(this.lockVersion," 不一致,拒绝加载")}}},{key:"checkModules",value:function(e){var t=this.checkVersion();if(t)return t;if(!this.manifest)return null;for(var n=0;n<e.length;n++){var r=U(e[n]);if(!this._moduleIndex()[r])return{code:T,message:"Module ".concat(r," not registered in the list, loading denied.")}}return null}},{key:"checkOrigin",value:function(e){if(!this.origins)return null;if(!function(e){return/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(e)||/^(?:blob|data):/i.test(e)}(e))return null;var t;try{t=new URL(e).origin}catch(t){return{code:T,message:"无法解析的地址:".concat(e)}}return-1===this.origins.indexOf(t)?{code:T,message:"来源 ".concat(t," 不在白名单内(允许:").concat(this.origins.join(", "),")")}:null}},{key:"verify",value:function(e,t){var n=this;if(!this.verifyHash)return Promise.resolve({ok:!0,skipped:"disabled"});if(!t)return Promise.resolve({ok:!0});var r="undefined"!=typeof globalThis&&globalThis.crypto&&globalThis.crypto.subtle;return r?this.fetch?Promise.resolve().then(function(){return n.fetch(e)}).then(function(e){return e&&e.ok?e.arrayBuffer().then(function(e){return r.digest("SHA-256",e)}):{ok:!1,message:"完整性预检请求失败:HTTP ".concat(e&&e.status||"unknown")}}).then(function(e){if(!e||!1===e.ok)return e;var n=function(e){for(var t=new Uint8Array(e),n="",r=0;r<t.length;r++)n+=t[r].toString(16).padStart(2,"0");return n}(e),r=String(t).toLowerCase();return n!==r?{ok:!1,message:"sha256 不匹配:期望 ".concat(r,",实际 ").concat(n)}:{ok:!0}}).catch(function(e){return{ok:!1,message:"完整性预检异常:".concat(e&&e.message||e),error:e}}):Promise.resolve({ok:!0,skipped:"fetch unavailable"}):Promise.resolve({ok:!0,skipped:"crypto.subtle unavailable(需要 https / localhost)"})}},{key:"describe",value:function(){return{manifest:this.enabled?this.manifest.name||"(unnamed)":null,version:this.manifest&&this.manifest.version||null,lockVersion:this.lockVersion,modules:this.enabled?Object.keys(this._moduleIndex()).length:0,origins:this.origins?this.origins.slice():null,verifyHash:this.verifyHash}}}])}(),H=["$","jQuery","define","require","requirejs","devfab","__devfab","__devfab_requirejs"],V=function(){return o(function e(t){i(this,e);var n=t||{};this.maxPollution=void 0===n.maxPollution?3:Number(n.maxPollution),this.watch=[].concat(n.watch||H),this.target=n.target||("undefined"!=typeof window?window:null),this.enabled=void 0===n.enabled||!!n.enabled,this._pending=0,this._before=null,this.lastWarnings=[]},[{key:"_snapshot",value:function(){var e=new Map,t=this.target;return t?(Object.keys(t).forEach(function(n){e.set(n,t[n])}),e):e}},{key:"_diff",value:function(){var e=this,t=this._before,n=this._snapshot(),r=[];if(!t)return r;n.forEach(function(n,i){var a=-1!==e.watch.indexOf(i);t.has(i)?t.get(i)!==n&&r.push({type:"overwritten",key:i,watched:a}):r.push({type:"added",key:i,watched:a})});var i=r.filter(function(e){return e.watched}).length,a=r.filter(function(e){return"added"===e.type}).length;return!i&&a<=this.maxPollution?[]:r}},{key:"begin",value:function(){var e=this;if(!this.enabled||!this.target)return{end:function(){return[]}};this._pending++,1===this._pending&&(this._before=this._snapshot());var t=!1;return{end:function(){if(t)return[];if(t=!0,e._pending--,e._pending>0)return[];var n=e._diff();return e._before=null,e.lastWarnings=n,n}}}},{key:"configure",value:function(e){var t=e||{};return void 0!==t.enabled&&(this.enabled=!!t.enabled),void 0!==t.maxPollution&&(this.maxPollution=Number(t.maxPollution)),void 0!==t.watch&&(this.watch=[].concat(t.watch||[])),void 0!==t.target&&(this.target=t.target||null),this}}])}(),F=null;try{F=new Function("s","return import(s)")}catch(e){F=null}function G(e,t,n,r){var i=e,a=t,o=n;Array.isArray(e)&&!Array.isArray(t)&&(i=null==r?void 0:r.path,a=e,o="function"==typeof t?t:n);var s=(a=Array.isArray(a)?a:[]).join(","),u={code:0,message:"",data:[],warnings:[]};return("require"===r.type&&"function"!=typeof r.require||"define"===r.type&&"function"!=typeof r.define)&&(u.code=404,u.message="requirejs is undefined, the fiels: ".concat(s)),{path:i,files:a,callback:o,filesStr:s,result:u}}function L(e,t){var n="";return Array.isArray(e)?n=e.filter(Boolean).join("/"):"string"==typeof e&&(n=e.replace(/\/+$/,"")),t.map(function(e){var t=String(e).replace(/^\/+/,"");return n?"".concat(n,"/").concat(t):t})}function z(e,t){var n=Number(e);return Number.isFinite(n)?n:t}var B="",X=15e3,J=0,K="",W=function(){return o(function e(t){var n,r,a,o;i(this,e);var s=t||{};this.__debug=null!==(n=s.__debug)&&void 0!==n&&n,this.__rootPath=void 0,this.__define=s.define||(null===(r=window.__devfab_requirejs)||void 0===r?void 0:r.define),this.__require=s.require||(null===(a=window.__devfab_requirejs)||void 0===a?void 0:a.require),this.__undef=s.undef||("function"==typeof(null===(o=this.__require)||void 0===o?void 0:o.undef)?this.__require.undef:null),this.__requireConfig=s.requireConfig||this._pickRequireConfig(this.__require),this.__import=s.importer||null,this._setTimer=s.setTimeout||function(e,t){return setTimeout(e,t)},this._clearTimer=s.clearTimeout||function(e){return clearTimeout(e)},this.options={version:s.version?String(s.version):B,timeout:void 0===s.timeout?X:Math.max(0,z(s.timeout,0)),retry:void 0===s.retry?J:Math.max(0,z(s.retry,0)),strict:!!s.strict,baseUrl:s.baseUrl||K},this.policy=new N(s),this.guard=new V(this._guardOptions(s)),this.options.version&&this._applyUrlArgs()},[{key:"_pickRequireConfig",value:function(e){var t,n=e&&"function"==typeof e.config?e:null===(t=window.__devfab_requirejs)||void 0===t?void 0:t.require;return n&&"function"==typeof n.config?n.config.bind(n):null}},{key:"_guardOptions",value:function(e){return!1===e.pollution?{enabled:!1,target:e.target}:e.pollution&&"object"===m(e.pollution)?Object.assign({target:e.target},e.pollution):{target:e.target,watch:e.watch,maxPollution:e.maxPollution,enabled:void 0===e.pollution||!!e.pollution}}},{key:"configure",value:function(e){var t=e||{};return void 0!==t.debug&&(this.__debug=!!t.debug),void 0!==t.version&&this.setVersion(t.version),void 0!==t.timeout&&(this.options.timeout=Math.max(0,z(t.timeout,this.options.timeout))),void 0!==t.retry&&(this.options.retry=Math.max(0,z(t.retry,this.options.retry))),void 0!==t.strict&&(this.options.strict=!!t.strict),void 0!==t.baseUrl&&(this.options.baseUrl=t.baseUrl||""),void 0===t.manifest&&void 0===t.origins&&void 0===t.lockVersion&&void 0===t.verifyHash&&void 0===t.fetch||this.policy.configure(t),void 0!==t.pollution?this.guard.configure(this._guardOptions(t)):void 0===t.watch&&void 0===t.maxPollution&&void 0===t.target||this.guard.configure(t),this}},{key:"setVersion",value:function(e){return this.options.version=e?String(e):"",this._applyUrlArgs(),this}},{key:"_applyUrlArgs",value:function(){if("function"!=typeof this.__requireConfig)return!1;try{return this.__requireConfig({urlArgs:this.options.version?"v=".concat(encodeURIComponent(this.options.version)):""}),!0}catch(e){return!1}}},{key:"getVersion",value:function(){return this.options.version}},{key:"_snapshotConfig",value:function(){return{__debug:this.__debug,version:this.options.version,timeout:this.options.timeout,retry:this.options.retry,strict:this.options.strict,baseUrl:this.options.baseUrl,manifest:this.policy.manifest,origins:this.policy.origins,lockVersion:this.policy.lockVersion,verifyHash:this.policy.verifyHash,fetch:this.policy.fetch,pollution:this.guard.enabled,watch:this.guard.watch,maxPollution:this.guard.maxPollution,target:this.guard.target}}},{key:"describe",value:function(){return Object.assign({},this.options,{debug:this.__debug,policy:this.policy.describe(),pollutionGuard:this.guard.enabled,canUndef:"function"==typeof this.__undef,canNativeImport:"function"==typeof(this.__import||F)})}},{key:"_define",value:function(e,t,n){var r=G(e,t,n,{path:this.__rootPath,define:this.__define,type:"define"}),i=r.path,a=r.files,o=r.callback,s=r.result;404!==s.code?this.__define(i,a,o):null==o||o(s)}},{key:"_mergeWarnings",value:function(e,t){var n=(e||[]).slice();return(t||[]).forEach(function(e){n.some(function(t){return t.type===e.type&&t.key===e.key})||n.push(e)}),n}},{key:"_undefModules",value:function(e){var t=this;"function"==typeof this.__undef&&e.forEach(function(e){try{t.__undef(e)}catch(e){}})}},{key:"_load",value:function(e,t,n){var r=this,i=this.options,a=G(e,t,n,{path:this.__rootPath,require:this.__require,type:"require"}),o=a.path,s=a.files,u=a.callback,c=a.result,l=a.filesStr;if(404!==c.code){var f=L(o,s),d=this.policy.checkModules(f);if(d)return c.code=d.code,c.message=d.message,void(null==u||u(c));var h=!1,v=0,y=null,p=null,g=function(){p&&(c.warnings=r._mergeWarnings(c.warnings,p.end()),p=null)},_=function(){h||(h=!0,null!==y&&(r._clearTimer(y),y=null),g(),i.strict&&c.warnings.length&&(c.code=500,c.message="Global pollution detection failed:".concat(c.warnings.map(function(e){return"".concat(e.type,":").concat(e.key)}).join(", "))),null==u||u(c))},m=function(){v++,p=r.guard.begin(),i.timeout>0&&(y=r._setTimer(function(){if(!h){var e=new Error("load timeout after ".concat(i.timeout,"ms: ").concat(l));e.__devfabTimeout=!0,b(e,"files load timeout after ".concat(i.timeout,"ms, the files: ").concat(l))}},i.timeout)),r.__require(o,s,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];c.data=t,_()},function(e){b(e)})},b=function(e,t){if(!h){if(null!==y&&(r._clearTimer(y),y=null),v<=i.retry)return g(),r._undefModules(f),void m();c.code=e&&e.__devfabTimeout?504:500,c.message=t||"files load error, the files: ".concat(l),c.error=e,_()}};m()}else null==u||u(c)}},{key:"load",value:function(e,t,n){this._load(e,t,n)}},{key:"resolveUrl",value:function(e){var t=String(null==e?"":e);if(/^[a-z][a-z0-9+.-]*:/i.test(t)||/^\/\//.test(t))return t;var n=this.options.baseUrl||("undefined"!=typeof document&&document.baseURI?document.baseURI:"");if(!n)return t;try{return new URL(t,n).href}catch(e){return t}}},{key:"_importOne",value:function(e){var t=this,n=this.resolveUrl(e),r=this.policy.checkOrigin(n);if(r)return Promise.resolve({ok:!1,code:r.code,message:r.message});var i=this.policy.entryOf(e),a=i&&i.sha256,o=function(){var e=t.__import||F;return"function"!=typeof e?Promise.resolve({ok:!1,code:500,message:"native import() is unavailable(CSP 是否禁用了 unsafe-eval?)"}):Promise.resolve().then(function(){return e(n)}).then(function(e){return{ok:!0,module:e}},function(e){return{ok:!1,code:500,message:"module load error: ".concat(n),error:e}})};return a?this.policy.verify(n,a).then(function(e){return e.ok?o():{ok:!1,code:T,message:"".concat(e.message,"(").concat(n,")")}}):o()}},{key:"loadModules",value:function(e,t,n){var r=this,i=G(e,t,n,{path:this.__rootPath,type:"module"}),a=i.path,o=i.files,s=i.callback,u=i.result,c=i.filesStr,l=L(a,o),f=function(e){return null==s||s(e),e},d=this.policy.checkModules(l);if(d)return u.code=d.code,u.message=d.message,Promise.resolve(f(u));if(!o.length)return Promise.resolve(f(u));var h=this.guard.begin();return Promise.all(l.map(function(e){return r._importOne(e)})).then(function(e){u.warnings=h.end();var t=e.filter(function(e){return!e.ok});return t.length?(u.code=t[0].code||500,u.message="".concat(t.map(function(e){return e.message}).join("; "),"(the files: ").concat(c,")"),u.error=t[0].error):u.data=e.map(function(e){return e.module}),f(u)})}},{key:"loadModule",value:function(e,t){return this.loadModules([e],t)}}])}(),Q=function(){function e(){return i(this,e),r(this,e,arguments)}return c(e,W),o(e,[{key:"define",value:function(e,t,n){this._define(e,t,n)}},{key:"defineScript",value:function(e){this.provideScript(e)}},{key:"provideScript",value:function(e){var t=e;"function"!=typeof e&&(t=function(){return e}),this.define([],t)}},{key:"require",value:function(e,t,n){this._load(e,t,n)}},{key:"injectScript",value:function(e,t,n,r){var i=this,a=e,o=t,s=n,u=r;Array.isArray(e)&&"function"==typeof t&&(a=void 0,o=e,s=t,u=n),this._load(a,o,function(e){if(0==e.code&&Array.isArray(e.data))for(var t=0,n=e.data.length;t<n;t++){var r,a=e.data[t];null===(r=s)||void 0===r||r(a,t)}else"function"==typeof u?u(e):i.__debug&&console.error("[devfab][FileRequire][injectScript] error: ",e)})}},{key:"requireScript",value:function(e,t,n){this.injectScript(e,t,n)}}])}(),$=new Q;function Y(e,t,n,r,i){var a,o=t,s=n,u=r,c=i;Array.isArray(t)&&"function"==typeof n&&(o=void 0,s=t,u=n,c=r);var l=(null===(a=c)||void 0===a?void 0:a.viewModel)||this,f=(s=Array.isArray(s)?s:[]).join(",");return $.create({require:e}).require(o,s,function(e){var t;if(0==e.code&&Array.isArray(e.data))for(var n=0,r=e.data.length;n<r;n++){var i=e.data[n];if(i&&i.doAction)try{i.doAction("init",l)}catch(t){e.code=500,e.message="".concat(f," script execute error"),e.error=t;break}else try{var a;"function"==typeof(null===(a=c)||void 0===a?void 0:a.onFileBack)&&c.onFileBack(i,n)}catch(t){e.code=500,e.message="".concat(f," script customize execute error");break}}0!=e.code&&window.__devfab.debug&&console.info("[devfab][models][extend][loadScripts] ".concat(f," \n [message]: ").concat(e.message," \n").concat(e.error?" \n [error]: ":""),e.error),null===(t=u)||void 0===t||t(e)})}function Z(e){var t=this;window.__devfab&&window.__devfab.__debugger_initExtendJs;var n=e.requirejs,r=e.extendScriptParams,i=e.readyEventName,a=void 0===i?"extendReady":i,o=r||{},s=o.enableJs,u=void 0!==s&&s,c=o.filepath,l=o.scriptUrl;if(!u)return window.__devfab.debug&&console.info("[devfab][extend][js] not enable extend script"),void t.execute(a,t);if(!l)return window.__devfab.debug&&console.info("[devfab][extend][js] extend script is not defined"),void t.execute(a,t);var f=c,d=[l];t.getEnv&&t.getEnv("everyCommonExtend")&&d.push(t.getEnv("everyCommonExtend")),Y.call(t,null==n?void 0:n.require,f,d,function(e){t.execute(a,t,e)})}$.create=function(e){return new Q(d(d({},this._snapshotConfig()),e))};var ee=function(){var e=n(h().m(function e(t,r,i){var a,o,s,u,c,l,f,d,v,y,p;return h().w(function(e){for(;;)switch(e.n){case 0:if(window.__devfab&&window.__devfab.__debugger_initExtJs,s=i.requirejs,u=i.extendScriptParams,l=(c=u||{}).enableExtJs,f=void 0!==l&&l,d=c.exturlsField,v=void 0===d?"extscripturls":d,f){e.n=1;break}return window.__devfab.debug&&console.info("[devfab][extend][exturls] ext script is not enable"),e.a(2,Promise.resolve(!0));case 1:if(t){e.n=2;break}return window.__devfab.debug&&console.info("[devfab][extend][exturls] script data is null"),e.a(2,Promise.resolve(!0));case 2:if(y=null==t?void 0:t[v],p=Array.isArray(y)?y:[],p=(p=(r.getCache("localScripts")||[]).concat(p)).concat(window.__devfab__GLOBAL_EXT_SCRIPTS__||[]),null!==(a=r.getParams())&&void 0!==a&&a.selfExtUrls&&(p=p.concat([r.getParams().selfExtUrls])),null===(o=p)||void 0===o||!o.length){e.n=4;break}return p=g(new Set(p)),e.n=3,Promise.all(p.map(function(){var e=n(h().m(function e(t){return h().w(function(e){for(;;)if(0===e.n)return e.a(2,t)},e)}));return function(t){return e.apply(this,arguments)}}()));case 3:p=e.v;case 4:return t[v]=p,e.a(2,new Promise(function(e,t){Y.call(r,null==s?void 0:s.require,p,function(t){e(t)})}))}},e)}));return function(t,n,r){return e.apply(this,arguments)}}(),te=q,ne=C,re=I,ie=R;function ae(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.modelNameField,s=void 0===a?"cName":a,u=function(e){function t(){return i(this,t),r(this,t,arguments)}return c(t,e),o(t,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var r={};return(Array.isArray(e)?e:[]).forEach(function(e){var t,i,a=function(e,t){var n=(null==t?void 0:t.SimpleModel)||C,r=e.cControlType||e.component||e.controlType||e.ctrlType;return r=r.toLowerCase(),new n(e)}(e,n),o={model:a,meta:e,childModel:!0,modelName:e[s]};null==n||null===(t=n.onBeforeInitModel)||void 0===t||t.call(n,o),r[o.modelName]=o.model,null==n||null===(i=n.onAfterInitModel)||void 0===i||i.call(n,o)}),r}},{key:"initData",value:function(){Z.call(this,n)}}])}((null==n||null===(t=n.models)||void 0===t?void 0:t.ViewModel)||I);return u.prototype.modelType="ViewModel",u}function oe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,i=function(e,t){var n,r,i,a=new(ae(e,t)),o={model:a,meta:e};return null==t||null===(n=t.onBeforeInitModel)||void 0===n||n.call(t,o),o.model=a,null==a||null===(r=a.init)||void 0===r||r.call(a,e.models,e),null==t||null===(i=t.onAfterInitModel)||void 0===i||i.call(t,o),a}(e,t);return i.on("destroyVM",function(){var e,t;null===(e=i)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),i=null,window.devfab.debug&&console.info("[devfab][models][initVM]: destory vm ".concat((new Date).toString()))}),i.on("extendReady",n(h().m(function n(){var a;return h().w(function(n){for(;;)switch(n.n){case 0:return(a=[]).push(ee(e,i,t)),n.n=1,Promise.all(a);case 1:window.devfab.debug&&console.info("[devfab][models][initVM]: after vm init ".concat((new Date).toString())),null==r||r(i,e);case 2:return n.a(2)}},n)}))),i.initData(),i}export{te as BaseModel,ie as GridModel,ne as SimpleModel,re as ViewModel,oe as initViewModel,Y as loadScripts};
3
+ var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",a=n.toStringTag||"@@toStringTag";function o(n,r,a,o){var u=r&&r.prototype instanceof s?r:s,c=Object.create(u.prototype);return h(c,"_invoke",function(n,r,a){var o,s,u,c=0,l=a||[],f=!1,d={p:0,n:0,v:e,a:v,f:v.bind(e,4),d:function(t,n){return o=t,s=0,u=e,d.n=n,i}};function v(n,r){for(s=n,u=r,t=0;!f&&c&&!a&&t<l.length;t++){var a,o=l[t],v=d.p,h=o[2];n>3?(a=h===r)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=v&&((a=n<2&&v<o[1])?(s=0,d.v=r,d.n=o[1]):v<h&&(a=n<3||o[0]>r||r>h)&&(o[4]=n,o[5]=r,d.n=h,s=0))}if(a||n>1)return i;throw f=!0,r}return function(a,l,h){if(c>1)throw TypeError("Generator is already running");for(f&&1===l&&v(l,h),s=l,u=h;(t=s<2?e:u)||!f;){o||(s?s<3?(s>1&&(d.n=-1),v(s,u)):d.n=u:d.v=u);try{if(c=2,o){if(s||(a="next"),t=o[a]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+a+"' method"),s=1);o=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==i)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:f}}}(n,a,o),!0),c}var i={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(h(t={},r,function(){return this}),t),f=c.prototype=s.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,h(e,a,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,h(f,"constructor",c),h(c,"constructor",u),u.displayName="GeneratorFunction",h(c,a,"GeneratorFunction"),h(f),h(f,a,"Generator"),h(f,r,function(){return this}),h(f,"toString",function(){return"[object Generator]"}),(v=function(){return{w:o,m:d}})()}function h(e,t,n,r){var a=Object.defineProperty;try{a({},"",{})}catch(e){a=0}h=function(e,t,n,r){function o(t,n){h(e,t,function(e){return this._invoke(t,n,e)})}t?a?a(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},h(e,t,n,r)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,o,i,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){c=!0,a=e}finally{try{if(!u&&null!=n.return&&(i=n.return(),Object(i)!==i))return}finally{if(c)throw a}}return s}}(e,t)||b(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||b(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function b(t,n){if(t){if("string"==typeof t)return e(t,n);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var k=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this._data=Object.assign({},e)}},{key:"set",value:function(e,t){this._data[e]=t}},{key:"get",value:function(e){var t;return null===(t=this._data)||void 0===t?void 0:t[e]}},{key:"delete",value:function(e){delete this._data[e]}},{key:"clear",value:function(){this._data={}}}])}();k.create=function(e){return new k};var x=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){var t;this.__ASYNC_EXECUTE__=null===(t=null==e?void 0:e.__ASYNC_EXECUTE__)||void 0===t||t,this._events=new Map,this._firstevents=new Map}},{key:"on",value:function(e,t,n){var r=this._events.get(e);Array.isArray(r)||(r=[]),r.push({callback:t,context:n}),this._events.set(e,r)}},{key:"onFirst",value:function(e,t,n){var r=this._firstevents.get(e);Array.isArray(r)||(r=[]),r.splice(0,0,{callback:t,context:n}),this._firstevents.set(e,r)}},{key:"execute",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var a=this._events.get(e),o=this._firstevents.get(e);if(!a&&!o)return!0;var i=!0;return[].concat(g(o||[]),g(a||[])).forEach(function(e){if(!1!==i){var t=e.callback.apply(e.context||void 0,n);i=!1!==t&&i}}),i}},{key:"un",value:function(e,t){this._unEvents(e,t,this._events),this._unEvents(e,t,this._firstevents)}},{key:"_unEvents",value:function(e,t,n){if(e&&n.has(e))if(t){var r=n.get(e),a=null==r?void 0:r.findIndex(function(e){return e.callback===t});-1!==a&&(null==r||r.splice(a,1))}else n.delete(e)}},{key:"hasEvent",value:function(e){var t,n;return e?((null===(t=this._events.get(e))||void 0===t?void 0:t.length)||0)+((null===(n=this._firstevents.get(e))||void 0===n?void 0:n.length)||0):0}},{key:"fireEvent",value:function(e,t){this.execute("before".concat(e),t)&&(this.execute(e,t),this.execute("after".concat(e),t))}},{key:"_asyncExecute",value:function(e,t,n){for(var r,a=this,o=n.resolve,i=n.reject,s=n.args,u=!0,c=t||[],l=!1,f=function(t){var n,r=c[t];if(!1===u)return 0;if(l)return{v:void 0};if("development"===process.env.nodeEnv)n=r.callback.apply(r.context||a,s);else try{n=r.callback.apply(r.context||a,s)}catch(e){throw e.isAddedMsg||(e.message="(领域扩展事件执行失败,请打开控制台查看详细错误信息并修复):".concat(e.message)),e.isAddedMsg=!0,e}n instanceof Promise?(l=!0,(u=n).callbacks&&u.callbacks.push({reject:function(){u.reject(),t===c.length-1&&(null==i||i())},resolve:function(n){t===c.length-1?(s.length>1&&(s[0]=n),null==o||o(s)):a._asyncExecute(e,c.slice(t+1),{resolve:o,reject:i,args:s})}})):(u=!1!==n&&u,t===c.length-1&&(u?null==o||o(s):null==i||i()))},d=0;d<c.length&&0!==(r=f(d));d++)if(r)return r.v;return u}},{key:"_asyncPromiseExecute",value:function(e,t,n,r){var a=this._events.get(e),o=this._firstevents.get(e);if(!((Array.isArray(a)?a.length:a)||(Array.isArray(o)?o.length:o)))return null==t?void 0:t();var i=[].concat(g(o||[]),g(a||[]));return this._asyncExecute(e,i,{resolve:t,reject:n,args:r})}},{key:"promiseExecute",value:function(e,t){var n=this,r=e,a=1;if("boolean"==typeof e&&(r=t,a=2),r){for(var o=arguments.length,i=new Array(o>2?o-2:0),s=2;s<o;s++)i[s-2]=arguments[s];var u=2===a?i:[t].concat(i);if(u.length){var c,l=u.length-1,f=u[l];if("function"!=typeof f){if("object"!==m(f)||!f[0]||"function"!=typeof f[0]||!f[1]||"function"!=typeof f[1])return;c=f[1],f=f[0]}if(this.__ASYNC_EXECUTE__)return this._asyncPromiseExecute(r,function(e){f.apply(n,e)},function(){c&&"function"==typeof c&&c()},u);u.splice(l,1),u.unshift(r);var d=this.execute.apply(this,u);if(d instanceof Promise){var v=this;d.then(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];f.apply(v,t)},function(){c&&"function"==typeof c&&c()})}else if(!d)return void(c&&"function"==typeof c&&c())}}}},{key:"clear",value:function(){this._events.clear(),this._firstevents.clear()}}])}();function w(e){return e||!("undefined"==typeof window||!window.__devfab||!window.__devfab.debug)}function S(e){this.pathname="",this.query={};var t=e;this.init=function(){t||(t=location.search);var e=t.indexOf("?"),n=t.indexOf("#");if(e>=0){if(this.pathname=t.substr(0,e),(t=n<0?t.substr(e+1):t.substring(e+1,n)).length>0)for(var r=(t=t.replace(/\+/g," ")).split("&"),a=0,o=r.length;a<o;a++){var i=r[a]||"";if(i){var s=i.indexOf("="),u="",c="";s<0?c=u=window.decode(i):(u=window.decode(i.substr(0,s)),c=window.decode(i.substr(s+1))),this.query[u]=c}}}else this.pathname=t},this.set=function(e,t){this.query[e]=t},this.get=function(e){return this.query[e]},this.del=function(e){delete this.query[e]},this.has=function(e){return null!=this.query[e]},this.toStr=function(){var e=["?"];for(var t in this.query)e.push(encodeURIComponent(t)),e.push("="),e.push(encodeURIComponent(this.query[t])),e.push("&");return 1===e.length?"":(e.splice(e.length-1,1),e.join(""))},this.init()}function P(e,t){return!(!e||!t)&&e.toLowerCase()===t.toLowerCase()}function j(e,t){if(!t)return e;var n=[],r=new S(e);for(var a in t)r.get(a)||n.push("".concat(a,"=").concat(t[a]));if(!n.length)return e;var o=n.join("&");return e.indexOf("?")>=0?"".concat(e,"&").concat(o):"".concat(e,"?").concat(o)}x.create=function(e){return new x(e)};var C={_xhrs:[],_jsonps:{index:0},doRequest:function(e){var t,n=e.method||"GET",r=e.url;try{null!=e&&e.requestHeaders&&(t=e.requestHeaders,e.requestHeaders=void 0,delete e.requestHeaders)}catch(e){w()&&console.log('[devfab][ajax]: [doRequest]: options["requestHeaders"] ERR : ',e)}try{e.params&&e.params.requestHeaders&&(t=e.params.requestHeaders,e.params.requestHeaders=void 0,delete e.params.requestHeaders)}catch(e){w()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}var a=null;if(P(n,"get")||P(n,"delete")?r=j(r,e.params):(P(n,"post")||P(n,"put"))&&(a=JSON.stringify(e.params)),e.jsonp)return this.getJsonp(r,e.callback);var o=this.getXMLHttpRequest();if(o){var i;if(o.open(n,r,!1!==e.async),e.timeout&&(o.timeout=e.timeout,o.setRequestHeader("timeout",e.timeout),o.ontimeout=function(){C.onerror(this,e,"timeout")}),e.contentType){if(o.setRequestHeader("Content-Type",e.contentType),e.contentType.indexOf("x-www-form-urlencoded")>=0)a=null===(i=new URLSearchParams(e.params))||void 0===i?void 0:i.toString()}else e.dateType?a=e.params:o.setRequestHeader("Content-Type","application/json;charset=utf-8");try{if(t&&"[object Object]"===Object.prototype.toString.call(t))for(var s in t)o.setRequestHeader(s,t[s])}catch(e){w()&&console.log('[devfab][ajax]: [doRequest]: options.params["requestHeaders"] ERR : ',e)}o.withCredentials=null==e||!e.hasOwnProperty("withCredentials")||e.withCredentials,e.onBeforeRequest&&e.onBeforeRequest(o,a);try{o.send(a)}catch(t){return{error:"NetWorkError",options:e}}if(!1===e.async)return this.onreadystatechange(o,e);o.onreadystatechange=function(){C.onreadystatechange(this,e)}}},onreadystatechange:function(e,t){if(4===e.readyState){if(200===e.status){var n;try{if("blob"===t.responseType){var r=function(e){var t=e.xhr.getAllResponseHeaders(),n={};return t.split("\r\n").map(function(e){var t=p(e.split(": "),2),r=t[0],a=t[1];n[r]=a}),n}({xhr:e});n={code:e.status,data:{data:e.response,headers:r}}}else n=JSON.parse(e.responseText)}catch(n){C.onerror(e,t,e.responseText)}if(!1===t.async)return e.isBusy=!1,t.onAfterRequest&&t.onAfterRequest(n),C.parseAjaxResult(n,!1,null,null,t,e);C.parseAjaxResult(n,t.async,t.callback,t.context,t,e),t.onAfterRequest&&t.onAfterRequest(n)}else if(0===e.status)C.onerror(e,t,"The network connection has been disconnected. Please check the network status of the device and try.");else if(502===e.status||504===e.status)C.onerror(e,t,"An error has occurred with the service. Please try again later.");else{if(401!==e.status){var a={};try{a=JSON.parse(e.responseText)}catch(t){a={code:e.status,message:e.responseText}}return C.onerror(e,t,a)}C.onerror(e,t,"Login information has expired. Please log in again or contact technical staff.")}e.isBusy=!1}},onerror:function(e,t,n){var r="[devfab][ajax]: [onerror]: api error \n [code]: ".concat(e.status," \n [error]: ").concat(("object"===m(n)?JSON.stringify(n):n)||"空"," \n [url]: ").concat(t.url," \n [token]: ").concat(document.cookie);w()&&console.log(r);var a="object"===m(n)?n:{code:500,message:n};t.onAfterRequest&&t.onAfterRequest(a)},getXMLHttpRequest:function(){return this.createXMLHttpRequest()},createXMLHttpRequest:function(){return window.XMLHttpRequest?new XMLHttpRequest:window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):null},getJsonp:function(e,t){var n=e,r="callback"+this._jsonps.index++,a=document.createElement("script");this._jsonps[r]=function(e){try{t(e)}finally{document.body.removeChild(a)}},n+=-1===n.indexOf("?")?"?":"&callback=cb.rest.AjaxUtil._jsonps."+r,a.src=n,document.body.appendChild(a)},parseAjaxResult:function(e,t,n,r,a,o){if(e){if(!e.code)return!1===t?e:void(n&&n.call(r,null,e));if(200==e.code){if(!1===t)return{result:e.data};n&&n.call(r,null,e.data,e.message,e.errorDetail,e.code,e.displayCode&&e)}else{if(!1===t)return{error:e};n&&n.call(r,e)}}}};function A(e,t){this.init&&this.init(e),this.queryParams=t}A.create=function(e,t){return new A(e,t)},A.prototype.init=function(e){if(e)for(var t in this.config=e,this.config)this[t]=function(e){return function(t,n,r){return this.Do(e,t,n,null,r)}}(t),this["".concat(t,"Sync")]=function(e){return function(t){return this.Do(e,t,null,!1)}}(t)},A.prototype.Do=function(e,t,n,r,a){var o,i,s;if(this.config&&this.config[e]&&this.config[e].url){var u=this.config[e],c=u.url;this.queryParams||(this.queryParams={}),null!==(o=u.options)&&void 0!==o&&o.proxyServiceCode&&(this.queryParams.serviceCode=u.options.proxyServiceCode),null!==(i=u.options)&&void 0!==i&&i.billnum&&(this.queryParams.billnum=u.options.billnum),null!==(s=this.queryParams)&&void 0!==s&&s.serviceCode&&(c=j(c,this.queryParams));var l=c,f=Object.assign({},u.options);return f.method=u.method||"GET","function"==typeof t?(f.callback=t,f.context=a||f.context||this):f.params=t,n&&(f.callback=n,f.context=a||f.context||this),!1===r&&(f.async=!1),this.ajax(l,f)}},A.prototype.ajax=function(e,t){return function(e,t){return t.url=e,C.doRequest(t)}(e,t)};var O=function(){return i(function e(t){a(this,e),this._init(t)},[{key:"_init",value:function(e){this._data={};var t=[];if(e)for(var n in e)t.push(n);Object.assign(this._data,{components:[],propertyNames:t},e),this._data.cache=new k,this._data.events=new x}},{key:"_del_data",value:function(e){e&&delete this._data[e]}},{key:"_cls_data",value:function(){this._data.cache.clear(),this._data.events.clear(),this._data={components:[],propertyNames:[],cache:new k,events:new x}}},{key:"_set_data",value:function(e,t,n){if(e){if(n){var r=this._data.propertyNames||[];r.indexOf(e)<0&&r.push(e)}this._data[e]=t}}},{key:"_get_data",value:function(e){if(e)return this._data[e]}},{key:"getData",value:function(){return this._get_data("value")}},{key:"getState",value:function(e,t){var n;if(!t)return this._get_data(e);var r=(this._get_data("components")||[]).find(function(e){return e.ctrlName===t});return r?null===(n=r.getState)||void 0===n?void 0:n.call(r,e):this._get_data(e)}},{key:"setState",value:function(e,t,n){n||this._set_data(e,t,!0);var r={};r[e]=t,this.doPropertyChange("setState",r,n)}},{key:"doPropertyChange",value:function(e,t,n){var r=this,a=this._get_data("components")||[];if(!a.length)return a;var o=[];if(n){var i=a.find(function(e){return e.ctrlName===n});i&&!this.notifyComponent(i,e,t)&&o.push(i)}else a.forEach(function(n){r.notifyComponent(n,e,t)||o.push(n)});return o.length?o:void 0}},{key:"notifyComponent",value:function(e,t,n){return"function"==typeof e[t]&&(this.viewUpdater(e,t,n),!0)}},{key:"viewUpdater",value:function(e,t,n){if("setState"===t)e[t](n);else{var r=this.getCache("name");e[t](n,r)}}},{key:"get",value:function(e){return this._get_data(e)}},{key:"addComponent",value:function(e,t){if(e){t&&!e.ctrlName&&(e.ctrlName=t);var n=this._get_data("components")||[];n.indexOf(e)>=0||n.push(e)}}},{key:"removeComponent",value:function(e){var t=this._get_data("components")||[],n=t.indexOf(e);n<0||t.splice(n,1)}},{key:"_applyState",value:function(e,t,n){var r=this;n||this._set_data(e,t,!0);var a="set".concat(e.charAt(0).toUpperCase()).concat(e.slice(1)),o=this.doPropertyChange(a,t,n);if(o){var i={};i[e]=t,o.forEach(function(e){r.notifyComponent(e,"setState",i)})}}},{key:"getVisible",value:function(e){return this.getState("visible",e)}},{key:"setVisible",value:function(e,t){this._applyState("visible",e,t)}},{key:"getValue",value:function(){return this.getData()}},{key:"setValue",value:function(e,t,n){var r=this,a=this.getValue();if(e!==a){var o={value:e,oldValue:a},i=this._get_data("forceFireEvent");t||i?this.promiseExecute("beforeValueChange",o,[function(){r._set_data("value",e,!0),r._applyState("value",e,n),r.execute("afterValueChange",o)},function(){r._set_data("value",a,!0),r._applyState("value",a,n)}]):(this._set_data("value",e,!0),this._applyState("value",e,n))}}},{key:"getDisabled",value:function(e){return this.getState("disabled",e)}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"setParent",value:function(e){this.setCache("parent",e)}},{key:"getParent",value:function(){return this.getCache("parent")}},{key:"getRootParent",value:function(){for(var e=this.getParent();null!==(t=e)&&void 0!==t&&t.getParent();){var t;e=e.getParent()}return e}},{key:"setName",value:function(e){this.setCache("name",e)}},{key:"getName",value:function(){return this.getCache("name")}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getDirtyData",value:function(e){var t=this.getData();return!1!==e&&this._get_data("isDirty")||t!==this._get_data("originalData")?t:void 0}},{key:"clear",value:function(e){void 0===e?this._set_data("value",this._get_data("cDefaultValue")):e||this._set_data("value",void 0),this._del_data("isDirty"),this._del_data("checking"),this._del_data("checkMsg")}},{key:"on",value:function(e,t,n){this._get_data("events").on(e,t,n)}},{key:"onFirst",value:function(e,t,n){this._get_data("events").onFirst(e,t,n)}},{key:"execute",value:function(e){for(var t,n=arguments.length,r=new Array(n>1?n-1:0),a=1;a<n;a++)r[a-1]=arguments[a];return(t=this._get_data("events")).execute.apply(t,[e].concat(r))}},{key:"un",value:function(e,t){this._get_data("events").un(e,t)}},{key:"hasEvent",value:function(e){return this._get_data("events").hasEvent(e)}},{key:"fireEvent",value:function(e,t){this._get_data("events").fireEvent(e,t)}},{key:"promiseExecute",value:function(e,t){for(var n,r=arguments.length,a=new Array(r>2?r-2:0),o=2;o<r;o++)a[o-2]=arguments[o];(n=this._get_data("events")).promiseExecute.apply(n,[e,t].concat(a))}},{key:"setCache",value:function(e,t){this._get_data("cache").set(e,t)}},{key:"getCache",value:function(e){return this._get_data("cache").get(e)}},{key:"clearCache",value:function(e){this._get_data("cache").delete(e)}},{key:"setProxy",value:function(e){if(!(e instanceof A)){var t,n=this._get_data("__requestHeaders__");for(var r in e){var a,o,i;if(n&&(null===(a=e[r])||void 0===a||null===(a=a.options)||void 0===a||!a.requestHeaders))null!==(i=e[r])&&void 0!==i&&i.options||(e[r].options={}),e[r].options.requestHeaders=n;null!==(o=this.getProxy())&&void 0!==o&&o[r]&&w()&&console.warn("[devfab][baseModel.prototype.setProxy]: Proxy ".concat(r," already exists on the model. Please change the name of ").concat(r," and try again"))}return this._set_data("proxy",A.create(d(d({},(null===(t=this.getProxy())||void 0===t?void 0:t.config)||{}),e))),this.getProxy()}this._set_data("proxy",e)}},{key:"getProxy",value:function(){return this._get_data("proxy")}}])}(),E=function(){function e(){var t;a(this,e);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return s(t=r(this,e,[].concat(o)),"modelType","SimpleModel"),t}return c(e,O),i(e,[{key:"getDisabled",value:function(){return this.getState("disabled")}},{key:"setDisabled",value:function(e,t){this._applyState("disabled",e,t)}},{key:"getReadonly",value:function(){return this.getState("readonly")}},{key:"setReadonly",value:function(e,t){this._applyState("readonly",e,t)}}])}(),D=Array.isArray;function M(e){if(D(e))return e.map(M);if(e instanceof Date)return new Date(e.getTime());if(e&&"object"===m(e)){var t={};for(var n in e)t[n]=M(e[n]);return t}return e}function q(e,t,n){var r=this;this.promiseExecute("beforeQuery",{proxyConfig:e,queryParams:t},function(){var a=r,o=r.setProxy({queryData:e}),i=r._get_data("innerUsedAttrs").pageIndex,u={page:s(s({},r._get_data("innerUsedAttrs").pageSize,r.getPageSize()),i,r.getPageIndex())},c=Object.assign(t,u);r.setCache("proxyCache",{proxyConfig:e,params:c,callback:n});if(!1!==r.execute("beforeQueryData",c)){var l=M(c);o.queryData(l,function(e,t,r,a){if(!e){var o=t;this._set_data("dataSourceMode","remote");var i=function(e){if(!e)return[];if(D(e))return e;if(D(e.data))return e.data;if(D(e.records))return e.records;if(D(e.list))return e.list;if(D(e.rows))return e.rows;var t=e.data&&"object"===m(e.data)?e.data:e.result;return D(t)?t:t&&"object"===m(t)&&(t.records||t.list||t.rows||t.data)||[]}(o=Object.assign({},o));this.execute("afterQueryData",o),null==n||n.call(this,i)}},a)}})}function R(e){if(this.execute("beforeSetDataSource",e)){var t=this.getRowKeyField(),n={};e.forEach(function(e){n[e[t]]=e}),this._set_data("keyMap",n),this._set_data("dataSource",e,!0),this.doPropertyChange("setDataSource"),this.execute("afterSetDataSource",e)}}var I=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a(this,e);var o,i=d(d({},{columns:{},dataSource:[],rows:[],readOnly:!0,dataSourceMode:"local",columnMode:"local",editMode:"cell",rowKeyField:"id",cellState:{},rowState:{},showCheckBox:!1,multiple:!0,showRowNo:!0,pagination:!0,pageInfo:s(s(s({},(o={id:"_id",selected:"_selected",status:"_status",pageIndex:"pageNo",pageSize:"pageSize",pageCount:"total"}).pageIndex,1),o.pageSize,20),o.pageCount,0),innerUsedAttrs:o,multiRowModel:!1,editRowModels:{},loading:!1,params:{},originalKeyMap:{},defaultRowDatas:new Map}),n);D(i.dataSource)||(i.dataSource=[]),D(i.rows)||(i.rows=[]);var u=function(){return d({},(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).proxyConfig||{})}(n);return i.proxyConfig=u,i.dataSourceMode=n.dataSourceMode||i.dataSourceMode,s(t=r(this,e,[i]),"modelType","GridModel"),t.initColumns(i.columns),t.initPageInfo(n.cPage||n.page),t.afterInit(),t}return c(e,O),i(e,[{key:"afterInit",value:function(){this.execute("afterInit")}},{key:"initColumns",value:function(e){var t=function(e){var t={};return(D(e)?e:Object.keys(e||{}).map(function(t){var n;return d(d({},e[t]||{}),{},{field:(null===(n=e[t])||void 0===n?void 0:n.field)||t})})).forEach(function(e,n){if(e){var r=e.field||e.cFieldName||e.cName||"col_".concat(n);t[r]=d(d({},e),{},{field:r,label:e.label||e.title||e.cCaption||r,index:void 0===e.index?n:e.index})}}),t}(e);return this._set_data("columns",t,!0),t}},{key:"initPageInfo",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({},this.getPageInfo()),n=this._get_data("innerUsedAttrs").pageIndex,r=this._get_data("innerUsedAttrs").pageSize;t[n]=e.pageNo||e.pageIndex||t.pageIndex||1,t[r]=e.pageSize||t.pageSize||20,!1===this.get("pagination")&&(t[n]=-1),this._set_data("pageInfo",t)}},{key:"getRowKeyField",value:function(){return this._get_data("rowKeyField")}},{key:"isRemote",value:function(){return"remote"===this._get_data("dataSourceMode")}},{key:"getReadOnly",value:function(){return!!this._get_data("readOnly")}},{key:"setReadOnly",value:function(e){this._applyState("readOnly",!!e)}},{key:"setShowCheckbox",value:function(e){this._applyState("showCheckBox",!!e)}},{key:"setShowRowNo",value:function(e){this._applyState("showRowNo",!!e)}},{key:"getParams",value:function(){return d(d({},this.get("cParams")||{}),this._get_data("params")||{})}},{key:"setParams",value:function(e){this._set_data("params",e||{})}},{key:"getInnerUsedAttrs",value:function(e){var t=this._get_data("innerUsedAttrs");return e?t[e]:t}},{key:"getId",value:function(){return this.getInnerUsedAttrs("id")}},{key:"setDataSource",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;if("local"===this._get_data("dataSourceMode")){R(D(e)?e:[])}else{if(!this.execute("beforeProxyLoad",n))return;this.setPageIndex(1),q.call(this,e,n,function(e){R.call(t,e),null==r||r.call(t)})}}},{key:"reloadData",value:function(){var e=this,t=this.getCache("proxyCache");if(t){var n=t.proxyConfig,r=t.params,a=t.callback;q.call(this,n,r,function(t){null==a||a.call(e,t)})}else w()&&console.log("[devfab][GridModel] proxyConfig is null")}},{key:"getDataSource",value:function(){return this._get_data("dataSource")||[]}},{key:"getData",value:function(e){return e?this._get_data("rows"):this._get_data("dataSource")}},{key:"getAllData",value:function(){return this.getData(!0)}},{key:"clear",value:function(){this._set_data("dataSource",[],!0),this._set_data("rows",[],!0)}},{key:"getPageInfo",value:function(){return this._get_data("pageInfo")}},{key:"getPageIndex",value:function(){var e=this._get_data("innerUsedAttrs").pageIndex;return this.getPageInfo()[e]}},{key:"getPageSize",value:function(){var e=this._get_data("innerUsedAttrs").pageSize;return this.getPageInfo()[e]}},{key:"getTotalCount",value:function(){var e=this._get_data("innerUsedAttrs").pageCount;return this.getPageInfo()[e]}},{key:"setPageInfo",value:function(e){var t=this.getPageInfo();this._set_data("pageInfo",d(d({},t),e)),this.reloadData()}},{key:"setPageIndex",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s({},t,Math.max(1,e))))}}},{key:"setPageSize",value:function(e){if("number"==typeof e){var t=this._get_data("innerUsedAttrs").pageIndex,n=this._get_data("innerUsedAttrs").pageSize;this._set_data("pageInfo",d(d({},this.getPageInfo()),{},s(s({},n,Math.max(-1,e)),t,1)))}}},{key:"setTotalCount",value:function(e){var t=this._get_data("innerUsedAttrs").pageCount;this.getPageInfo()[t]=e}}])}(),T=function(){function e(){var t;a(this,e);for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return s(t=r(this,e,[].concat(o)),"modelType","ViewModel"),t}return c(e,O),i(e,[{key:"getParams",value:function(){return this._get_data("params")}},{key:"setParams",value:function(e){this._set_data("params",e,!0)}},{key:"set",value:function(e,t){t instanceof O&&(t.setParent(this),t.setName(e)),this._set_data(e,t,!0)}},{key:"setData",value:function(e){for(var t in e)this.addProperty(t,e[t])}},{key:"addProperty",value:function(e,t){var n=this.get(e);null!=n&&n.setData?n.setData(t):this.set(e,t)}},{key:"getData",value:function(){var e=this,t=this._get_data("propertyNames")||[],n={};return t.forEach(function(t){var r,a=e.get(t);a instanceof O&&!1!==a._get_data("needCollect")&&(n[t]=null===(r=a.getData)||void 0===r?void 0:r.call(a))}),n}},{key:"getAllData",value:function(e){var t=this,n=this._get_data("propertyNames")||[],r={};return n.forEach(function(n){var a,o=t.get(n);if(o instanceof O&&!1!==o._get_data("needCollect")&&(!e||!o._get_data("isGrid"))){var i=null===(a=o.getData)||void 0===a?void 0:a.call(o);void 0!==i&&(r[n]=i)}}),r}},{key:"removeProperty",value:function(e){var t=this._get_data("propertyNames")||[],n=t.indexOf(e);-1!==n&&t.splice(n,1),this._del_data(e)}},{key:"loadData",value:function(e){this.setCache("isLoadData",!0),this.clear(),this.setData(e),this.setDirty(!1),this.setCache("isLoadData",!1)}},{key:"clear",value:function(e){var t=this;(this._get_data("propertyNames")||[]).forEach(function(n){var r,a=t.get(n);a instanceof O&&!1!==a._get_data("needClear")&&(null===(r=a.clear)||void 0===r||r.call(a,e))})}},{key:"setDirty",value:function(e){e?this._set_data("isDirty",!0):(this._del_data("isDirty"),this._set_data("originalData",this.getData()))}},{key:"getGridModel",value:function(e){var t;if(e)return this.get(e);var n=this._get_data("gridModel");if(n)return n;var r=null===(t=this.getParams())||void 0===t?void 0:t.masterGridModelName;if(r)return this.get(r);for(var a=this._get_data("propertyNames"),o=0,i=a.length;o<i;o++){if((n=this.get(a[o]))instanceof I||"GridModel"==n.modelType)return this._set_data("gridModel",n),n}}},{key:"getGridModels",value:function(){for(var e=this._get_data("propertyNames"),t=[],n=0,r=e.length;n<r;n++){var a=this.get(e[n]);(a instanceof I||"GridModel"==a.modelType)&&t.push(a)}return t}},{key:"getGridFilterModel",value:function(e){return this.getGridModel(e).getCache("FilterViewModel")}}])}();function N(e,t,n,r,a){var o,i=t,s=n,u=r,c=a;Array.isArray(t)&&"function"==typeof n&&(i=void 0,s=t,u=n,c=r);var l=(null===(o=c)||void 0===o?void 0:o.viewModel)||this,f=(s=Array.isArray(s)?s:[]).join(",");if(!e||"function"!=typeof e.inject){var d,v=function(e){return{code:404,message:"params.fileRequire is required, the files: ".concat(e),data:[],warnings:[]}}(f);return w()&&console.error("[devfab][models][extend][loadScripts] ".concat(v.message)),null===(d=u)||void 0===d||d(v),v}return e.inject(i,s,function(e){var t;if(0==e.code&&Array.isArray(e.data))for(var n=0,r=e.data.length;n<r;n++){var a=e.data[n];if(a&&a.doAction)try{a.doAction("init",l)}catch(t){e.code=500,e.message="".concat(f," script execute error"),e.error=t;break}else try{var o;"function"==typeof(null===(o=c)||void 0===o?void 0:o.onFileBack)&&c.onFileBack(a,n)}catch(t){e.code=500,e.message="".concat(f," script customize execute error");break}}0!=e.code&&w()&&console.info("[devfab][models][extend][loadScripts] ".concat(f," \n [message]: ").concat(e.message," \n").concat(e.error?" \n [error]: ":""),e.error),null===(t=u)||void 0===t||t(e)})}function U(e){var t=this;window.__devfab&&window.__devfab.__debugger_initExtendJs;var n=e.fileRequire,r=e.extendScriptParams,a=e.readyEventName,o=void 0===a?"extendReady":a,i=r||{},s=i.enableJs,u=void 0!==s&&s,c=i.filepath,l=i.scriptUrl;if(!u)return w()&&console.info("[devfab][extend][js] not enable extend script"),void t.execute(o,t);if(!l)return w()&&console.info("[devfab][extend][js] extend script is not defined"),void t.execute(o,t);var f=c,d=[l];t.getEnv&&t.getEnv("everyCommonExtend")&&d.push(t.getEnv("everyCommonExtend")),N.call(t,n,f,d,function(e){t.execute(o,t,e)})}var H=function(){var e=n(v().m(function e(t,r,a){var o,i,s,u,c,l,f,d,h,y,p;return v().w(function(e){for(;;)switch(e.n){case 0:if(window.__devfab&&window.__devfab.__debugger_initExtJs,s=a.fileRequire,u=a.extendScriptParams,l=(c=u||{}).enableExtJs,f=void 0!==l&&l,d=c.exturlsField,h=void 0===d?"extscripturls":d,f){e.n=1;break}return w()&&console.info("[devfab][extend][exturls] ext script is not enable"),e.a(2,Promise.resolve(!0));case 1:if(t){e.n=2;break}return w()&&console.info("[devfab][extend][exturls] script data is null"),e.a(2,Promise.resolve(!0));case 2:if(y=null==t?void 0:t[h],p=Array.isArray(y)?y:[],p=(p=(r.getCache("localScripts")||[]).concat(p)).concat(window.__devfab__GLOBAL_EXT_SCRIPTS__||[]),null!==(o=r.getParams())&&void 0!==o&&o.selfExtUrls&&(p=p.concat([r.getParams().selfExtUrls])),null===(i=p)||void 0===i||!i.length){e.n=4;break}return p=g(new Set(p)),e.n=3,Promise.all(p.map(function(){var e=n(v().m(function e(t){return v().w(function(e){for(;;)if(0===e.n)return e.a(2,t)},e)}));return function(t){return e.apply(this,arguments)}}()));case 3:p=e.v;case 4:return t[h]=p,e.a(2,new Promise(function(e,t){N.call(r,s,p,function(t){e(t)})}))}},e)}));return function(t,n,r){return e.apply(this,arguments)}}(),G=O,F=E,L=T,V=I;function z(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n.modelNameField,s=void 0===o?"cName":o,u=function(e){function t(){return a(this,t),r(this,t,arguments)}return c(t,e),i(t,[{key:"init",value:function(e,t){var n=this.createModels(e,t);this.setData(n),this.setDirty(!1)}},{key:"createModels",value:function(e,t){var r={};return(Array.isArray(e)?e:[]).forEach(function(e){var t,a,o=function(e,t){var n=(null==t?void 0:t.SimpleModel)||E,r=e.cControlType||e.component||e.controlType||e.ctrlType;return r=r.toLowerCase(),new n(e)}(e,n),i={model:o,meta:e,childModel:!0,modelName:e[s]};null==n||null===(t=n.onBeforeInitModel)||void 0===t||t.call(n,i),r[i.modelName]=i.model,null==n||null===(a=n.onAfterInitModel)||void 0===a||a.call(n,i)}),r}},{key:"initData",value:function(){U.call(this,n)}}])}((null==n||null===(t=n.models)||void 0===t?void 0:t.ViewModel)||T);return u.prototype.modelType="ViewModel",u}function B(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,a=function(e,t){var n,r,a,o=new(z(e,t)),i={model:o,meta:e};return null==t||null===(n=t.onBeforeInitModel)||void 0===n||n.call(t,i),i.model=o,null==o||null===(r=o.init)||void 0===r||r.call(o,e.models,e),null==t||null===(a=t.onAfterInitModel)||void 0===a||a.call(t,i),o}(e,t);return a.on("destroyVM",function(){var e,t;null===(e=a)||void 0===e||null===(t=e.destroyVM)||void 0===t||t.call(e),a=null,w()&&console.info("[devfab][models][initVM]: destory vm ".concat((new Date).toString()))}),a.on("extendReady",n(v().m(function n(){var o;return v().w(function(n){for(;;)switch(n.n){case 0:return(o=[]).push(H(e,a,t)),n.n=1,Promise.all(o);case 1:w()&&console.info("[devfab][models][initVM]: after vm init ".concat((new Date).toString())),null==r||r(a,e);case 2:return n.a(2)}},n)}))),a.initData(),a}export{G as BaseModel,V as GridModel,F as SimpleModel,L as ViewModel,B as initViewModel,N as loadScripts};