@sankhyalabs/sankhyablocks 8.16.0-rc.1 → 8.16.0-rc.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. package/dist/cjs/{ConfigStorage-a343e418.js → ConfigStorage-e49214c6.js} +2 -2
  2. package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-77729a93.js} +7 -2
  3. package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
  4. package/dist/cjs/{IExporterProvider-597949f9.js → IExporterProvider-8c030a7e.js} +5 -5
  5. package/dist/cjs/{SnkFormConfigManager-166cbd1f.js → SnkFormConfigManager-beebf47a.js} +2 -2
  6. package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-cceebbae.js} +2 -2
  7. package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-29bb791c.js} +1 -1
  8. package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-d4873076.js} +1 -1
  9. package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-feb08214.js} +1 -1
  10. package/dist/cjs/loader.cjs.js +1 -1
  11. package/dist/cjs/{pesquisa-fetcher-680e198f.js → pesquisa-fetcher-a1d0353f.js} +1 -1
  12. package/dist/cjs/sankhyablocks.cjs.js +1 -1
  13. package/dist/cjs/snk-actions-button_4.cjs.entry.js +17 -14
  14. package/dist/cjs/snk-application.cjs.entry.js +7 -7
  15. package/dist/cjs/snk-attach.cjs.entry.js +5 -5
  16. package/dist/cjs/snk-crud.cjs.entry.js +5 -5
  17. package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -9
  18. package/dist/cjs/{snk-data-unit-04df81bf.js → snk-data-unit-c7dcfa19.js} +18 -10
  19. package/dist/cjs/snk-data-unit.cjs.entry.js +5 -5
  20. package/dist/cjs/snk-detail-view.cjs.entry.js +9 -9
  21. package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
  22. package/dist/cjs/snk-filter-bar.cjs.entry.js +19 -11
  23. package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
  24. package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
  25. package/dist/cjs/snk-form.cjs.entry.js +4 -4
  26. package/dist/cjs/snk-grid.cjs.entry.js +9 -9
  27. package/dist/cjs/{snk-guides-viewer-bdc41281.js → snk-guides-viewer-69ec61af.js} +5 -5
  28. package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
  29. package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
  30. package/dist/cjs/snk-simple-crud.cjs.entry.js +9 -10
  31. package/dist/cjs/snk-taskbar.cjs.entry.js +23 -1
  32. package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
  33. package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +1 -1
  34. package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
  35. package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
  36. package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
  37. package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -2
  38. package/dist/collection/components/snk-data-unit/snk-data-unit.js +16 -8
  39. package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +16 -8
  40. package/dist/collection/components/snk-grid/snk-grid.js +1 -1
  41. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -20
  42. package/dist/collection/components/snk-taskbar/snk-taskbar.js +64 -0
  43. package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +2 -2
  44. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -3
  45. package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -1
  46. package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
  47. package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
  48. package/dist/components/DataFetcher.js +8 -3
  49. package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
  50. package/dist/components/IExporterProvider.js +2 -2
  51. package/dist/components/SnkMessageBuilder.js +2 -2
  52. package/dist/components/snk-actions-button2.js +12 -9
  53. package/dist/components/snk-data-exporter2.js +2 -2
  54. package/dist/components/snk-data-unit2.js +18 -47
  55. package/dist/components/snk-detail-view2.js +1 -1
  56. package/dist/components/snk-exporter-email-sender2.js +1 -1
  57. package/dist/components/snk-filter-bar2.js +16 -8
  58. package/dist/components/snk-grid2.js +3 -3
  59. package/dist/components/snk-simple-crud2.js +3 -3
  60. package/dist/components/snk-taskbar2.js +24 -2
  61. package/dist/esm/{ConfigStorage-3806514e.js → ConfigStorage-e476378d.js} +2 -2
  62. package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-773a3e4b.js} +8 -3
  63. package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
  64. package/dist/esm/{IExporterProvider-63a188b6.js → IExporterProvider-f86019db.js} +6 -6
  65. package/dist/esm/{SnkFormConfigManager-31b24066.js → SnkFormConfigManager-298cd647.js} +2 -2
  66. package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-ae87b754.js} +2 -2
  67. package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-a411f73c.js} +1 -1
  68. package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-3d2ec959.js} +1 -1
  69. package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-e0382e5a.js} +1 -1
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/{pesquisa-fetcher-03c8f919.js → pesquisa-fetcher-a87445a0.js} +1 -1
  72. package/dist/esm/sankhyablocks.js +1 -1
  73. package/dist/esm/snk-actions-button_4.entry.js +17 -14
  74. package/dist/esm/snk-application.entry.js +7 -7
  75. package/dist/esm/snk-attach.entry.js +5 -5
  76. package/dist/esm/snk-crud.entry.js +5 -5
  77. package/dist/esm/snk-data-exporter.entry.js +9 -9
  78. package/dist/esm/{snk-data-unit-8eec78bd.js → snk-data-unit-3276e55e.js} +18 -10
  79. package/dist/esm/snk-data-unit.entry.js +5 -5
  80. package/dist/esm/snk-detail-view.entry.js +9 -9
  81. package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
  82. package/dist/esm/snk-filter-bar.entry.js +19 -11
  83. package/dist/esm/snk-filter-modal-item.entry.js +3 -3
  84. package/dist/esm/snk-form-config.entry.js +2 -2
  85. package/dist/esm/snk-form.entry.js +4 -4
  86. package/dist/esm/snk-grid.entry.js +9 -9
  87. package/dist/esm/{snk-guides-viewer-dda0fede.js → snk-guides-viewer-43f21b03.js} +5 -5
  88. package/dist/esm/snk-guides-viewer.entry.js +7 -7
  89. package/dist/esm/snk-personalized-filter.entry.js +3 -3
  90. package/dist/esm/snk-simple-crud.entry.js +9 -10
  91. package/dist/esm/snk-taskbar.entry.js +23 -1
  92. package/dist/sankhyablocks/{p-fe79f83a.js → p-091ce761.js} +1 -1
  93. package/dist/sankhyablocks/{p-913a9979.js → p-0cd3c0a9.js} +1 -1
  94. package/dist/sankhyablocks/{p-045eae4d.entry.js → p-162b9a59.entry.js} +2 -2
  95. package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
  96. package/dist/sankhyablocks/{p-df5451c7.js → p-181975f1.js} +1 -1
  97. package/dist/sankhyablocks/p-18ed15f4.entry.js +1 -0
  98. package/dist/sankhyablocks/p-1a21b61a.entry.js +1 -0
  99. package/dist/sankhyablocks/p-1e596b15.entry.js +1 -0
  100. package/dist/sankhyablocks/{p-fa4d8cb4.js → p-1f35c795.js} +1 -1
  101. package/dist/sankhyablocks/{p-af8efd95.js → p-25f1fc39.js} +1 -1
  102. package/dist/sankhyablocks/{p-62ba211a.entry.js → p-2e9c764c.entry.js} +1 -1
  103. package/dist/sankhyablocks/{p-52920496.js → p-3287a6cc.js} +1 -1
  104. package/dist/sankhyablocks/{p-7505da04.entry.js → p-42f7b05d.entry.js} +1 -1
  105. package/dist/sankhyablocks/p-4e1b47a4.js +1 -0
  106. package/dist/sankhyablocks/{p-b05d8893.entry.js → p-53412c1d.entry.js} +1 -1
  107. package/dist/sankhyablocks/p-594bc21d.js +1 -0
  108. package/dist/sankhyablocks/p-5b26cc7c.entry.js +1 -0
  109. package/dist/sankhyablocks/{p-2a408684.js → p-5f016aed.js} +1 -1
  110. package/dist/sankhyablocks/p-6d55957a.js +1 -0
  111. package/dist/sankhyablocks/p-7b8f7242.entry.js +1 -0
  112. package/dist/sankhyablocks/p-7c4aabe2.js +1 -0
  113. package/dist/sankhyablocks/p-7dd49d15.js +1 -0
  114. package/dist/sankhyablocks/p-92ed1d24.entry.js +1 -0
  115. package/dist/sankhyablocks/{p-450c60e4.entry.js → p-939e15d3.entry.js} +1 -1
  116. package/dist/sankhyablocks/{p-47db7e88.entry.js → p-9dfda04a.entry.js} +1 -1
  117. package/dist/sankhyablocks/p-aa5b3b2c.entry.js +1 -0
  118. package/dist/sankhyablocks/{p-7a85fd49.entry.js → p-aa6d510d.entry.js} +1 -1
  119. package/dist/sankhyablocks/{p-2c68b3ae.entry.js → p-bd008859.entry.js} +1 -1
  120. package/dist/sankhyablocks/{p-c1d57831.entry.js → p-fd8a58ff.entry.js} +1 -1
  121. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  122. package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
  123. package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -0
  124. package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +1 -0
  125. package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +0 -4
  126. package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
  127. package/dist/types/components.d.ts +10 -2
  128. package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
  129. package/package.json +2 -2
  130. package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
  131. package/dist/sankhyablocks/p-3a212712.js +0 -1
  132. package/dist/sankhyablocks/p-46d38387.entry.js +0 -1
  133. package/dist/sankhyablocks/p-4e5e1313.entry.js +0 -1
  134. package/dist/sankhyablocks/p-547eeac8.entry.js +0 -1
  135. package/dist/sankhyablocks/p-75e674ed.entry.js +0 -1
  136. package/dist/sankhyablocks/p-7a337364.js +0 -1
  137. package/dist/sankhyablocks/p-7b08d0f8.entry.js +0 -1
  138. package/dist/sankhyablocks/p-9863d682.js +0 -1
  139. package/dist/sankhyablocks/p-d6e26ea8.entry.js +0 -1
  140. package/dist/sankhyablocks/p-dc7c9047.js +0 -1
  141. package/dist/sankhyablocks/p-e549f7d1.js +0 -1
  142. package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
  143. package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -1 +1 @@
1
- import{r as i,c as e,h as t,F as s}from"./p-d2d301a6.js";import{Action as r,ElementIDUtils as a}from"@sankhyalabs/core";import{S as n}from"./p-2a408684.js";import{buildFormMetadata as d,FormMetadata as o}from"@sankhyalabs/ezui/dist/collection/utils/form";import{o as h,T as l,b as u}from"./p-c2495304.js";import{T as c}from"./p-7e7a7473.js";import{d as v}from"./p-b0ef4383.js";import"./p-dc7c9047.js";import"./p-af8efd95.js";import{P as g}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-fe79f83a.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{SelectionMode as m}from"@sankhyalabs/core/dist/dataunit/DataUnit";const k="__FORM:",f=class{constructor(t){i(this,t),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={}}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){const t=null==i?void 0:i.selectedRecord,s=null==e?void 0:e.selectedRecord;(null==t?void 0:t.__record__id__)!==(null==s?void 0:s.__record__id__)&&this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected())}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async findField(){await h(this._moreOptions,this._fieldSearch)}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,t){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:t})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){this._container.focus()}exitViewer(){this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===c.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=d(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),t=this.dataUnit.getSelectedRecord(),s=!t||this.dataUnit.isNewRecord(t.__record__id__),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&s&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=o.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}getTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular"}loadTaskbarProcessor(){var i;const e=this.getTaskBarId(),t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const s=["PREVIOUS","NEXT","DIVIDER","ATTACH","CLONE","REMOVE","MORE_OPTIONS","ACTIONS_BUTTON","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==g.SECONDARY?s.unshift("INSERT"):s.push("INSERT");const r=this.getInvisibleButtons();this._taskbarProcessor=new l({"snkGuideViewer.regular":s,"snkGuideViewer.finish_edition":["CANCEL","SAVE"]}),this._taskbarProcessor.process(e,this.taskbarManager,this.dataState,t,r)}getInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===m.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}static updateContentCard(i,e,t,s){return s.saveCardState(i,e,t)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return t(s,null,Array.from(r.entries()).filter((([e,t])=>(null==t?void 0:t.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,s])=>{var r,a;const n=i.formMetadata.getSheet(e);if(null!=n)return t("snk-form-view",{levelPath:i.levelPath,label:n.label,name:e,fields:n.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==s?void 0:s.presentation),fixed:null==s?void 0:s.fixed,summaryFields:null===(a=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps})})))}wrapDetail(i,e){if(0===i.length)return e;const s=i.pop(),r=o.getDetailName(s);return r?this.wrapDetail(i,t("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const t=i.map((i=>o.getDetailName(i)));return`${this.entityPath}/${t.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,s,r,a;if(!this.selectedGuide)return;const n=this.selectedGuide.id;let d;const h=n.split("::"),l=h.pop(),u=o.getDetailName(l);let c=n;if(u||h.length>0){let e,s;if(n.includes(k)){[c,e]=n.split(k);const t=(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)||0;s=t>1?this._breadcrumbItems[t-2]:this.selectedGuide}else s=this.selectedGuide;d=this.wrapDetail(h,t("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(h,u),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:u,selectedForm:e,branchGuide:s,guideItemPath:this._breadcrumbItems,key:`detail${c}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders}))}else{const i=this.selectedGuide.id,o=this._masterFormMetadata.getSheet(i);if(o){const h=null===(s=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===s?void 0:s.get(i);d=t("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(a=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(i),name:i,label:o.label,fields:o.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:n,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps},this.presentationMode==g.SECONDARY&&this.buildTaskBar())}}return d}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))]}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}componentWillLoad(){if(null==this.resourceID)throw new Error("Erro interno: resourceID não informado");this._configManager=new n(this.configName,this.resourceID,(i=>this.masterFormConfig=i)),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}getFieldsSearch(i,e){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._moreOptions=i,i.addEventListener("taskbarActionsButtonDisconnected",(()=>this._hasToCreateFieldSearch=!0)),this._fieldSearch=u(e,(({argument:i})=>this.fieldsOptionLoader(i)),(e=>this.onSelectField(e,i)))),this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(this.dataUnit,i).map((i=>({value:i.name,label:i.label}))))}onSelectField(i,e){if(null==i)return;this._fieldToGetFocus=i.value;const t=this.getGuideName(i.value);t!==this.selectedGuide.id&&this.changeGuideHandler(t),e.hideActions()}getActionsList(){return[{value:"",label:this.getMessage("snkCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,e)=>this.getFieldsSearch(i,e)}].concat(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions?this.taskbarManager.getMoreOptions(this.getTaskBarId(),this.configName,this.dataState,this.actionsList):this.actionsList)}buildTaskBar(){var i;return t("div",{class:"snk-guides-viewer__header-taskbar "+(this.presentationMode!=g.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},t("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.getActionsList(),messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit,resourceID:this.resourceID,customSlotId:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS",alignRigth:!0},t("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"})))}async dataUnitActionHandler(i){var e;if(i.type===r.FIELD_INVALIDATED){const t=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(t),await this.openGuideNavigator(t)}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var t;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(t=i.badge)&&void 0!==t?t:null}getGuideName(i){var e;for(const t of this._masterFormMetadata.getAllSheets()){const s=null===(e=t[1])||void 0===e?void 0:e.fields;for(const e of s)if(e.name===i)return t[0]}return""}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}render(){var i,e;if(null!=this._formEditorConfigManager)return t("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null});if(!this.dataUnit||!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const s=this._guides&&this._guides.length>1;return t("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabindex:-1},t("div",{class:"ez-row snk-guides-viewer__header"},t("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},t("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),t("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},t("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getMessage("snkCrud.title")),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&t("div",{class:"ez-margin-top--extra-small"},t("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=g.SECONDARY&&this.buildTaskBar()),t("div",{class:"snk-guides-viewer__container"},s?t("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):t("div",null),t("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps}),this.getContent())),t("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
1
+ import{r as i,c as e,h as t,F as s}from"./p-d2d301a6.js";import{Action as r,ElementIDUtils as a}from"@sankhyalabs/core";import{S as n}from"./p-5f016aed.js";import{buildFormMetadata as d,FormMetadata as o}from"@sankhyalabs/ezui/dist/collection/utils/form";import{o as h,T as l,b as u}from"./p-c2495304.js";import{T as c}from"./p-7e7a7473.js";import{d as v}from"./p-b0ef4383.js";import"./p-594bc21d.js";import"./p-25f1fc39.js";import{P as g}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{SelectionMode as m}from"@sankhyalabs/core/dist/dataunit/DataUnit";const k="__FORM:",f=class{constructor(t){i(this,t),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this.formItemsReady=e(this,"formItemsReady",7),this._guideBuilders=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.canEdit=!0,this.presentationMode=void 0,this.resourceID=void 0,this.detailTaskbarCustomContainerId=void 0,this.formLegacyConfigName=void 0,this._hasToCreateFieldSearch=!0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0,this._fieldToGetFocus=void 0,this._customEditors=void 0,this._customRenders=void 0,this._fieldsProps={}}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){const t=null==i?void 0:i.selectedRecord,s=null==e?void 0:e.selectedRecord;(null==t?void 0:t.__record__id__)!==(null==s?void 0:s.__record__id__)&&this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(this.noGuideSelected())}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}async findField(){await h(this._moreOptions,this._fieldSearch)}async addCustomEditor(i,e){this._customEditors=Object.assign(Object.assign({},this._customEditors),{[i]:e})}async addGridCustomRender(i,e){this._customRenders=Object.assign(Object.assign({},this._customRenders),{[i]:e})}async setFieldProp(i,e,t){const s={[i]:Object.assign(Object.assign({},this._fieldsProps[i]),{[e]:t})};this._fieldsProps=Object.assign(Object.assign({},this._fieldsProps),s)}async setFocus(){this._container.focus()}exitViewer(){this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===c.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){f.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataUnit)))}getMessage(i){return this.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=d(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),t=this.dataUnit.getSelectedRecord(),s=!t||this.dataUnit.isNewRecord(t.__record__id__),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&s&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),r.push(e)})),this._guides=r,this._guideNavigator&&this._guideNavigator.updateItem(this._guides),i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=o.getDetailName(i)}updateGuide(i){this._guideBuilders.set(i.id,i);const e=i.buildGuideItem(this._guideBuilders);this._guideNavigator&&(this._guideNavigator.updateItem(e).then((()=>{this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))})),this._guides=this._guides.map((i=>i.id===e.id?Object.assign(Object.assign(Object.assign({},i),e),void 0!==e.children?{}:{children:void 0}):i)))}getTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular"}loadTaskbarProcessor(){var i;const e=this.getTaskBarId(),t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(i=this.dataState)||void 0===i?void 0:i.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const s=["PREVIOUS","NEXT","DIVIDER","ATTACH","CLONE","REMOVE","MORE_OPTIONS","ACTIONS_BUTTON","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==g.SECONDARY?s.unshift("INSERT"):s.push("INSERT");const r=this.getInvisibleButtons();this._taskbarProcessor=new l({"snkGuideViewer.regular":s,"snkGuideViewer.finish_edition":["CANCEL","SAVE"]}),this._taskbarProcessor.process(e,this.taskbarManager,this.dataState,t,r)}getInvisibleButtons(){const i=[];return this.dataState&&this.dataState.selectionInfo.mode===m.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}static updateContentCard(i,e,t,s){return s.saveCardState(i,e,t)}static buildFixedForms(i){var e;const r=null===(e=i.formConfig)||void 0===e?void 0:e.cardsState;if(null!=r)return t(s,null,Array.from(r.entries()).filter((([e,t])=>(null==t?void 0:t.fixed)&&e!=i.selectedForm)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([e,s])=>{var r,a;const n=i.formMetadata.getSheet(e);if(null!=n)return t("snk-form-view",{levelPath:i.levelPath,label:n.label,name:e,fields:n.fields,formMetadata:i.formMetadata,dataUnit:i.dataUnit,recordsValidator:i.recordsValidator,contracted:"CONTRACTED"===(null==s?void 0:s.presentation),fixed:null==s?void 0:s.fixed,summaryFields:null===(a=null===(r=i.formConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(e),fieldToFocus:i.fieldToFocus,key:e,onSnkRequestClearFieldToFocus:()=>{var e;return null===(e=i.onRequestClearFieldToFocus)||void 0===e?void 0:e.call(i)},customEditors:i.propsCustomEditor,fieldsProps:i.fieldsProps})})))}wrapDetail(i,e){if(0===i.length)return e;const s=i.pop(),r=o.getDetailName(s);return r?this.wrapDetail(i,t("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const t=i.map((i=>o.getDetailName(i)));return`${this.entityPath}/${t.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,s,r,a;if(!this.selectedGuide)return;const n=this.selectedGuide.id;let d;const h=n.split("::"),l=h.pop(),u=o.getDetailName(l);let c=n;if(u||h.length>0){let e,s;if(n.includes(k)){[c,e]=n.split(k);const t=(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)||0;s=t>1?this._breadcrumbItems[t-2]:this.selectedGuide}else s=this.selectedGuide;d=this.wrapDetail(h,t("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(h,u),onSnkDetailGuidesChange:i=>this.updateGuide(i.detail),entityName:u,selectedForm:e,branchGuide:s,guideItemPath:this._breadcrumbItems,key:`detail${c}`,canEdit:this.canEdit,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail),resourceID:this.resourceID,taskbarCustomContainerId:this.detailTaskbarCustomContainerId,customEditors:this._customEditors,customRenders:this._customRenders}))}else{const i=this.selectedGuide.id,o=this._masterFormMetadata.getSheet(i);if(o){const h=null===(s=null===(e=this.masterFormConfig)||void 0===e?void 0:e.cardsState)||void 0===s?void 0:s.get(i);d=t("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(a=null===(r=this.masterFormConfig)||void 0===r?void 0:r.summary)||void 0===a?void 0:a.get(i),name:i,label:o.label,fields:o.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,key:n,onSnkRequestClearFieldToFocus:()=>this.clearFieldToFocusHandler(),customEditors:this._customEditors,fieldsProps:this._fieldsProps},this.presentationMode==g.SECONDARY&&this.buildTaskBar())}}return d}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})),this.resetGuideBadge(i)}changeGuideHandler(i){var e;null===(e=this._guideNavigator)||void 0===e||e.selectGuide(i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}resetGuideBadge(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>this.canClearGuideBadge(e,i.id)?Object.assign(Object.assign({},e),{badge:null}):e))]}canClearGuideBadge(i,e){return i.id===e||this.isIncludedInChildrenList(i,e)}isIncludedInChildrenList(i,e){return this.hasChildren(i)&&this.getChildrenIdList(i).includes(e)}hasChildren(i){return i.children&&Array.isArray(i.children)}getChildrenIdList(i){return i.children.map((i=>i.id))}getConfigViewMode(){return v.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===v.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}noGuideSelected(){var i;return void 0===this.selectedGuide||"__main"===(null===(i=this.selectedGuide)||void 0===i?void 0:i.id)}addFormLegacyConfigName(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}componentWillLoad(){if(null==this.resourceID)throw new Error("Erro interno: resourceID não informado");this._configManager=new n(this.configName,this.resourceID,(i=>this.masterFormConfig=i)),this.addFormLegacyConfigName(),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}getFieldsSearch(i,e){return(null==this._fieldSearch||this._hasToCreateFieldSearch)&&(this._hasToCreateFieldSearch=!1,this._moreOptions=i,i.addEventListener("taskbarActionsButtonDisconnected",(()=>this._hasToCreateFieldSearch=!0)),this._fieldSearch=u(e,(({argument:i})=>this.fieldsOptionLoader(i)),(e=>this.onSelectField(e,i)))),this._fieldSearch}fieldsOptionLoader(i){return Promise.resolve(this._configManager.getFieldsList(this.dataUnit,i).map((i=>({value:i.name,label:i.label}))))}onSelectField(i,e){if(null==i)return;this._fieldToGetFocus=i.value;const t=this.getGuideName(i.value);t!==this.selectedGuide.id&&this.changeGuideHandler(t),e.hideActions()}getActionsList(){return[{value:"",label:this.getMessage("snkCrud.findColumn"),disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,e)=>this.getFieldsSearch(i,e)}].concat(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions?this.taskbarManager.getMoreOptions(this.getTaskBarId(),this.configName,this.dataState,this.actionsList):this.actionsList)}buildTaskBar(){var i;return t("div",{class:"snk-guides-viewer__header-taskbar "+(this.presentationMode!=g.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},t("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.getActionsList(),messagesBuilder:this.messagesBuilder,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit,resourceID:this.resourceID,customSlotId:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS",alignRigth:!0},t("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"})))}async dataUnitActionHandler(i){var e;if(i.type===r.FIELD_INVALIDATED){const t=this.getGuideName(null===(e=i.payload)||void 0===e?void 0:e.fieldName);await this.addErrorBadgeToGuide(t),await this.openGuideNavigator(t)}}async addErrorBadgeToGuide(i){var e;this._guides=[...null===(e=this._guides)||void 0===e?void 0:e.map((e=>Object.assign(Object.assign({},e),{badge:this.getBadge(e,i)})))]}async openGuideNavigator(i){this.selectedGuide.id!==i&&await this._guideNavigator.openGuideNavidator()}getBadge(i,e){var t;return this.selectedGuide.id===e?null:e===i.id?"error":null!==(t=i.badge)&&void 0!==t?t:null}getGuideName(i){var e;for(const t of this._masterFormMetadata.getAllSheets()){const s=null===(e=t[1])||void 0===e?void 0:e.fields;for(const e of s)if(e.name===i)return t[0]}return""}componentDidLoad(){this.dataUnit.subscribe(this.dataUnitActionHandler.bind(this))}render(){var i,e;if(null!=this._formEditorConfigManager)return t("snk-form-config",{ref:i=>this._container=i,tabindex:-1,dataUnit:this._formEditorDataUnit,messagesBuilder:this.messagesBuilder,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null});if(!this.dataUnit||!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const s=this._guides&&this._guides.length>1;return t("section",{class:"snk-guides-viewer",ref:i=>this._container=i,tabindex:-1},t("div",{class:"ez-row snk-guides-viewer__header"},t("div",{class:"snk-guides-viewer__header-breadcrumb ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},t("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),t("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},t("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getMessage("snkCrud.title")),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&t("div",{class:"ez-margin-top--extra-small"},t("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=g.SECONDARY&&this.buildTaskBar()),t("div",{class:"snk-guides-viewer__container"},s?t("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzSelectionChange:i=>this.updateSelectedGuideHandler(i.detail)}):t("div",null),t("div",{class:"snk-guides-viewer__detail-container"},f.buildFixedForms({formConfig:this.masterFormConfig,formMetadata:this._masterFormMetadata,selectedForm:null===(e=this.selectedGuide)||void 0===e?void 0:e.id,dataUnit:this.dataUnit,recordsValidator:this.recordsValidator,fieldToFocus:this._fieldToGetFocus,onRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this),propsCustomEditor:this._customEditors,fieldsProps:this._fieldsProps}),this.getContent())),t("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),messagesBuilder:this.messagesBuilder,onOpenConfig:i=>this.openConfig(i.detail),resourceID:this.resourceID}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};f.style=".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__header-breadcrumb.sc-snk-guides-viewer{width:25%;display:flex}.snk-guides-viewer__header-taskbar.sc-snk-guides-viewer{width:75%}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";export{f as S}
@@ -1,4 +1,4 @@
1
- import{DataType as e,ApplicationContext as t}from"@sankhyalabs/core";import{d as i,D as n}from"./p-dc7c9047.js";class r{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",i.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
1
+ import{DataType as e,ApplicationContext as t}from"@sankhyalabs/core";import{d as i,D as n}from"./p-594bc21d.js";class r{constructor(){this._defaultPageSize=100,this._templateByQuery=new Map,this._searchListenersByDataUnit=new Map,this.buldTemplates()}buldTemplates(){this._templateByQuery.set("search",i.gql`query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
2
2
  $queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
3
3
  value
4
4
  label
@@ -1 +1 @@
1
- import{r as i,c as t,h as s,g as h}from"./p-d2d301a6.js";import{ElementIDUtils as o}from"@sankhyalabs/core";import{S as a}from"./p-2a408684.js";import{R as n}from"./p-688dcb4c.js";import"./p-52920496.js";import"./p-df5451c7.js";import"./p-dc7c9047.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";const e=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}closeConfig(){this.hideConfig()}dataunitReady(){o.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await n.getResourceID()),this._configManager=new a(this.configName,this.resourceID),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataState.insertionMode,this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return h(this)}};e.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";export{e as snk_form}
1
+ import{r as i,c as t,h as s,g as a}from"./p-d2d301a6.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{S as o}from"./p-5f016aed.js";import{R as n}from"./p-688dcb4c.js";import"./p-3287a6cc.js";import"./p-181975f1.js";import"./p-594bc21d.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";const e=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}closeConfig(){this.hideConfig()}dataunitReady(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await n.getResourceID()),this._configManager=new o(this.configName,this.resourceID),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataState.insertionMode,this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return a(this)}};e.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";export{e as snk_form}
@@ -1,4 +1,4 @@
1
- import{R as e,F as t}from"./p-df5451c7.js";import{F as i}from"./p-ff1990ad.js";import{ObjectUtils as s}from"@sankhyalabs/core";import{d as r,D as a}from"./p-dc7c9047.js";var n;function l(e,t){if(null==e)return e;if(e instanceof Date)return e.toISOString();if("object"==typeof e){if(e instanceof Array)return e.map((e=>l(i.MULTI_LIST===t?function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(i[s[r]]=e[s[r]])}return i}(e,["label"]):e)));{const i=Object.assign({},e);return Object.keys(e).forEach((s=>{void 0!==e[s]?i[s]=l(e[s],t):delete i[s]})),i}}return e}class o{constructor(){this.templateByQuery=new Map,this.buildTemplates()}resolveURI(e,t){let i="filter-assistent-config://"+e;return t&&(i+="."+t),i}buildTemplates(){this.templateByQuery.set("fetchFilterFields",r.gql`
1
+ import{R as e,F as t}from"./p-181975f1.js";import{F as i}from"./p-ff1990ad.js";import{ObjectUtils as s}from"@sankhyalabs/core";import{d as r,D as a}from"./p-594bc21d.js";var n;function l(e,t){if(null==e)return e;if(e instanceof Date)return e.toISOString();if("object"==typeof e){if(e instanceof Array)return e.map((e=>l(i.MULTI_LIST===t?function(e,t){var i={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(s=Object.getOwnPropertySymbols(e);r<s.length;r++)t.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(e,s[r])&&(i[s[r]]=e[s[r]])}return i}(e,["label"]):e)));{const i=Object.assign({},e);return Object.keys(e).forEach((s=>{void 0!==e[s]?i[s]=l(e[s],t):delete i[s]})),i}}return e}class o{constructor(){this.templateByQuery=new Map,this.buildTemplates()}resolveURI(e,t){let i="filter-assistent-config://"+e;return t&&(i+="."+t),i}buildTemplates(){this.templateByQuery.set("fetchFilterFields",r.gql`
2
2
  query($name: String!) {
3
3
  $queryAlias$: fetchFilterFields(name: $name){
4
4
  currentLink {
@@ -1 +1 @@
1
- import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnit as l}from"@sankhyalabs/core";import{D as h}from"./p-dc7c9047.js";import"./p-af8efd95.js";import"./p-30cf616e.js";import{S as d}from"./p-21749402.js";import{P as c,b as u,c as v,d as m,D as A,I as O}from"./p-fe79f83a.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{d as p}from"./p-b0ef4383.js";import{A as w}from"./p-913a9979.js";import{T as I}from"./p-7e7a7473.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";class _{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(d.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",k="AnexoSistemaSP.excluir",y="AnexoSistemaSP.baixar";class b{constructor(t,i,e){var a;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(d.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(d.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(a=window.workspace)||void 0===a?void 0:a.resourceID)}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:k,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(k,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:y,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(y,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class f{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(c.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const E=a.getContextValue("__SNK__APPLICATION__"),N=t=>{var i,e;return null===(e=null===(i=null==E?void 0:E.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},g={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},C={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:N("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:N("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:N("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:N("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:N("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class P{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(C)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}let e=u(this._records,t,i.filters);return e=v(e,t,i.sort),Promise.resolve({records:e,paginationInfo:m(e,i.offset,i.limit)})}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===d.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(w.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const T=a.getContextValue("__SNK__APPLICATION__"),L=t=>{var i,e;return null===(e=null===(i=null==T?void 0:T.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},R={DOWNLOAD:{hint:L("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:L("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[I.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(I.REFRESH),1);const{selectedRecord:a}=i||{},s=(null==a?void 0:a.LINK)?R.LINK:R.DOWNLOAD;e.splice(e.indexOf(I.DIVIDER)+1,0,I.REMOVE,s,I.DIVIDER);const n=Array.from(new Set(e.filter((t=>t!==I.CLONE))));return n.splice(n.indexOf(s)+1,0,I.DIVIDER),n},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},D={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},j=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData())}async initAttach(){var t,i,e,a,s,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData());if("Attach"===this.fetcherType&&(null===(a=this.registerKey)||void 0===a?void 0:a.split("_").length)>1)return;await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(p.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i,e;this._currentDataUnit=(new A).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnit.metadata||(await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadMetadata()),this.crudConfig=Object.assign({},D)),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()),this.disableEditFieldsNotInForm()}async loadAttach(){var t,i;this._currentFetcher=new _,this._currentDataUnit=new l(O.IN_MEMORY_DATA_UNIT_NAME),this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=Object.assign({},g),null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},g),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm())}initDataUnitLoaders(){var t,i,e;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnitBuilder=new f(this.entityName,this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new _,this._currentDataUnitBuilder=new P(this.getMessage.bind(this)),null===(e=this._currentDataUnitBuilder)||void 0===e||e.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this._currentDataUnit.disableField(e)}))}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}render(){var t,i;return this._currentDataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:x(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this)},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};j.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{j as snk_attach}
1
+ import{r as t,c as i,h as e}from"./p-d2d301a6.js";import{ApplicationContext as a,DataType as s,Action as n,UserInterface as o,StringUtils as r,DataUnit as l}from"@sankhyalabs/core";import{D as h}from"./p-594bc21d.js";import"./p-25f1fc39.js";import"./p-30cf616e.js";import{S as d}from"./p-21749402.js";import{P as c,b as u,c as v,d as m,D as A,I as O}from"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{d as p}from"./p-b0ef4383.js";import{A as w}from"./p-0cd3c0a9.js";import{T as I}from"./p-7e7a7473.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"./p-6dc031de.js";class _{constructor(t){this.dataUnitName=t}async save({dataUnit:t,record:i,updatingFields:e,operation:a}){var s,n;const o="INSERT"==a,r=o?e:i;if(!o&&(null==e?void 0:e.DESCRICAO)&&(null==e?void 0:e.DESCRICAO)!==(null==i?void 0:i.DESCRICAO))throw new Error(d.DESCRIPTION_CANNOT_BE_CHANGED);const l={anexo:{codata:o?null==e?void 0:e.REGISTER_KEY:null==i?void 0:i.CODATA,sequencia:(null==r?void 0:r.SEQUENCIA)||"0",tipo:(null==r?void 0:r.TIPO)||"N",descricao:null==r?void 0:r.DESCRICAO,arquivo:null===(n=null===(s=e.CAMINHO_ARQUIVO)||void 0===s?void 0:s[0])||void 0===n?void 0:n.name,ehInclusao:o?"S":"N",ehArquivoRepositorio:"N"}};return new Promise(((i,a)=>{h.get().callServiceBroker("Attach.save",JSON.stringify(l)).then((a=>{var s;return i([Object.assign(Object.assign(Object.assign({},a),e),{__owner__dataunit__name__:null!==(s=this.dataUnitName)&&void 0!==s?s:t})])})).catch((t=>a(t)))}))}async edit(t){throw new Error("Method not implemented.")}async delete(t){var i={anexo:{codata:t.CODATA,tipo:t.TIPO,descricao:t.DESCRICAO}};const e=await h.get().callServiceBroker("Attach.remove",JSON.stringify(i));return Promise.resolve(e)}async getDownloadKey(t){var i,e,a;if("S"==t.EHARQUIVOREPOSITORIO){const a={config:{path:t.ARQUIVO,tipoconteudo:t.TIPOCONTEUDO}},s=await h.get().callServiceBroker("RepositorioArquivoSP.abreArquivo",JSON.stringify(a));return Promise.resolve({chave:{valor:null===(e=null===(i=null==s?void 0:s.responseBody)||void 0===i?void 0:i.chave)||void 0===e?void 0:e.valor}})}const s={anexo:{codata:t.CODATA,codemp:t.CODEMP,sequencia:t.SEQUENCIA,tipo:t.TIPO,descricao:t.DESCRICAO,tipoConteudo:t.TIPOCONTEUDO}},n=await h.get().callServiceBroker("Attach.view",JSON.stringify(s));return(null==n?void 0:n.chaveAnexo)?Promise.resolve({chave:{valor:null===(a=null==n?void 0:n.chaveAnexo)||void 0===a?void 0:a.idChaveAnexo}}):Promise.reject(new Error("File not found."))}}const S="AnexoSistemaSP.salvar",k="AnexoSistemaSP.excluir",y="AnexoSistemaSP.baixar";class b{constructor(t,i,e){var a;this.entityName=t,this.registerKey=i,this.dataUnitName=e,this.validateFields=t=>{if(t.LINK&&t.NOMEARQUIVO)throw new Error(d.LINK_AND_FILE_AT_THE_SAME_TIME);if(!t.LINK&&!t.NOMEARQUIVO)throw new Error(d.ANY_LINK_OR_FILE_FILLED);if(!this.registerKey)throw new Error("Register key can not be null")},this.resourceID=window.resourceID||(null===(a=window.workspace)||void 0===a?void 0:a.resourceID)}async save(t){var i,e;let{updatingFields:a}=t;a=Object.assign(Object.assign({},a),{NOMEARQUIVO:null===(i=a.NOMEARQUIVO)||void 0===i?void 0:i[0]});try{this.validateFields(a);const t=a.LINK?null:a.NOMEARQUIVO,i={serviceName:S,requestBody:{params:{resourceID:this.resourceID,description:a.DESCRICAO,fileSelect:t?1:0,keySession:null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.fileNameTmp,nameAttach:null==t?void 0:t.name,link:a.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:a.TIPOACESSO,typeApres:a.TIPOAPRES}}},s=await h.get().callServiceBroker(S,JSON.stringify(i));return Promise.resolve([Object.assign(Object.assign(Object.assign({},s),a),{ARQUIVOOULINK:a.LINK?a.LINK:null==t?void 0:t.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}async edit(t){var i,e,a;let{updatingFields:s,record:n}=t;const o=t=>void 0!==s[t]?s[t]:n[t],r=o("NOMEARQUIVO"),l=null===(e=null===(i=s.NOMEARQUIVO)||void 0===i?void 0:i[0])||void 0===e?void 0:e.downloadURL;s=Object.assign(Object.assign({},s),{DESCRICAO:o("DESCRICAO"),LINK:o("LINK"),TIPOACESSO:o("TIPOACESSO"),TIPOAPRES:o("TIPOAPRES"),CHAVEARQUIVO:n.CHAVEARQUIVO,NOMEARQUIVO:null==r?void 0:r[0]});const d=s.LINK?null:s.NOMEARQUIVO;try{this.validateFields(s);const t={serviceName:S,requestBody:{params:{resourceID:this.resourceID,nuAttach:null==n?void 0:n.NUATTACH,description:s.DESCRICAO,fileSelect:l?1:0,keySession:null===(a=null==d?void 0:d.properties)||void 0===a?void 0:a.fileNameTmp,keyAttach:s.CHAVEARQUIVO,nameAttach:null==d?void 0:d.name,link:s.LINK,nameEntity:this.entityName,pkEntity:this.registerKey,typeAcess:s.TIPOACESSO,typeApres:s.TIPOAPRES}}},i=await h.get().callServiceBroker(S,JSON.stringify(t));return Promise.resolve([Object.assign(Object.assign(Object.assign({},i),s),{ARQUIVOOULINK:s.LINK?s.LINK:null==d?void 0:d.name,__owner__dataunit__name__:this.dataUnitName})])}catch(t){return Promise.reject(t)}}delete(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:k,requestBody:{paramsDelete:{keyAttach:t.CHAVEARQUIVO,nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(k,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}getDownloadKey(t){var i;const e=(null===(i=t.NOMEARQUIVO)||void 0===i?void 0:i[0])||{},a={serviceName:y,requestBody:{paramsDown:{nameAttach:null==e?void 0:e.name,nameEntity:t.NOMEINSTANCIA,nuAttach:t.NUATTACH,pkEntity:t.PKREGISTRO,keyAttach:t.CHAVEARQUIVO}}};return new Promise(((t,i)=>{h.get().callServiceBroker(y,JSON.stringify(a)).then((i=>t(i))).catch((t=>i(t)))}))}}class f{constructor(t,i){this.entityName=t,this.getMessage=i,this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){this.loader||(this.loader=t.dataLoader),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){throw new Error("Method not implemented.")}dataLoader(t,i){return new Promise((e=>{this.loader(t,i).then((t=>{const i=((null==t?void 0:t.records)||[]).map((t=>{let i;return t.LINK||(i=[{name:t.NOMEARQUIVO}]),Object.assign(Object.assign({},t),{ARQUIVOOULINK:t.LINK?t.LINK:t.NOMEARQUIVO,NOMEARQUIVO:i})}));e(Object.assign(Object.assign({},t),{records:i}))}))}))}saveLoader(t,i){return new Promise((e=>{var a;const s=Array.isArray(t)?t[0]:{};((null===(a=null==s?void 0:s.record)||void 0===a?void 0:a.NUATTACH)>=0?i.edit.bind(i):i.save.bind(i))(s).then((t=>{e(t)})).catch((t=>t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{const{records:s}=t.getSelectionInfo(),n=s[0];e.delete(n).then((()=>(c.removeRecords(t,[n]),a(i))))}))}getFilters(t){return[{name:"AttachmentsByPK",expression:"this.PKREGISTRO = :PKREGISTRO",params:[{name:"PKREGISTRO",dataType:s.TEXT,value:`${t}_${this.entityName}`}]}]}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const E=a.getContextValue("__SNK__APPLICATION__"),N=t=>{var i,e;return null===(e=null===(i=null==E?void 0:E.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},g={grid:{columns:[{name:"CODATA",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"ARQUIVO",orderIndex:2,width:0},{name:"DTALTER",orderIndex:3,width:0},{name:"USUARIO",orderIndex:4,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),visible:!0,readOnly:!1,required:!0},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFile"),visible:!0,readOnly:!1,required:!0}]}},C={name:"Attach",label:"Attach List",fields:[{name:"CODATA",label:N("snkAttach.attachMetadata.lblCode"),dataType:s.TEXT},{name:"DESCRICAO",label:N("snkAttach.attachMetadata.lblDescription"),dataType:s.TEXT,readOnly:!1},{name:"ARQUIVO",label:N("snkAttach.attachMetadata.lblFileOrLink"),dataType:s.TEXT},{name:"USUARIO",label:N("snkAttach.attachMetadata.lblUser"),dataType:s.TEXT},{name:"DTALTER",label:N("snkAttach.attachMetadata.lblDate"),dataType:s.TEXT},{name:"CAMINHO_ARQUIVO",label:N("snkAttach.attachMetadata.lblFileUpload"),dataType:s.OBJECT,userInterface:o.FILE,readOnly:!1,required:!0,visible:!0,properties:{subTitle:N("snkAttach.attachMetadata.lblSubTitle"),MAX_FILES:1,STORAGESTRATEGY:"SESSION",INTERNAL_FILENAME:"Attach.upload"}}]};class P{constructor(t){this.getMessage=t,this._records=[],this._application=a.getContextValue("__SNK__APPLICATION__")}initLoaders(t,i,e){t.metadataLoader=t=>this.metadataLoader(t),t.dataLoader=(t,i)=>this.dataLoader(t,i),t.saveLoader=(t,a)=>this.saveLoader(a,i).then((t=>(t.length&&e(),t))),t.removeLoader=(t,a)=>this.removeLoader(t,a,i).then((t=>(t.length&&e(),t)))}metadataLoader(t){return Promise.resolve(C)}async dataLoader(t,i){if(!i.source)return Promise.resolve({records:this._records});if(!Number.isNaN(Number(i.source))){const t={criteria:{codata:i.source,tipoAnexo:"N"}},e=await this._application.getDataFetcher(),{anexos:{anexo:a=[]}}=await e.callServiceBroker("Attach.load",JSON.stringify(t)),s=[];a.forEach((t=>{s.push(Object.assign({__record__id__:r.generateUUID(),CAMINHO_ARQUIVO:[{name:null==t?void 0:t.ARQUIVO}]},t))})),this._records=s}let e=u(this._records,t,i.filters);return e=v(e,t,i.sort),Promise.resolve({records:e,paginationInfo:m(e,i.offset,i.limit)})}saveLoader(t,i){return new Promise((e=>{const a=Array.isArray(t)?t[0]:{};i.save(a).then(e).catch((t=>t.message===d.DESCRIPTION_CANNOT_BE_CHANGED?(this._application.alert(this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.title"),this.getMessage("snkAttach.alertValidation.descriptionCannotBeChanged.message")),e([])):t.message===d.LINK_AND_FILE_AT_THE_SAME_TIME?(this._application.alert(this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.title"),this.getMessage("snkAttach.alertValidation.fileAndLinkAtTheSameTime.message")),e([])):t.message===d.ANY_LINK_OR_FILE_FILLED?(this._application.alert(this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.title"),this.getMessage("snkAttach.alertValidation.anyLinkOrFileFilled.message")),e([])):t.message?(this._application.error(t.title||t.name,t.message),e([])):void e([])))}))}removeLoader(t,i,e){return new Promise((a=>{t.getSelectionInfo().records.forEach((async t=>{this._application.hasAccess(w.REMOVE).then((async s=>{s&&(await e.delete(t),a(i))}))}))}))}getFilters(){throw new Error("Method not implemented.")}getInterceptions(t,i,e){return new Promise((a=>i.type===n.EDITION_CANCELED?t.isDirty()?this._application.confirm(this.getMessage("snkAttach.cancelConfirmation.title"),this.getMessage("snkAttach.cancelConfirmation.message")).then((t=>t?(e.goToView(p.GRID),a(i)):a(void 0))):a(i):i.type===n.DATA_SAVED?(t.loadData(),a(i)):void a(i)))}}const T=a.getContextValue("__SNK__APPLICATION__"),L=t=>{var i,e;return null===(e=null===(i=null==T?void 0:T.messagesBuilder)||void 0===i?void 0:i.getMessage)||void 0===e?void 0:e.call(i,t,null)},R={DOWNLOAD:{hint:L("snkAttach.taskbar.titleDownload"),name:"DOWNLOAD",iconName:"file-download"},LINK:{hint:L("snkAttach.taskbar.titleLink"),name:"LINK",iconName:"launch"}},x=()=>{const t=[I.REMOVE,"DOWNLOAD","LINK"];return{getButtons:(t,i,e)=>{if((null==i?void 0:i.insertionMode)||(null==i?void 0:i.isDirty))return e.reverse();e.splice(e.indexOf(I.REFRESH),1);const{selectedRecord:a}=i||{},s=(null==a?void 0:a.LINK)?R.LINK:R.DOWNLOAD;e.splice(e.indexOf(I.DIVIDER)+1,0,I.REMOVE,s,I.DIVIDER);const n=Array.from(new Set(e.filter((t=>t!==I.CLONE))));return n.splice(n.indexOf(s)+1,0,I.DIVIDER),n},isEnabled:(i,e,a)=>{const s=void 0!==(null==e?void 0:e.selectedRecord);return!(t.includes(a)&&!s)}}},D={grid:{columns:[{name:"ARQUIVOOULINK",orderIndex:0,width:0},{name:"DESCRICAO",orderIndex:1,width:0},{name:"DHCAD",orderIndex:2,width:0},{name:"DHALTER",orderIndex:3,width:0},{name:"TIPOAPRES",orderIndex:4,width:0},{name:"TIPOACESSO",orderIndex:5,width:0},{name:"CODUSU",orderIndex:6,width:0},{name:"CODUSUALT",orderIndex:7,width:0}]},form:{emptyConfig:!1,fields:[{name:"DESCRICAO",required:!0},{name:"TIPOAPRES",required:!0},{name:"TIPOACESSO",required:!0},{name:"LINK"},{name:"NOMEARQUIVO"}]}},j=class{constructor(e){t(this,e),this.back=i(this,"back",7),this.handleTaskbarClick=async({detail:t})=>{if(["DOWNLOAD","LINK"].includes(t))return this.downloadAttachment(this._currentDataUnit.getSelectedRecord());"Attach"===this.fetcherType&&["SAVE"].includes(t)&&this._currentDataUnit.isDirty()&&await this._currentDataUnit.setFieldValue("REGISTER_KEY",this.registerKey)},this.handleBack=()=>{this._currentDataUnit.cancelEdition().then((t=>{t&&this.back.emit()}))},this.handleFinish=()=>{if(!this._currentDataUnit.isDirty())return this.back.emit();this._currentDataUnit.saveData().then((()=>{this.showFinishedToast(),this.back.emit()}))},this.fetcherType=void 0,this.fetcher=void 0,this.dataUnit=void 0,this.dataUnitBuilder=void 0,this.registerKey=void 0,this.entityName=void 0,this.messagesBuilder=void 0,this._currentFetcher=void 0,this._currentDataUnit=void 0,this.crudConfig=void 0}async registerKeyWatcher(t,i){var e;null==this._currentDataUnit&&this.loadAttachmentDataUnit(),i!==t&&await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData())}async initAttach(){var t,i,e,a,s,n;if(this.fetcherType||this.registerKey){if(this.fetcherType||(this.fetcherType="AnexoSistema"),this.returnToGridMode(),"AnexoSistema"===this.fetcherType)return this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this)),void await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData());if("Attach"===this.fetcherType&&(null===(a=this.registerKey)||void 0===a?void 0:a.split("_").length)>1)return;await(null===(s=this._currentDataUnit)||void 0===s?void 0:s.loadMetadata()),await(null===(n=this._currentDataUnit)||void 0===n?void 0:n.loadData(void 0,void 0,!0,this.registerKey))}}getMessage(t,i){if(this.messagesBuilder)return this.messagesBuilder.getMessage(t,i)}showFinishedToast(){this._application.info(this.getMessage("snkAttach.finishedMessage"),{iconName:"check"})}downloadAttachment(t){if(!t)throw new Error("Nenhum registro selecionado");t.LINK?window.open(`${t.LINK}`):this._currentFetcher.getDownloadKey(t).then((({chave:i})=>{var e;let a=!1;(null===(e=null==t?void 0:t.ARQUIVO)||void 0===e?void 0:e.endsWith(".pdf"))||(a=!0),window.open(`/mge/visualizadorArquivos.mge?chaveArquivo=${i.valor}${a?"&forcarDownload=S":""}`)}))}returnToGridMode(){var t;null===(t=this._currentDataUnit)||void 0===t||t.clearSelection(),this._crudElement&&this._crudElement.goToView(p.GRID)}async loadAttachmentDataUnit(){try{switch(this.fetcherType){case"AnexoSistema":await this.loadAnexoSistema();break;case"Attach":await this.loadAttach();break;default:this._currentFetcher=this.fetcher,this._currentDataUnit=this.dataUnit,this._currentDataUnitBuilder=this.dataUnitBuilder}}catch(t){throw new Error("There was an error while creating the data unit")}}async loadAnexoSistema(){var t,i,e;this._currentDataUnit=(new A).getDataUnit("AnexoSistema","br.com.sankhya.core.v3.anexoSistema"),this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnit.metadata||(await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadMetadata()),this.crudConfig=Object.assign({},D)),this.initDataUnitLoaders(),this._currentDataUnit.addFilterProvider({getFilter:()=>this._currentDataUnitBuilder.getFilters(this.registerKey)}),this._currentDataUnit.addInterceptor({interceptAction:t=>this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}),await(null===(e=this._currentDataUnit)||void 0===e?void 0:e.loadData()),this.disableEditFieldsNotInForm()}async loadAttach(){var t,i;this._currentFetcher=new _,this._currentDataUnit=new l(O.IN_MEMORY_DATA_UNIT_NAME),this.initDataUnitLoaders(),this._currentDataUnit.addInterceptor({interceptAction:t=>{var i;return t.type===n.METADATA_LOADED&&(this.crudConfig=Object.assign({},g),null===(i=this._crudElement)||void 0===i||i.updateConfig()),this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit,t,this._crudElement)}}),this._currentDataUnit.metadata||(await(null===(t=this._currentDataUnit)||void 0===t?void 0:t.loadMetadata()),this.crudConfig=Object.assign({},g),await(null===(i=this._currentDataUnit)||void 0===i?void 0:i.loadData(void 0,void 0,!0,this.registerKey)),this.disableEditFieldsNotInForm())}initDataUnitLoaders(){var t,i,e;"AnexoSistema"===this.fetcherType&&(this._currentFetcher=new b(this.entityName,this.registerKey,null===(t=this._currentDataUnit)||void 0===t?void 0:t.name),this._currentDataUnitBuilder=new f(this.entityName,this.getMessage.bind(this)),null===(i=this._currentDataUnitBuilder)||void 0===i||i.initLoaders(this._currentDataUnit,this._currentFetcher,this.returnToGridMode.bind(this))),"Attach"===this.fetcherType&&(this._currentFetcher=new _,this._currentDataUnitBuilder=new P(this.getMessage.bind(this)),null===(e=this._currentDataUnitBuilder)||void 0===e||e.initLoaders(this._currentDataUnit,this._currentFetcher,(async()=>{this.returnToGridMode(),await this._currentDataUnit.loadData(void 0,void 0,!0,this.registerKey)})))}disableEditFieldsNotInForm(){var t;null===(t=this.crudConfig)||void 0===t||t.grid.columns.forEach((t=>{var i;const e=t.name;(null===(i=this.crudConfig)||void 0===i?void 0:i.form.fields.some((t=>t.name===e)))||this._currentDataUnit.disableField(e)}))}async componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__"),await this.initAttach()}componentWillRender(){this.fetcherType||(this.fetcherType="AnexoSistema"),null==this._currentDataUnit&&this.loadAttachmentDataUnit()}async handleOnDataStateChange({detail:t}){"Attach"===this.fetcherType&&(t.insertionMode?this._currentDataUnit.enableField("DESCRICAO"):this._currentDataUnit.disableField("DESCRICAO"),await this._currentDataUnit.loadMetadata())}render(){var t,i;return this._currentDataUnit?e("main",{class:"snk-attach__main"},e("header",{class:"snk-attach__header"},e("snk-simple-bar",{onExit:this.handleBack,messagesBuilder:this.messagesBuilder},e("div",{slot:"rightSlot"},e("ez-button",{class:"ez-button--primary",label:this.getMessage("snkAttach.finish"),onClick:this.handleFinish})))),e("div",{class:"snk-attach__crud-section ez-size-height--full ez-size-width--full ez-flex ez-flex--column"},e("div",{class:"ez-box__container"},e("snk-simple-crud",{ref:t=>this._crudElement=t,dataUnit:this._currentDataUnit,taskbarManager:x(),gridConfig:null===(t=this.crudConfig)||void 0===t?void 0:t.grid,formConfig:null===(i=this.crudConfig)||void 0===i?void 0:i.form,useCancelConfirm:!1,onActionClick:this.handleTaskbarClick,messagesBuilder:this.messagesBuilder,onDataStateChange:this.handleOnDataStateChange.bind(this)},e("div",{slot:"snkSimpleCrudHeader"},e("div",{class:"ez-flex ez-flex--column"},e("span",{class:"ez-title--primary ez-text ez-text--large ez-text--bold ez-padding-bottom--medium"},this.getMessage("snkAttach.title")),e("span",{class:"ez-text ez-text--medium ez-text--secondary"},this.getMessage("snkAttach.description")))))))):null}static get watchers(){return{registerKey:["registerKeyWatcher"]}}};j.style=".snk-attach__header.sc-snk-attach,.snk-attach__crud-section.sc-snk-attach{padding:0 var(--space--lg)}.snk-attach__file-info.sc-snk-attach{padding:var(--space--small);max-width:50%}.snk-attach__main.sc-snk-attach{height:85%}.ez-box__container.sc-snk-attach{height:100%}";export{j as snk_attach}
@@ -0,0 +1 @@
1
+ import{D as t}from"./p-594bc21d.js";import"./p-25f1fc39.js";import{SortMode as i,ApplicationContext as e,UserInterface as s,DateUtils as r,ObjectUtils as a,StringUtils as o,NumberUtils as n,DataType as l}from"@sankhyalabs/core";import"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as c}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as d}from"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import u from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";class h{static assertDefaultSorting(t,e){t&&e&&(e.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:s})=>{const{dataType:r}=e.getField(t);return{field:t,dataType:r,mode:s?i.ASC:i.DESC}})))}static find(i,s,r,a=!0,o,n){let l=[],c=[],d={},u=e.getContextValue("__SNK__APPLICATION__");if(s){if(!Array.isArray(s))throw new Error(u.messagesBuilder.getMessage("crudUtils.errorArray",null));s.forEach((t=>{l.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&c.push({nome:t,valor:r[t]});o&&(d={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:c,fields:{field:l},literalCriteria:d,orderby:n}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var e;let s=null===(e=t.entidades)||void 0===e?void 0:e.entidade;if(null!=s){let t={fields:new Map};for(let i in s){let e=s[i];if(e.hasOwnProperty("$")&&t.fields.set(i,e.$),a)break}i(t)}else i(null)}))}))}}class m{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:e}=this._dataUnit.getField(t);return e===s.DATETIME?r.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t){return Promise.resolve(null==t?void 0:await d.getDistinct(this._dataUnit,t))}fetchData(t,i){return new Promise((e=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{e(t.map((t=>this._dataUnit.getField(i).userInterface===s.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return u.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}class f{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){a.objectToString(t)!==a.objectToString(this._dataState)&&(this._dataState=t,this.refreshSelectedRows())}format(t,i,e){var s;if(o.isEmpty(t))return t;const r=null===(s=this._dataState)||void 0===s?void 0:s.metadataByRow.get(e),a=null==r?void 0:r.getProp("rm_precision",i.name);return a||0===a?n.format(t,a,a):t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class p{constructor(t,i){this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,e;const s=[];for(const r of t){if(r.hidden&&"RECDESP"!==r.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(r.name),a=await this.grid.getCustomValueFormatter(r.name);if(s.push({label:r.label,id:r.name,width:r.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:a}),null!=(null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.DESCRIPTIONFIELD)){const i=t.properties.mergedFrom;s.push({label:t.properties.DESCRIPTIONENTITY,id:`${i?i+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,width:r.width,type:l.TEXT,userInterface:c.LONGTEXT,descriptionFrom:t.name})}}return s||[]}}export{p as C,f as R,m as S,h as a}
@@ -1 +1 @@
1
- import{r as t,c as i,h as s,H as e,g as a}from"./p-d2d301a6.js";import{StringUtils as o,ElementIDUtils as n,ApplicationContext as h,JSUtils as r,FloatingManager as d}from"@sankhyalabs/core";import{T as c}from"./p-7e7a7473.js";import"./p-dc7c9047.js";import"./p-af8efd95.js";import{P as l}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-fe79f83a.js";import"./p-ff1990ad.js";import"./p-df5451c7.js";import{d as m}from"./p-b0ef4383.js";import{A as u}from"./p-913a9979.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const p=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this._keyDownHandler=async t=>this.keyDownListener(t),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=l.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.disablePersonalizedFilter=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${o.generateUUID()}`}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}async getFilterBar(){return await this._snkGrid.getFilterBar()}async addCustomEditor(t,i){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(t,i),void this._snkGrid.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async addCustomValueFormatter(t,i){this._snkGrid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._snkGrid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){await this._guidesViewer.setFieldProp(t,i,s)}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===m.GRID,this.setViewMode(m.FORM)}async executeAction(t){return t===c.GRID_MODE?this.setViewMode(m.GRID):t===c.FORM_MODE||t===c.UPDATE?this.gridToForm(t!==c.UPDATE):t===c.CONFIGURATOR?this._snkConfigurator.open():"ATTACH"===t?this.setViewMode(m.ATTACHMENT):void 0}backView(){const t=this._viewHistory.at(-2)||m.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t,t===m.GRID?this._snkGrid.setFocus():t===m.FORM&&this._guidesViewer.setFocus()}openConfig(t){this._snkConfigurator.close(),t===m.GRID?this._snkGrid.showConfig():t===m.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[t,i]of this._customRenders)this._snkGrid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[t,i]of this._customEditors)this._guidesViewer.addCustomEditor(t,i),this._snkGrid.addCustomEditor(t,i),this._customEditors.delete(t)}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(this._application.hasAccess(u.UPDATE,this._resourceID).then((t=>this._canEdit=t));t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}t=t.parentElement}this.configName||(this.configName=this._application.configName)}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){this.removeShortcuts(),window.removeEventListener("keydown",this._keyDownHandler)}async handleDataStateChange(t){var i;this._dataState=t.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey());const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const t of s||[]){if(!t)continue;const s=null===(i=this._dataState.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",t);(s||0===s)&&(await this.setFieldProp(t,"precision",s),await this.setFieldProp(t,"prettyPrecision",s))}}async initKeyboardManager(){var t;const i=await(null===(t=this._application)||void 0===t?void 0:t.getKeyboardManager());if(i){const s=this._dataUnit||await this._snkDataUnit.getDataUnit();async function e(){const t=document.activeElement,i=t==document.body;i||t.blur(),await s.saveData(),i||null==t.setFocus?i||t.focus():t.setFocus()}i.bind("F6",this.toggleView.bind(this),{description:"Alterna entre modo formulário e grade.",element:this._element}).bind("F7",e.bind(this),{description:"Salva os dados.",element:this._element}).bind("ctrl + \\",e.bind(this),{description:"Salva os dados.",element:this._element}).bind("F8",s.addRecord.bind(s),{description:"Adiciona um novo registro.",element:this._element}).bind("F9",s.removeSelectedRecords.bind(s),{description:"Remove o registro selecionado.",element:this._element}).bind("ctrl + F9",s.removeSelectedRecords.bind(s),{description:"Remove o registro selecionado.",element:this._element}).bind("ctrl + .",(()=>0===s.getSelectionInfo().records.length?s.selectFirst():s.nextRecord()),{description:"Avança para o próximo registro.",element:this._element}).bind("ctrl + ,",s.previousRecord.bind(s),{description:"Retorna ao registro anterior.",element:this._element}).bind("F5",(async()=>{const t=await this._viewStack.getSelectedIndex();m.GRID===t&&s.loadData()}),{description:"Atualiza os dados.",element:this._element}).bind("Escape",(()=>{s.isDirty()&&s.cancelEdition()}),{debounceTime:1e3,description:"Cancela uma ação.",element:this._element})}}async removeShortcuts(){var t;const i=await(null===(t=this._application)||void 0===t?void 0:t.getKeyboardManager());i&&i.unbind("F6").unbind("F7").unbind("ctrl + \\").unbind("F8").unbind("F9").unbind("ctrl + F9").unbind("ctrl + .").unbind("ctrl + ,").unbind("F5").unbind("Escape")}async toggleView(){const t=await this._viewStack.getSelectedIndex();this.setViewMode(m.GRID===t?m.FORM:m.GRID)}async initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await this._application.getResourceID()))}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}async keyDownListener(t){t.ctrlKey&&null!=t.key&&"F"===t.key.toUpperCase()&&null!=this._element&&(r.isHiddenElement(this._element)||(d.closeAll(),this._currentViewMode===m.GRID?await this._snkGrid.findColumn():await this._guidesViewer.findField(),t.preventDefault()))}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID,s(e,null,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,filterBarTitle:this.filterBarTitle,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID,disablePersonalizedFilter:this.disablePersonalizedFilter,gridLegacyConfigName:this.gridLegacyConfigName,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,autoFocus:this.autoFocus},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId,formLegacyConfigName:this.formLegacyConfigName},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",null,s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId})),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return a(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};p.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{p as snk_crud}
1
+ import{r as t,c as i,h as s,H as e,g as a}from"./p-d2d301a6.js";import{StringUtils as o,ElementIDUtils as n,ApplicationContext as h,JSUtils as r,FloatingManager as d}from"@sankhyalabs/core";import{T as c}from"./p-7e7a7473.js";import"./p-594bc21d.js";import"./p-25f1fc39.js";import{P as l}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-091ce761.js";import"./p-ff1990ad.js";import"./p-181975f1.js";import{d as m}from"./p-b0ef4383.js";import{A as u}from"./p-0cd3c0a9.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const p=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this.configuratorSave=i(this,"configuratorSave",7),this.configuratorCancel=i(this,"configuratorCancel",7),this.formItemsReady=i(this,"formItemsReady",7),this._keyDownHandler=async t=>this.keyDownListener(t),this._viewHistory=[],this._customEditors=new Map,this._customRenders=new Map,this._dataUnit=void 0,this._dataState=void 0,this.attachmentRegisterKey=void 0,this._currentViewMode=m.GRID,this._canEdit=void 0,this._resourceID=void 0,this.configName=void 0,this.filterBarTitle=void 0,this.selectionToastConfig=void 0,this.showActionButtons=!1,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=l.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.gridLegacyConfigName=void 0,this.filterBarLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.disablePersonalizedFilter=void 0,this.autoLoad=void 0,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.customContainerId=`SNK-CRUD-CUSTOM-CONTAINER-${o.generateUUID()}`}async goToView(t){this.executeAction(t)}async openConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.open()}async closeConfigurator(){var t;null===(t=this._snkConfigurator)||void 0===t||t.close()}async reloadFilterBar(){var t;null===(t=this._snkGrid)||void 0===t||t.reloadFilterBar()}async getFilterBar(){return await this._snkGrid.getFilterBar()}async addCustomEditor(t,i){if(this._guidesViewer&&this._snkGrid)return this._guidesViewer.addCustomEditor(t,i),void this._snkGrid.addCustomEditor(t,i);const s=new Map(this._customEditors);s.set(t,i),this._customEditors=s}async addGridCustomRender(t,i){if(this._snkGrid)return void this._snkGrid.addGridCustomRender(t,i);const s=new Map(this._customRenders);s.set(t,i),this._customRenders=s}async addCustomValueFormatter(t,i){this._snkGrid.addCustomValueFormatter(t,i)}async removeCustomValueFormatter(t){this._snkGrid.removeCustomValueFormatter(t)}async setFieldProp(t,i,s){await this._guidesViewer.setFieldProp(t,i,s)}currentViewModeWatcher(t){this._viewHistory=[...this._viewHistory.slice(-1),t]}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===m.GRID,this.setViewMode(m.FORM)}async executeAction(t){return t===c.GRID_MODE?this.setViewMode(m.GRID):t===c.FORM_MODE||t===c.UPDATE?this.gridToForm(t!==c.UPDATE):t===c.CONFIGURATOR?this._snkConfigurator.open():"ATTACH"===t?this.setViewMode(m.ATTACHMENT):void 0}backView(){const t=this._viewHistory.at(-2)||m.GRID;this.setViewMode(t)}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t,t===m.GRID?this._snkGrid.setFocus():t===m.FORM&&this._guidesViewer.setFocus()}openConfig(t){this._snkConfigurator.close(),t===m.GRID?this._snkGrid.showConfig():t===m.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){n.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(m.GRID)}async getAttachmentRegisterKey(){if(this._snkDataUnit)return(await this._snkDataUnit.getSelectedRecordsIDsInfo()).map((({value:t})=>t)).join("_")}setCustomRenders(){if(this._snkGrid)for(const[t,i]of this._customRenders)this._snkGrid.addGridCustomRender(t,i),this._customRenders.delete(t)}setCustomEditors(){if(this._snkGrid&&this._guidesViewer)for(const[t,i]of this._customEditors)this._guidesViewer.addCustomEditor(t,i),this._snkGrid.addCustomEditor(t,i),this._customEditors.delete(t)}componentDidRender(){this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__");let t=this._element.parentElement;for(this._application.hasAccess(u.UPDATE,this._resourceID).then((t=>this._canEdit=t));t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._snkDataUnit.domainMessagesBuilder=this.domainMessagesBuilder,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.initDataUnit():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.initDataUnit()})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}t=t.parentElement}this.configName||(this.configName=this._application.configName)}componentDidLoad(){this.initKeyboardManager()}disconnectedCallback(){this.removeShortcuts(),window.removeEventListener("keydown",this._keyDownHandler)}async handleDataStateChange(t){var i;this._dataState=t.detail,void 0!==this._dataState.selectedRecord&&(this.attachmentRegisterKey=await this.getAttachmentRegisterKey());const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const t of s||[]){if(!t)continue;const s=null===(i=this._dataState.rowMetadata)||void 0===i?void 0:i.getProp("rm_precision",t);(s||0===s)&&(await this.setFieldProp(t,"precision",s),await this.setFieldProp(t,"prettyPrecision",s))}}async initKeyboardManager(){var t;const i=await(null===(t=this._application)||void 0===t?void 0:t.getKeyboardManager());if(i){const s=this._dataUnit||await this._snkDataUnit.getDataUnit();async function e(){const t=document.activeElement,i=t==document.body;i||t.blur(),await s.saveData(),i||null==t.setFocus?i||t.focus():t.setFocus()}i.bind("F6",this.toggleView.bind(this),{description:"Alterna entre modo formulário e grade.",element:this._element}).bind("F7",e.bind(this),{description:"Salva os dados.",element:this._element}).bind("ctrl + \\",e.bind(this),{description:"Salva os dados.",element:this._element}).bind("F8",s.addRecord.bind(s),{description:"Adiciona um novo registro.",element:this._element}).bind("F9",s.removeSelectedRecords.bind(s),{description:"Remove o registro selecionado.",element:this._element}).bind("ctrl + F9",s.removeSelectedRecords.bind(s),{description:"Remove o registro selecionado.",element:this._element}).bind("ctrl + .",(()=>0===s.getSelectionInfo().records.length?s.selectFirst():s.nextRecord()),{description:"Avança para o próximo registro.",element:this._element}).bind("ctrl + ,",s.previousRecord.bind(s),{description:"Retorna ao registro anterior.",element:this._element}).bind("F5",(async()=>{const t=await this._viewStack.getSelectedIndex();m.GRID===t&&s.loadData()}),{description:"Atualiza os dados.",element:this._element}).bind("Escape",(()=>{s.isDirty()&&s.cancelEdition()}),{debounceTime:1e3,description:"Cancela uma ação.",element:this._element})}}async removeShortcuts(){var t;const i=await(null===(t=this._application)||void 0===t?void 0:t.getKeyboardManager());i&&i.unbind("F6").unbind("F7").unbind("ctrl + \\").unbind("F8").unbind("F9").unbind("ctrl + F9").unbind("ctrl + .").unbind("ctrl + ,").unbind("F5").unbind("Escape")}async toggleView(){const t=await this._viewStack.getSelectedIndex();this.setViewMode(m.GRID===t?m.FORM:m.GRID)}async initDataUnit(){this.addDataElementID(),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),null==this._resourceID&&(this._resourceID=this._snkDataUnit.resourceID,null==this._resourceID&&(this._resourceID=await this._application.getResourceID()))}handleConfiguratorEvent(t,i){t.stopImmediatePropagation(),"SAVE"!==i?this.configuratorCancel.emit():this.configuratorSave.emit()}async keyDownListener(t){t.ctrlKey&&null!=t.key&&"F"===t.key.toUpperCase()&&null!=this._element&&(r.isHiddenElement(this._element)||(d.closeAll(),this._currentViewMode===m.GRID?await this._snkGrid.findColumn():await this._guidesViewer.findField(),t.preventDefault()))}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}render(){if(null!=this._resourceID)return this._snkDataUnit.ignoreSaveMessage=this._currentViewMode===m.GRID,s(e,null,s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,filterBarTitle:this.filterBarTitle,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),messagesBuilder:this.messagesBuilder,actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode,recordsValidator:this.recordsValidator,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,canEdit:this._canEdit,resourceID:this._resourceID,disablePersonalizedFilter:this.disablePersonalizedFilter,gridLegacyConfigName:this.gridLegacyConfigName,filterBarLegacyConfigName:this.filterBarLegacyConfigName,autoLoad:this.autoLoad,autoFocus:this.autoFocus},s("slot",{name:"GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,messagesBuilder:this.messagesBuilder,onExit:()=>this.setViewMode(m.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form",canEdit:this._canEdit,recordsValidator:this.recordsValidator,resourceID:this._resourceID,detailTaskbarCustomContainerId:this.customContainerId,formLegacyConfigName:this.formLegacyConfigName},s("slot",{name:"GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"SnkFormTaskBar"}))),s("stack-item",null,s("snk-attach",{registerKey:this.attachmentRegisterKey,messagesBuilder:this.messagesBuilder,entityName:this._snkDataUnit.entityName,onBack:this.backView.bind(this)})),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail),showActionButtons:this.showActionButtons,onSave:t=>this.handleConfiguratorEvent(t,"SAVE"),onCancel:t=>this.handleConfiguratorEvent(t,"CANCEL"),resourceID:this._resourceID,customContainerId:this.customContainerId})),s("div",{id:`${this.customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}),s("slot",{name:"DETAIL_GRID_HEADER_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS"}),s("slot",{name:"DETAIL_TASKBAR_CUSTOM_ELEMENTS"})))}get _element(){return a(this)}static get watchers(){return{_currentViewMode:["currentViewModeWatcher"]}}};p.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{p as snk_crud}
@@ -0,0 +1 @@
1
+ import{DataType as e,ApplicationContext as t,StringUtils as n,ErrorException as i,WarningException as r,ObjectUtils as s,ServiceCanceledException as o}from"@sankhyalabs/core";import{P as u}from"./p-8d884fab.js";import{DataUnitTransient as a}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";var c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e,t,n){return e(n={path:t,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}},n.exports),n.exports}var h=l((function(e,t){var n="undefined"!=typeof self?self:c,i=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,i="Symbol"in e&&"iterator"in Symbol,r="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in e,o="ArrayBuffer"in e;if(o)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(e){return e&&u.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return i&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function v(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function p(e){var t=new FileReader,n=v(t);return t.readAsArrayBuffer(e),n}function m(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&r&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=m(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||a(e))?this._bodyArrayBuffer=m(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var e,t,n,i=d(this);if(i)return i;if(this._bodyBlob)return e=this._bodyBlob,n=v(t=new FileReader),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),i=0;i<t.length;i++)n[i]=String.fromCharCode(t[i]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=c(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[c(e)]},f.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},f.prototype.set=function(e,t){this.map[c(e)]=l(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),h(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),h(e)},i&&(f.prototype[Symbol.iterator]=f.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(e,t){var n,i,r=(t=t||{}).body;if(e instanceof w){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,r||null==e._bodyInit||(r=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(i=(n=t.method||this.method||"GET").toUpperCase(),b.indexOf(i)>-1?i:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function g(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),i=n.shift().replace(/\+/g," "),r=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(r))}})),t}function O(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},y.call(w.prototype),y.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},O.error=function(){var e=new O(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];O.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new O(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function T(e,n){return new Promise((function(i,s){var o=new w(e,n);if(o.signal&&o.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function a(){u.abort()}u.onload=function(){var e,t,n={status:u.status,statusText:u.statusText,headers:(e=u.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),i=n.shift().trim();if(i){var r=n.join(":").trim();t.append(i,r)}})),t)};n.url="responseURL"in u?u.responseURL:n.headers.get("X-Request-URL"),i(new O("response"in u?u.response:u.responseText,n))},u.onerror=function(){s(new TypeError("Network request failed"))},u.ontimeout=function(){s(new TypeError("Network request failed"))},u.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},u.open(o.method,o.url,!0),"include"===o.credentials?u.withCredentials=!0:"omit"===o.credentials&&(u.withCredentials=!1),"responseType"in u&&r&&(u.responseType="blob"),o.headers.forEach((function(e,t){u.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",a),u.onreadystatechange=function(){4===u.readyState&&o.signal.removeEventListener("abort",a)}),u.send(void 0===o._bodyInit?null:o._bodyInit)}))}T.polyfill=!0,e.fetch||(e.fetch=T,e.Headers=f,e.Request=w,e.Response=O),t.Headers=f,t.Request=w,t.Response=O,t.fetch=T,Object.defineProperty(t,"__esModule",{value:!0})}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var r=i;(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t})),f=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.isObjectLike=function(e){return"object"==typeof e&&null!==e}})),d=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.invariant=function(e,t){if(!Boolean(e))throw new Error(null!=t?t:"Unexpected invariant triggered.")}})),v=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getLocation=function(e,t){let i=0,r=1;for(const s of e.body.matchAll(n)){if("number"==typeof s.index||(0,d.invariant)(!1),s.index>=t)break;i=s.index+s[0].length,r+=1}return{line:r,column:t+1-i}};const n=/\r\n|[\n\r]/g})),p=l((function(e,t){function n(e,t){const n=e.locationOffset.column-1,r="".padStart(n)+e.body,s=t.line-1,o=t.line+(e.locationOffset.line-1),u=t.column+(1===t.line?n:0),a=`${e.name}:${o}:${u}\n`,c=r.split(/\r\n|[\n\r]/g),l=c[s];if(l.length>120){const e=Math.floor(u/80),t=u%80,n=[];for(let e=0;e<l.length;e+=80)n.push(l.slice(e,e+80));return a+i([[`${o} |`,n[0]],...n.slice(1,e+1).map((e=>["|",e])),["|","^".padStart(t)],["|",n[e+1]]])}return a+i([[o-1+" |",c[s-1]],[`${o} |`,l],["|","^".padStart(u)],[`${o+1} |`,c[s+1]]])}function i(e){const t=e.filter((([e,t])=>void 0!==t)),n=Math.max(...t.map((([e])=>e.length)));return t.map((([e,t])=>e.padStart(n)+(t?" "+t:""))).join("\n")}Object.defineProperty(t,"__esModule",{value:!0}),t.printLocation=function(e){return n(e.source,(0,v.getLocation)(e.source,e.start))},t.printSourceLocation=n})),m=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLError=void 0,t.formatError=function(e){return e.toJSON()},t.printError=function(e){return e.toString()};class n extends Error{constructor(e,...t){var r,s,o;const{nodes:u,source:a,positions:c,path:l,originalError:h,extensions:d}=function(e){const t=e[0];return null==t||"kind"in t||"length"in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}(t);super(e),this.name="GraphQLError",this.path=null!=l?l:void 0,this.originalError=null!=h?h:void 0,this.nodes=i(Array.isArray(u)?u:u?[u]:void 0);const p=i(null===(r=this.nodes)||void 0===r?void 0:r.map((e=>e.loc)).filter((e=>null!=e)));this.source=null!=a?a:null==p||null===(s=p[0])||void 0===s?void 0:s.source,this.positions=null!=c?c:null==p?void 0:p.map((e=>e.start)),this.locations=c&&a?c.map((e=>(0,v.getLocation)(a,e))):null==p?void 0:p.map((e=>(0,v.getLocation)(e.source,e.start)));const m=(0,f.isObjectLike)(null==h?void 0:h.extensions)?null==h?void 0:h.extensions:void 0;this.extensions=null!==(o=null!=d?d:m)&&void 0!==o?o:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),null!=h&&h.stack?Object.defineProperty(this,"stack",{value:h.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,n):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const t of this.nodes)t.loc&&(e+="\n\n"+(0,p.printLocation)(t.loc));else if(this.source&&this.locations)for(const t of this.locations)e+="\n\n"+(0,p.printSourceLocation)(this.source,t);return e}toJSON(){const e={message:this.message};return null!=this.locations&&(e.locations=this.locations),null!=this.path&&(e.path=this.path),null!=this.extensions&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function i(e){return void 0===e||0===e.length?void 0:e}t.GraphQLError=n})),y=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.syntaxError=function(e,t,n){return new m.GraphQLError(`Syntax Error: ${n}`,{source:e,positions:[t]})}})),b=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Token=t.QueryDocumentKeys=t.OperationTypeNode=t.Location=void 0,t.isNode=function(e){const t=null==e?void 0:e.kind;return"string"==typeof t&&s.has(t)};class n{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}t.Location=n;class i{constructor(e,t,n,i,r,s){this.kind=e,this.start=t,this.end=n,this.line=i,this.column=r,this.value=s,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}t.Token=i;const r={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]};t.QueryDocumentKeys=r;const s=new Set(Object.keys(r));var o;t.OperationTypeNode=o,function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription"}(o||(t.OperationTypeNode=o={}))})),w=l((function(e,t){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.DirectiveLocation=void 0,t.DirectiveLocation=n,function(e){e.QUERY="QUERY",e.MUTATION="MUTATION",e.SUBSCRIPTION="SUBSCRIPTION",e.FIELD="FIELD",e.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",e.FRAGMENT_SPREAD="FRAGMENT_SPREAD",e.INLINE_FRAGMENT="INLINE_FRAGMENT",e.VARIABLE_DEFINITION="VARIABLE_DEFINITION",e.SCHEMA="SCHEMA",e.SCALAR="SCALAR",e.OBJECT="OBJECT",e.FIELD_DEFINITION="FIELD_DEFINITION",e.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",e.INTERFACE="INTERFACE",e.UNION="UNION",e.ENUM="ENUM",e.ENUM_VALUE="ENUM_VALUE",e.INPUT_OBJECT="INPUT_OBJECT",e.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"}(n||(t.DirectiveLocation=n={}))})),g=l((function(e,t){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Kind=void 0,t.Kind=n,function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"}(n||(t.Kind=n={}))})),O=l((function(e,t){function n(e){return e>=48&&e<=57}function i(e){return e>=97&&e<=122||e>=65&&e<=90}Object.defineProperty(t,"__esModule",{value:!0}),t.isDigit=n,t.isLetter=i,t.isNameContinue=function(e){return i(e)||n(e)||95===e},t.isNameStart=function(e){return i(e)||95===e},t.isWhiteSpace=function(e){return 9===e||32===e}})),E=l((function(e,t){function n(e){let t=0;for(;t<e.length&&(0,O.isWhiteSpace)(e.charCodeAt(t));)++t;return t}Object.defineProperty(t,"__esModule",{value:!0}),t.dedentBlockStringLines=function(e){var t;let i=Number.MAX_SAFE_INTEGER,r=null,s=-1;for(let t=0;t<e.length;++t){var o;const u=e[t],a=n(u);a!==u.length&&(r=null!==(o=r)&&void 0!==o?o:t,s=t,0!==t&&a<i&&(i=a))}return e.map(((e,t)=>0===t?e:e.slice(i))).slice(null!==(t=r)&&void 0!==t?t:0,s+1)},t.isPrintableAsBlockString=function(e){if(""===e)return!0;let t=!0,n=!1,i=!0,r=!1;for(let s=0;s<e.length;++s)switch(e.codePointAt(s)){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 11:case 12:case 14:case 15:case 13:return!1;case 10:if(t&&!r)return!1;r=!0,t=!0,n=!1;break;case 9:case 32:n||(n=t);break;default:i&&(i=n),t=!1}return!t&&(!i||!r)},t.printBlockString=function(e,t){const n=e.replace(/"""/g,'\\"""'),i=n.split(/\r\n|[\n\r]/g),r=1===i.length,s=i.length>1&&i.slice(1).every((e=>0===e.length||(0,O.isWhiteSpace)(e.charCodeAt(0)))),o=n.endsWith('\\"""'),u=e.endsWith('"')&&!o,a=e.endsWith("\\"),c=u||a,l=!(null!=t&&t.minimize)&&(!r||e.length>70||c||s||o);let h="";const f=r&&(0,O.isWhiteSpace)(e.charCodeAt(0));return(l&&!f||s)&&(h+="\n"),h+=n,(l||c)&&(h+="\n"),'"""'+h+'"""'}})),T=l((function(e,t){var n;Object.defineProperty(t,"__esModule",{value:!0}),t.TokenKind=void 0,t.TokenKind=n,function(e){e.SOF="<SOF>",e.EOF="<EOF>",e.BANG="!",e.DOLLAR="$",e.AMP="&",e.PAREN_L="(",e.PAREN_R=")",e.SPREAD="...",e.COLON=":",e.EQUALS="=",e.AT="@",e.BRACKET_L="[",e.BRACKET_R="]",e.BRACE_L="{",e.PIPE="|",e.BRACE_R="}",e.NAME="Name",e.INT="Int",e.FLOAT="Float",e.STRING="String",e.BLOCK_STRING="BlockString",e.COMMENT="Comment"}(n||(t.TokenKind=n={}))})),S=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Lexer=void 0,t.isPunctuatorTokenKind=function(e){return e===T.TokenKind.BANG||e===T.TokenKind.DOLLAR||e===T.TokenKind.AMP||e===T.TokenKind.PAREN_L||e===T.TokenKind.PAREN_R||e===T.TokenKind.SPREAD||e===T.TokenKind.COLON||e===T.TokenKind.EQUALS||e===T.TokenKind.AT||e===T.TokenKind.BRACKET_L||e===T.TokenKind.BRACKET_R||e===T.TokenKind.BRACE_L||e===T.TokenKind.PIPE||e===T.TokenKind.BRACE_R};class n{constructor(e){const t=new b.Token(T.TokenKind.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==T.TokenKind.EOF)do{if(e.next)e=e.next;else{const t=c(this,e.end);e.next=t,t.prev=e,e=t}}while(e.kind===T.TokenKind.COMMENT);return e}}function i(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function r(e,t){return s(e.charCodeAt(t))&&o(e.charCodeAt(t+1))}function s(e){return e>=55296&&e<=56319}function o(e){return e>=56320&&e<=57343}function u(e,t){const n=e.source.body.codePointAt(t);if(void 0===n)return T.TokenKind.EOF;if(n>=32&&n<=126){const e=String.fromCodePoint(n);return'"'===e?"'\"'":`"${e}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function a(e,t,n,i,r){return new b.Token(t,n,i,e.line,1+n-e.lineStart,r)}function c(e,t){const n=e.source.body,s=n.length;let o=t;for(;o<s;){const t=n.charCodeAt(o);switch(t){case 65279:case 9:case 32:case 44:++o;continue;case 10:++o,++e.line,e.lineStart=o;continue;case 13:10===n.charCodeAt(o+1)?o+=2:++o,++e.line,e.lineStart=o;continue;case 35:return l(e,o);case 33:return a(e,T.TokenKind.BANG,o,o+1);case 36:return a(e,T.TokenKind.DOLLAR,o,o+1);case 38:return a(e,T.TokenKind.AMP,o,o+1);case 40:return a(e,T.TokenKind.PAREN_L,o,o+1);case 41:return a(e,T.TokenKind.PAREN_R,o,o+1);case 46:if(46===n.charCodeAt(o+1)&&46===n.charCodeAt(o+2))return a(e,T.TokenKind.SPREAD,o,o+3);break;case 58:return a(e,T.TokenKind.COLON,o,o+1);case 61:return a(e,T.TokenKind.EQUALS,o,o+1);case 64:return a(e,T.TokenKind.AT,o,o+1);case 91:return a(e,T.TokenKind.BRACKET_L,o,o+1);case 93:return a(e,T.TokenKind.BRACKET_R,o,o+1);case 123:return a(e,T.TokenKind.BRACE_L,o,o+1);case 124:return a(e,T.TokenKind.PIPE,o,o+1);case 125:return a(e,T.TokenKind.BRACE_R,o,o+1);case 34:return 34===n.charCodeAt(o+1)&&34===n.charCodeAt(o+2)?S(e,o):d(e,o)}if((0,O.isDigit)(t)||45===t)return h(e,o,t);if((0,O.isNameStart)(t))return j(e,o);throw(0,y.syntaxError)(e.source,o,39===t?"Unexpected single quote character ('), did you mean to use a double quote (\")?":i(t)||r(n,o)?`Unexpected character: ${u(e,o)}.`:`Invalid character: ${u(e,o)}.`)}return a(e,T.TokenKind.EOF,s,s)}function l(e,t){const n=e.source.body,s=n.length;let o=t+1;for(;o<s;){const e=n.charCodeAt(o);if(10===e||13===e)break;if(i(e))++o;else{if(!r(n,o))break;o+=2}}return a(e,T.TokenKind.COMMENT,t,o,n.slice(t+1,o))}function h(e,t,n){const i=e.source.body;let r=t,s=n,o=!1;if(45===s&&(s=i.charCodeAt(++r)),48===s){if(s=i.charCodeAt(++r),(0,O.isDigit)(s))throw(0,y.syntaxError)(e.source,r,`Invalid number, unexpected digit after 0: ${u(e,r)}.`)}else r=f(e,r,s),s=i.charCodeAt(r);if(46===s&&(o=!0,s=i.charCodeAt(++r),r=f(e,r,s),s=i.charCodeAt(r)),69!==s&&101!==s||(o=!0,s=i.charCodeAt(++r),43!==s&&45!==s||(s=i.charCodeAt(++r)),r=f(e,r,s),s=i.charCodeAt(r)),46===s||(0,O.isNameStart)(s))throw(0,y.syntaxError)(e.source,r,`Invalid number, expected digit but got: ${u(e,r)}.`);return a(e,o?T.TokenKind.FLOAT:T.TokenKind.INT,t,r,i.slice(t,r))}function f(e,t,n){if(!(0,O.isDigit)(n))throw(0,y.syntaxError)(e.source,t,`Invalid number, expected digit but got: ${u(e,t)}.`);const i=e.source.body;let r=t+1;for(;(0,O.isDigit)(i.charCodeAt(r));)++r;return r}function d(e,t){const n=e.source.body,s=n.length;let o=t+1,c=o,l="";for(;o<s;){const s=n.charCodeAt(o);if(34===s)return l+=n.slice(c,o),a(e,T.TokenKind.STRING,t,o+1,l);if(92!==s){if(10===s||13===s)break;if(i(s))++o;else{if(!r(n,o))throw(0,y.syntaxError)(e.source,o,`Invalid character within String: ${u(e,o)}.`);o+=2}}else{l+=n.slice(c,o);const t=117===n.charCodeAt(o+1)?123===n.charCodeAt(o+2)?v(e,o):p(e,o):g(e,o);l+=t.value,o+=t.size,c=o}}throw(0,y.syntaxError)(e.source,o,"Unterminated string.")}function v(e,t){const n=e.source.body;let r=0,s=3;for(;s<12;){const e=n.charCodeAt(t+s++);if(125===e){if(s<5||!i(r))break;return{value:String.fromCodePoint(r),size:s}}if(r=r<<4|w(e),r<0)break}throw(0,y.syntaxError)(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+s)}".`)}function p(e,t){const n=e.source.body,r=m(n,t+2);if(i(r))return{value:String.fromCodePoint(r),size:6};if(s(r)&&92===n.charCodeAt(t+6)&&117===n.charCodeAt(t+7)){const e=m(n,t+8);if(o(e))return{value:String.fromCodePoint(r,e),size:12}}throw(0,y.syntaxError)(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function m(e,t){return w(e.charCodeAt(t))<<12|w(e.charCodeAt(t+1))<<8|w(e.charCodeAt(t+2))<<4|w(e.charCodeAt(t+3))}function w(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function g(e,t){const n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:"\n",size:2};case 114:return{value:"\r",size:2};case 116:return{value:"\t",size:2}}throw(0,y.syntaxError)(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function S(e,t){const n=e.source.body,s=n.length;let o=e.lineStart,c=t+3,l=c,h="";const f=[];for(;c<s;){const s=n.charCodeAt(c);if(34===s&&34===n.charCodeAt(c+1)&&34===n.charCodeAt(c+2)){h+=n.slice(l,c),f.push(h);const i=a(e,T.TokenKind.BLOCK_STRING,t,c+3,(0,E.dedentBlockStringLines)(f).join("\n"));return e.line+=f.length-1,e.lineStart=o,i}if(92!==s||34!==n.charCodeAt(c+1)||34!==n.charCodeAt(c+2)||34!==n.charCodeAt(c+3))if(10!==s&&13!==s)if(i(s))++c;else{if(!r(n,c))throw(0,y.syntaxError)(e.source,c,`Invalid character within String: ${u(e,c)}.`);c+=2}else h+=n.slice(l,c),f.push(h),13===s&&10===n.charCodeAt(c+1)?c+=2:++c,h="",l=c,o=c;else h+=n.slice(l,c),l=c+1,c+=4}throw(0,y.syntaxError)(e.source,c,"Unterminated string.")}function j(e,t){const n=e.source.body,i=n.length;let r=t+1;for(;r<i;){const e=n.charCodeAt(r);if(!(0,O.isNameContinue)(e))break;++r}return a(e,T.TokenKind.NAME,t,r,n.slice(t,r))}t.Lexer=n})),j=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.devAssert=function(e,t){if(!Boolean(e))throw new Error(t)}})),D=l((function(e,t){function n(e,t){switch(typeof e){case"string":return JSON.stringify(e);case"function":return e.name?`[function ${e.name}]`:"[function]";case"object":return function(e,t){if(null===e)return"null";if(t.includes(e))return"[Circular]";const i=[...t,e];if(function(e){return"function"==typeof e.toJSON}(e)){const t=e.toJSON();if(t!==e)return"string"==typeof t?t:n(t,i)}else if(Array.isArray(e))return function(e,t){if(0===e.length)return"[]";if(t.length>2)return"[Array]";const i=Math.min(10,e.length),r=e.length-i,s=[];for(let r=0;r<i;++r)s.push(n(e[r],t));return 1===r?s.push("... 1 more item"):r>1&&s.push(`... ${r} more items`),"["+s.join(", ")+"]"}(e,i);return function(e,t){const i=Object.entries(e);if(0===i.length)return"{}";if(t.length>2)return"["+function(e){const t=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if("Object"===t&&"function"==typeof e.constructor){const t=e.constructor.name;if("string"==typeof t&&""!==t)return t}return t}(e)+"]";const r=i.map((([e,i])=>e+": "+n(i,t)));return"{ "+r.join(", ")+" }"}(e,i)}(e,t);default:return String(e)}}Object.defineProperty(t,"__esModule",{value:!0}),t.inspect=function(e){return n(e,[])}})),x=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.instanceOf=void 0,t.instanceOf=function(e,t){return e instanceof t}})),I=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Source=void 0,t.isSource=function(e){return(0,x.instanceOf)(e,n)};class n{constructor(e,t="GraphQL request",n={line:1,column:1}){"string"==typeof e||(0,j.devAssert)(!1,`Body must be a string. Received: ${(0,D.inspect)(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||(0,j.devAssert)(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||(0,j.devAssert)(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}t.Source=n})),N=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Parser=void 0,t.parse=function(e,t){return new n(e,t).parseDocument()},t.parseConstValue=function(e,t){const i=new n(e,t);i.expectToken(T.TokenKind.SOF);const r=i.parseConstValueLiteral();return i.expectToken(T.TokenKind.EOF),r},t.parseType=function(e,t){const i=new n(e,t);i.expectToken(T.TokenKind.SOF);const r=i.parseTypeReference();return i.expectToken(T.TokenKind.EOF),r},t.parseValue=function(e,t){const i=new n(e,t);i.expectToken(T.TokenKind.SOF);const r=i.parseValueLiteral(!1);return i.expectToken(T.TokenKind.EOF),r};class n{constructor(e,t={}){const n=(0,I.isSource)(e)?e:new I.Source(e);this._lexer=new S.Lexer(n),this._options=t,this._tokenCounter=0}parseName(){const e=this.expectToken(T.TokenKind.NAME);return this.node(e,{kind:g.Kind.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:g.Kind.DOCUMENT,definitions:this.many(T.TokenKind.SOF,this.parseDefinition,T.TokenKind.EOF)})}parseDefinition(){if(this.peek(T.TokenKind.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===T.TokenKind.NAME){switch(t.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw(0,y.syntaxError)(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(t.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(T.TokenKind.BRACE_L))return this.node(e,{kind:g.Kind.OPERATION_DEFINITION,operation:b.OperationTypeNode.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const t=this.parseOperationType();let n;return this.peek(T.TokenKind.NAME)&&(n=this.parseName()),this.node(e,{kind:g.Kind.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(T.TokenKind.NAME);switch(e.value){case"query":return b.OperationTypeNode.QUERY;case"mutation":return b.OperationTypeNode.MUTATION;case"subscription":return b.OperationTypeNode.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(T.TokenKind.PAREN_L,this.parseVariableDefinition,T.TokenKind.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:g.Kind.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(T.TokenKind.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(T.TokenKind.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(T.TokenKind.DOLLAR),this.node(e,{kind:g.Kind.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:g.Kind.SELECTION_SET,selections:this.many(T.TokenKind.BRACE_L,this.parseSelection,T.TokenKind.BRACE_R)})}parseSelection(){return this.peek(T.TokenKind.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,t=this.parseName();let n,i;return this.expectOptionalToken(T.TokenKind.COLON)?(n=t,i=this.parseName()):i=t,this.node(e,{kind:g.Kind.FIELD,alias:n,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(T.TokenKind.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){return this.optionalMany(T.TokenKind.PAREN_L,e?this.parseConstArgument:this.parseArgument,T.TokenKind.PAREN_R)}parseArgument(e=!1){const t=this._lexer.token,n=this.parseName();return this.expectToken(T.TokenKind.COLON),this.node(t,{kind:g.Kind.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(T.TokenKind.SPREAD);const t=this.expectOptionalKeyword("on");return!t&&this.peek(T.TokenKind.NAME)?this.node(e,{kind:g.Kind.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:g.Kind.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),this.node(e,!0===this._options.allowLegacyFragmentVariables?{kind:g.Kind.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}:{kind:g.Kind.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if("on"===this._lexer.token.value)throw this.unexpected();return this.parseName()}parseValueLiteral(e){const t=this._lexer.token;switch(t.kind){case T.TokenKind.BRACKET_L:return this.parseList(e);case T.TokenKind.BRACE_L:return this.parseObject(e);case T.TokenKind.INT:return this.advanceLexer(),this.node(t,{kind:g.Kind.INT,value:t.value});case T.TokenKind.FLOAT:return this.advanceLexer(),this.node(t,{kind:g.Kind.FLOAT,value:t.value});case T.TokenKind.STRING:case T.TokenKind.BLOCK_STRING:return this.parseStringLiteral();case T.TokenKind.NAME:switch(this.advanceLexer(),t.value){case"true":return this.node(t,{kind:g.Kind.BOOLEAN,value:!0});case"false":return this.node(t,{kind:g.Kind.BOOLEAN,value:!1});case"null":return this.node(t,{kind:g.Kind.NULL});default:return this.node(t,{kind:g.Kind.ENUM,value:t.value})}case T.TokenKind.DOLLAR:if(e){if(this.expectToken(T.TokenKind.DOLLAR),this._lexer.token.kind===T.TokenKind.NAME)throw(0,y.syntaxError)(this._lexer.source,t.start,`Unexpected variable "$${this._lexer.token.value}" in constant value.`);throw this.unexpected(t)}return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:g.Kind.STRING,value:e.value,block:e.kind===T.TokenKind.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:g.Kind.LIST,values:this.any(T.TokenKind.BRACKET_L,(()=>this.parseValueLiteral(e)),T.TokenKind.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:g.Kind.OBJECT,fields:this.any(T.TokenKind.BRACE_L,(()=>this.parseObjectField(e)),T.TokenKind.BRACE_R)})}parseObjectField(e){const t=this._lexer.token,n=this.parseName();return this.expectToken(T.TokenKind.COLON),this.node(t,{kind:g.Kind.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){const t=[];for(;this.peek(T.TokenKind.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const t=this._lexer.token;return this.expectToken(T.TokenKind.AT),this.node(t,{kind:g.Kind.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let t;if(this.expectOptionalToken(T.TokenKind.BRACKET_L)){const n=this.parseTypeReference();this.expectToken(T.TokenKind.BRACKET_R),t=this.node(e,{kind:g.Kind.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(T.TokenKind.BANG)?this.node(e,{kind:g.Kind.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:g.Kind.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(T.TokenKind.STRING)||this.peek(T.TokenKind.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("schema");const n=this.parseConstDirectives(),i=this.many(T.TokenKind.BRACE_L,this.parseOperationTypeDefinition,T.TokenKind.BRACE_R);return this.node(e,{kind:g.Kind.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:i})}parseOperationTypeDefinition(){const e=this._lexer.token,t=this.parseOperationType();this.expectToken(T.TokenKind.COLON);const n=this.parseNamedType();return this.node(e,{kind:g.Kind.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("scalar");const n=this.parseName(),i=this.parseConstDirectives();return this.node(e,{kind:g.Kind.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:i})}parseObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("type");const n=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:g.Kind.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:i,directives:r,fields:s})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(T.TokenKind.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(T.TokenKind.BRACE_L,this.parseFieldDefinition,T.TokenKind.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),i=this.parseArgumentDefs();this.expectToken(T.TokenKind.COLON);const r=this.parseTypeReference(),s=this.parseConstDirectives();return this.node(e,{kind:g.Kind.FIELD_DEFINITION,description:t,name:n,arguments:i,type:r,directives:s})}parseArgumentDefs(){return this.optionalMany(T.TokenKind.PAREN_L,this.parseInputValueDef,T.TokenKind.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(T.TokenKind.COLON);const i=this.parseTypeReference();let r;this.expectOptionalToken(T.TokenKind.EQUALS)&&(r=this.parseConstValueLiteral());const s=this.parseConstDirectives();return this.node(e,{kind:g.Kind.INPUT_VALUE_DEFINITION,description:t,name:n,type:i,defaultValue:r,directives:s})}parseInterfaceTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("interface");const n=this.parseName(),i=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),s=this.parseFieldsDefinition();return this.node(e,{kind:g.Kind.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:i,directives:r,fields:s})}parseUnionTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("union");const n=this.parseName(),i=this.parseConstDirectives(),r=this.parseUnionMemberTypes();return this.node(e,{kind:g.Kind.UNION_TYPE_DEFINITION,description:t,name:n,directives:i,types:r})}parseUnionMemberTypes(){return this.expectOptionalToken(T.TokenKind.EQUALS)?this.delimitedMany(T.TokenKind.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("enum");const n=this.parseName(),i=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();return this.node(e,{kind:g.Kind.ENUM_TYPE_DEFINITION,description:t,name:n,directives:i,values:r})}parseEnumValuesDefinition(){return this.optionalMany(T.TokenKind.BRACE_L,this.parseEnumValueDefinition,T.TokenKind.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(e,{kind:g.Kind.ENUM_VALUE_DEFINITION,description:t,name:n,directives:i})}parseEnumValueName(){if("true"===this._lexer.token.value||"false"===this._lexer.token.value||"null"===this._lexer.token.value)throw(0,y.syntaxError)(this._lexer.source,this._lexer.token.start,`${i(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("input");const n=this.parseName(),i=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();return this.node(e,{kind:g.Kind.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:i,fields:r})}parseInputFieldsDefinition(){return this.optionalMany(T.TokenKind.BRACE_L,this.parseInputValueDef,T.TokenKind.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===T.TokenKind.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const t=this.parseConstDirectives(),n=this.optionalMany(T.TokenKind.BRACE_L,this.parseOperationTypeDefinition,T.TokenKind.BRACE_R);if(0===t.length&&0===n.length)throw this.unexpected();return this.node(e,{kind:g.Kind.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const t=this.parseName(),n=this.parseConstDirectives();if(0===n.length)throw this.unexpected();return this.node(e,{kind:g.Kind.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const t=this.parseName(),n=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(0===n.length&&0===i.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:g.Kind.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:i,fields:r})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const t=this.parseName(),n=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),r=this.parseFieldsDefinition();if(0===n.length&&0===i.length&&0===r.length)throw this.unexpected();return this.node(e,{kind:g.Kind.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:i,fields:r})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const t=this.parseName(),n=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(0===n.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:g.Kind.UNION_TYPE_EXTENSION,name:t,directives:n,types:i})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const t=this.parseName(),n=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(0===n.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:g.Kind.ENUM_TYPE_EXTENSION,name:t,directives:n,values:i})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const t=this.parseName(),n=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(0===n.length&&0===i.length)throw this.unexpected();return this.node(e,{kind:g.Kind.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:i})}parseDirectiveDefinition(){const e=this._lexer.token,t=this.parseDescription();this.expectKeyword("directive"),this.expectToken(T.TokenKind.AT);const n=this.parseName(),i=this.parseArgumentDefs(),r=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const s=this.parseDirectiveLocations();return this.node(e,{kind:g.Kind.DIRECTIVE_DEFINITION,description:t,name:n,arguments:i,repeatable:r,locations:s})}parseDirectiveLocations(){return this.delimitedMany(T.TokenKind.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(w.DirectiveLocation,t.value))return t;throw this.unexpected(e)}node(e,t){return!0!==this._options.noLocation&&(t.loc=new b.Location(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){const t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw(0,y.syntaxError)(this._lexer.source,t.start,`Expected ${r(e)}, found ${i(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e&&(this.advanceLexer(),!0)}expectKeyword(e){const t=this._lexer.token;if(t.kind!==T.TokenKind.NAME||t.value!==e)throw(0,y.syntaxError)(this._lexer.source,t.start,`Expected "${e}", found ${i(t)}.`);this.advanceLexer()}expectOptionalKeyword(e){const t=this._lexer.token;return t.kind===T.TokenKind.NAME&&t.value===e&&(this.advanceLexer(),!0)}unexpected(e){const t=null!=e?e:this._lexer.token;return(0,y.syntaxError)(this._lexer.source,t.start,`Unexpected ${i(t)}.`)}any(e,t,n){this.expectToken(e);const i=[];for(;!this.expectOptionalToken(n);)i.push(t.call(this));return i}optionalMany(e,t,n){if(this.expectOptionalToken(e)){const e=[];do{e.push(t.call(this))}while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);const i=[];do{i.push(t.call(this))}while(!this.expectOptionalToken(n));return i}delimitedMany(e,t){this.expectOptionalToken(e);const n=[];do{n.push(t.call(this))}while(this.expectOptionalToken(e));return n}advanceLexer(){const{maxTokens:e}=this._options,t=this._lexer.advance();if(void 0!==e&&t.kind!==T.TokenKind.EOF&&(++this._tokenCounter,this._tokenCounter>e))throw(0,y.syntaxError)(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function i(e){const t=e.value;return r(e.kind)+(null!=t?` "${t}"`:"")}function r(e){return(0,S.isPunctuatorTokenKind)(e)?`"${e}"`:e}t.Parser=n})),k=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.printString=function(e){return`"${e.replace(n,i)}"`};const n=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function i(e){return r[e.charCodeAt(0)]}const r=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"]})),_=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BREAK=void 0,t.getEnterLeaveForKind=i,t.getVisitFn=function(e,t,n){const{enter:r,leave:s}=i(e,t);return n?s:r},t.visit=function(e,t,r=b.QueryDocumentKeys){const s=new Map;for(const e of Object.values(g.Kind))s.set(e,i(t,e));let o,u,a,c=Array.isArray(e),l=[e],h=-1,f=[],d=e;const v=[],p=[];do{h++;const e=h===l.length,i=e&&0!==f.length;if(e){if(u=0===p.length?void 0:v[v.length-1],d=a,a=p.pop(),i)if(c){d=d.slice();let e=0;for(const[t,n]of f){const i=t-e;null===n?(d.splice(i,1),e++):d[i]=n}}else{d=Object.defineProperties({},Object.getOwnPropertyDescriptors(d));for(const[e,t]of f)d[e]=t}h=o.index,l=o.keys,f=o.edits,c=o.inArray,o=o.prev}else if(a){if(u=c?h:l[h],d=a[u],null==d)continue;v.push(u)}let g;if(!Array.isArray(d)){var m,y;(0,b.isNode)(d)||(0,j.devAssert)(!1,`Invalid AST Node: ${(0,D.inspect)(d)}.`);const i=e?null===(m=s.get(d.kind))||void 0===m?void 0:m.leave:null===(y=s.get(d.kind))||void 0===y?void 0:y.enter;if(g=null==i?void 0:i.call(t,d,u,a,v,p),g===n)break;if(!1===g){if(!e){v.pop();continue}}else if(void 0!==g&&(f.push([u,g]),!e)){if(!(0,b.isNode)(g)){v.pop();continue}d=g}}var w;void 0===g&&i&&f.push([u,d]),e?v.pop():(o={inArray:c,index:h,keys:l,edits:f,prev:o},c=Array.isArray(d),l=c?d:null!==(w=r[d.kind])&&void 0!==w?w:[],h=-1,f=[],a&&p.push(a),a=d)}while(void 0!==o);return 0!==f.length?f[f.length-1][1]:e},t.visitInParallel=function(e){const t=new Array(e.length).fill(null),r=Object.create(null);for(const s of Object.values(g.Kind)){let o=!1;const u=new Array(e.length).fill(void 0),a=new Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){const{enter:n,leave:r}=i(e[t],s);o||(o=null!=n||null!=r),u[t]=n,a[t]=r}o&&(r[s]={enter(...i){const r=i[0];for(let o=0;o<e.length;o++)if(null===t[o]){var s;const a=null===(s=u[o])||void 0===s?void 0:s.apply(e[o],i);if(!1===a)t[o]=r;else if(a===n)t[o]=n;else if(void 0!==a)return a}},leave(...i){const r=i[0];for(let o=0;o<e.length;o++)if(null===t[o]){var s;const r=null===(s=a[o])||void 0===s?void 0:s.apply(e[o],i);if(r===n)t[o]=n;else if(void 0!==r&&!1!==r)return r}else t[o]===r&&(t[o]=null)}})}return r};const n=Object.freeze({});function i(e,t){const n=e[t];return"object"==typeof n?n:"function"==typeof n?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}t.BREAK=n})),A=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.print=function(e){return(0,_.visit)(e,n)};const n={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>i(e.definitions,"\n\n")},OperationDefinition:{leave(e){const t=s("(",i(e.variableDefinitions,", "),")"),n=i([e.operation,i([e.name,t]),i(e.directives," ")]," ");return("query"===n?"":n+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+": "+t+s(" = ",n)+s(" ",i(r," "))},SelectionSet:{leave:({selections:e})=>r(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:u}){const a=s("",e,": ")+t;let c=a+s("(",i(n,", "),")");return c.length>80&&(c=a+s("(\n",o(i(n,"\n")),"\n)")),i([c,i(r," "),u]," ")}},Argument:{leave:({name:e,value:t})=>e+": "+t},FragmentSpread:{leave:({name:e,directives:t})=>"..."+e+s(" ",i(t," "))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>i(["...",s("on ",e),i(t," "),n]," ")},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:o})=>`fragment ${e}${s("(",i(n,", "),")")} on ${t} ${s("",i(r," ")," ")}`+o},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?(0,E.printBlockString)(e):(0,k.printString)(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+i(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+i(e,", ")+"}"},ObjectField:{leave:({name:e,value:t})=>e+": "+t},Directive:{leave:({name:e,arguments:t})=>"@"+e+s("(",i(t,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>s("",e,"\n")+i(["schema",i(t," "),r(n)]," ")},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+": "+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>s("",e,"\n")+i(["scalar",t,i(n," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:o,fields:u})=>s("",e,"\n")+i(["type",t,s("implements ",i(n," & ")),i(o," "),r(u)]," ")},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:a})=>s("",e,"\n")+t+(u(n)?s("(\n",o(i(n,"\n")),"\n)"):s("(",i(n,", "),")"))+": "+r+s(" ",i(a," "))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:o})=>s("",e,"\n")+i([t+": "+n,s("= ",r),i(o," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:o,fields:u})=>s("",e,"\n")+i(["interface",t,s("implements ",i(n," & ")),i(o," "),r(u)]," ")},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>s("",e,"\n")+i(["union",t,i(n," "),s("= ",i(r," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:o})=>s("",e,"\n")+i(["enum",t,i(n," "),r(o)]," ")},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>s("",e,"\n")+i([t,i(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:o})=>s("",e,"\n")+i(["input",t,i(n," "),r(o)]," ")},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:a})=>s("",e,"\n")+"directive @"+t+(u(n)?s("(\n",o(i(n,"\n")),"\n)"):s("(",i(n,", "),")"))+(r?" repeatable":"")+" on "+i(a," | ")},SchemaExtension:{leave:({directives:e,operationTypes:t})=>i(["extend schema",i(e," "),r(t)]," ")},ScalarTypeExtension:{leave:({name:e,directives:t})=>i(["extend scalar",e,i(t," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:o})=>i(["extend type",e,s("implements ",i(t," & ")),i(n," "),r(o)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:o})=>i(["extend interface",e,s("implements ",i(t," & ")),i(n," "),r(o)]," ")},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>i(["extend union",e,i(t," "),s("= ",i(n," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>i(["extend enum",e,i(t," "),r(n)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>i(["extend input",e,i(t," "),r(n)]," ")}};function i(e,t=""){var n;return null!==(n=null==e?void 0:e.filter((e=>e)).join(t))&&void 0!==n?n:""}function r(e){return s("{\n",o(i(e,"\n")),"\n}")}function s(e,t,n=""){return null!=t&&""!==t?e+t+n:""}function o(e){return s(" ",e.replace(/\n/g,"\n "))}function u(e){var t;return null!==(t=null==e?void 0:e.some((e=>e.includes("\n"))))&&void 0!==t&&t}})),F=function(e){var t=e.name,n=e.type;this.uri=e.uri,this.name=t,this.type=n},$=function(e){return"undefined"!=typeof File&&e instanceof File||"undefined"!=typeof Blob&&e instanceof Blob||e instanceof F},q=function e(t,n,i){var r;void 0===n&&(n=""),void 0===i&&(i=$);var s=new Map;function o(e,t){var n=s.get(t);n?n.push.apply(n,e):s.set(t,e)}if(i(t))r=null,o([n],t);else{var u=n?n+".":"";if("undefined"!=typeof FileList&&t instanceof FileList)r=Array.prototype.map.call(t,(function(e,t){return o([""+u+t],e),null}));else if(Array.isArray(t))r=t.map((function(t,n){var r=e(t,""+u+n,i);return r.files.forEach(o),r.clone}));else if(t&&t.constructor===Object)for(var a in r={},t){var c=e(t[a],""+u+a,i);c.files.forEach(o),r[a]=c.clone}else r=t}return{clone:r,files:s}},U=$,C="object"==typeof self?self.FormData:window.FormData,V=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.defaultJsonSerializer=void 0,t.defaultJsonSerializer={parse:JSON.parse,stringify:JSON.stringify}})),M=l((function(e,t){var n=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(C),r=function(e){return U(e)||null!==e&&"object"==typeof e&&"function"==typeof e.pipe};t.default=function(e,t,n,s){void 0===s&&(s=V.defaultJsonSerializer);var o=q({query:e,variables:t,operationName:n},"",r),u=o.clone,a=o.files;if(0===a.size){if(!Array.isArray(e))return s.stringify(u);if(void 0!==t&&!Array.isArray(t))throw new Error("Cannot create request body with given variable type, array expected");var c=e.reduce((function(e,n,i){return e.push({query:n,variables:t?t[i]:void 0}),e}),[]);return s.stringify(c)}var l=new("undefined"==typeof FormData?i.default:FormData);l.append("operations",s.stringify(u));var h={},f=0;return a.forEach((function(e){h[++f]=e})),l.append("map",s.stringify(h)),f=0,a.forEach((function(e,t){l.append(""+ ++f,t)})),l}})),P=l((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.parseBatchRequestsExtendedArgs=t.parseRawRequestExtendedArgs=t.parseRequestExtendedArgs=t.parseBatchRequestArgs=t.parseRawRequestArgs=t.parseRequestArgs=void 0,t.parseRequestArgs=function(e,t,n){return e.document?e:{document:e,variables:t,requestHeaders:n,signal:void 0}},t.parseRawRequestArgs=function(e,t,n){return e.query?e:{query:e,variables:t,requestHeaders:n,signal:void 0}},t.parseBatchRequestArgs=function(e,t){return e.documents?e:{documents:e,requestHeaders:t,signal:void 0}},t.parseRequestExtendedArgs=function(e,t,n,i){return e.document?e:{url:e,document:t,variables:n,requestHeaders:i,signal:void 0}},t.parseRawRequestExtendedArgs=function(e,t,n,i){return e.query?e:{url:e,query:t,variables:n,requestHeaders:i,signal:void 0}},t.parseBatchRequestsExtendedArgs=function(e,t,n){return e.documents?e:{url:e,documents:t,requestHeaders:n,signal:void 0}}})),L=l((function(e,t){var n,i=c&&c.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});Object.defineProperty(t,"__esModule",{value:!0}),t.ClientError=void 0;var r=function(e){function t(n,i){var r=this,s=t.extractMessage(n)+": "+JSON.stringify({response:n,request:i});return r=e.call(this,s)||this,Object.setPrototypeOf(r,t.prototype),r.response=n,r.request=i,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,t),r}return i(t,e),t.extractMessage=function(e){try{return e.errors[0].message}catch(t){return"GraphQL Error (Code: "+e.status+")"}},t}(Error);t.ClientError=r})),R=l((function(e,t){var n=c&&c.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)},i=c&&c.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function u(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,u)}a((i=i.apply(e,t||[])).next())}))},r=c&&c.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLWebSocketClient=void 0;var s="ping",o="pong",u="complete",a=function(){function e(e,t,n){this._type=e,this._payload=t,this._id=n}return Object.defineProperty(e.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"payload",{get:function(){return this._payload},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){var e={type:this.type};return null!=this.id&&null!=this.id&&(e.id=this.id),null!=this.payload&&null!=this.payload&&(e.payload=this.payload),JSON.stringify(e)},enumerable:!1,configurable:!0}),e.parse=function(t,n){var i=JSON.parse(t),r=i.id;return new e(i.type,n(i.payload),r)},e}(),l=function(){function e(e,t){var c=this,l=t.onInit,d=t.onAcknowledged,v=t.onPing,p=t.onPong;this.socketState={acknowledged:!1,lastRequestId:0,subscriptions:{}},this.socket=e,e.onopen=function(){return i(c,void 0,void 0,(function(){var t,n,i,s;return r(this,(function(r){switch(r.label){case 0:return this.socketState.acknowledged=!1,this.socketState.subscriptions={},n=(t=e).send,i=h,l?[4,l()]:[3,2];case 1:return s=r.sent(),[3,3];case 2:s=null,r.label=3;case 3:return n.apply(t,[i.apply(void 0,[s]).text]),[2]}}))}))},e.onclose=function(){c.socketState.acknowledged=!1,c.socketState.subscriptions={}},e.onerror=function(e){console.error(e)},e.onmessage=function(t){try{var i=(void 0===y&&(y=function(e){return e}),a.parse(t.data,y));switch(i.type){case"connection_ack":return void(c.socketState.acknowledged?console.warn("Duplicate CONNECTION_ACK message ignored"):(c.socketState.acknowledged=!0,d&&d(i.payload)));case s:return void(v?v(i.payload).then((function(t){return e.send(f(t).text)})):e.send(f(null).text));case o:return void(p&&p(i.payload))}if(!c.socketState.acknowledged)return;if(null==i.id||!c.socketState.subscriptions[i.id])return;var r=c.socketState.subscriptions[i.id],l=r.query,h=r.variables,m=r.subscriber;switch(i.type){case"next":return!i.payload.errors&&i.payload.data&&m.next&&m.next(i.payload.data),void(i.payload.errors&&m.error&&m.error(new L.ClientError(n(n({},i.payload),{status:200}),{query:l,variables:h})));case"error":return void(m.error&&m.error(new L.ClientError({errors:i.payload,status:200},{query:l,variables:h})));case u:return m.complete&&m.complete(),void delete c.socketState.subscriptions[i.id]}}catch(t){console.error(t),e.close(1006)}var y;e.close(4400,"Unknown graphql-ws message.")}}return e.prototype.makeSubscribe=function(e,t,n,i){var r,s,o=this,c=(this.socketState.lastRequestId++).toString();return this.socketState.subscriptions[c]={query:e,variables:n,subscriber:i},this.socket.send((r=c,s={query:e,operationName:t,variables:n},new a("subscribe",s,r)).text),function(){o.socket.send(function(e){return new a(u,void 0,e)}(c).text),delete o.socketState.subscriptions[c]}},e.prototype.rawRequest=function(e,t){var n=this;return new Promise((function(i,r){var s;n.rawSubscribe(e,{next:function(e,t){return s={data:e,extensions:t}},error:r,complete:function(){return i(s)}},t)}))},e.prototype.request=function(e,t){var n=this;return new Promise((function(i,r){var s;n.subscribe(e,{next:function(e){return s=e},error:r,complete:function(){return i(s)}},t)}))},e.prototype.subscribe=function(e,t,n){var i=B.resolveRequestDocument(e);return this.makeSubscribe(i.query,i.operationName,n,t)},e.prototype.rawSubscribe=function(e,t,n){return this.makeSubscribe(e,void 0,n,t)},e.prototype.ping=function(e){this.socket.send(function(e){return new a(s,e,void 0)}(e).text)},e.prototype.close=function(){this.socket.close(1e3)},e.PROTOCOL="graphql-transport-ws",e}();function h(e){return new a("connection_init",e)}function f(e){return new a(o,e,void 0)}t.GraphQLWebSocketClient=l})),B=l((function(e,t){var n=c&&c.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)},i=c&&c.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=c&&c.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=c&&c.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},o=c&&c.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(r,s){function o(e){try{a(i.next(e))}catch(e){s(e)}}function u(e){try{a(i.throw(e))}catch(e){s(e)}}function a(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,u)}a((i=i.apply(e,t||[])).next())}))},u=c&&c.__generator||function(e,t){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((r=(r=o.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=c&&c.__rest||function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n},l=c&&c.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GraphQLWebSocketClient=t.gql=t.resolveRequestDocument=t.batchRequests=t.request=t.rawRequest=t.GraphQLClient=t.ClientError=void 0;var f=s(h),d=f,v=l(M);Object.defineProperty(t,"ClientError",{enumerable:!0,get:function(){return L.ClientError}});var p=function(e){var t={};return e&&("undefined"!=typeof Headers&&e instanceof Headers||e instanceof d.Headers?t=function(e){var t={};return e.forEach((function(e,n){t[n]=e})),t}(e):Array.isArray(e)?e.forEach((function(e){t[e[0]]=e[1]})):t=e),t},m=function(e){return e.replace(/([\s,]|#[^\n\r]+)+/g," ").trim()},y=function(e){var t=e.url,i=e.query,r=e.variables,s=e.operationName,a=e.headers,c=e.fetch,l=e.fetchOptions;return o(void 0,void 0,void 0,(function(){var e;return u(this,(function(o){switch(o.label){case 0:return e=v.default(i,r,s,l.jsonSerializer),[4,c(t,n({method:"POST",headers:n(n({},"string"==typeof e?{"Content-Type":"application/json"}:{}),a),body:e},l))];case 1:return[2,o.sent()]}}))}))},b=function(e){var t=e.url,i=e.query,r=e.variables,s=e.operationName,a=e.headers,c=e.fetch,l=e.fetchOptions;return o(void 0,void 0,void 0,(function(){var e;return u(this,(function(o){switch(o.label){case 0:return e=function(e){var t=e.query,n=e.variables,i=e.operationName,r=e.jsonSerializer;if(!Array.isArray(t)){var s=["query="+encodeURIComponent(m(t))];return n&&s.push("variables="+encodeURIComponent(r.stringify(n))),i&&s.push("operationName="+encodeURIComponent(i)),s.join("&")}if(void 0!==n&&!Array.isArray(n))throw new Error("Cannot create query with given variable type, array expected");var o=t.reduce((function(e,t,i){return e.push({query:m(t),variables:n?r.stringify(n[i]):void 0}),e}),[]);return"query="+encodeURIComponent(r.stringify(o))}({query:i,variables:r,operationName:s,jsonSerializer:l.jsonSerializer}),[4,c(t+"?"+e,n({method:"GET",headers:a},l))];case 1:return[2,o.sent()]}}))}))},w=function(){function e(e,t){this.url=e,this.options=t||{}}return e.prototype.rawRequest=function(e,t,i){return o(this,void 0,void 0,(function(){var r,s,o,c,l,h,d,v,m,y;return u(this,(function(){return r=P.parseRawRequestArgs(e,t,i),o=(s=this.options).headers,l=void 0===(c=s.fetch)?f.default:c,d=void 0===(h=s.method)?"POST":h,v=a(s,["headers","fetch","method"]),m=this.url,void 0!==r.signal&&(v.signal=r.signal),y=S(r.query).operationName,[2,g({url:m,query:r.query,variables:r.variables,headers:n(n({},p(j(o))),p(r.requestHeaders)),operationName:y,fetch:l,method:d,fetchOptions:v})]}))}))},e.prototype.request=function(e,t,i){return o(this,void 0,void 0,(function(){var r,s,o,c,l,h,d,v,m,y,b;return u(this,(function(u){switch(u.label){case 0:return r=P.parseRequestArgs(e,t,i),o=(s=this.options).headers,l=void 0===(c=s.fetch)?f.default:c,d=void 0===(h=s.method)?"POST":h,v=a(s,["headers","fetch","method"]),m=this.url,void 0!==r.signal&&(v.signal=r.signal),y=S(r.document),b=y.operationName,[4,g({url:m,query:y.query,variables:r.variables,headers:n(n({},p(j(o))),p(r.requestHeaders)),operationName:b,fetch:l,method:d,fetchOptions:v})];case 1:return[2,u.sent().data]}}))}))},e.prototype.batchRequests=function(e,t){return o(this,void 0,void 0,(function(){var i,r,s,o,c,l,h,d,v,m,y;return u(this,(function(u){switch(u.label){case 0:return i=P.parseBatchRequestArgs(e,t),s=(r=this.options).headers,c=void 0===(o=r.fetch)?f.default:o,h=void 0===(l=r.method)?"POST":l,d=a(r,["headers","fetch","method"]),v=this.url,void 0!==i.signal&&(d.signal=i.signal),m=i.documents.map((function(e){return S(e.document).query})),y=i.documents.map((function(e){return e.variables})),[4,g({url:v,query:m,variables:y,headers:n(n({},p(j(s))),p(i.requestHeaders)),operationName:void 0,fetch:c,method:h,fetchOptions:d})];case 1:return[2,u.sent().data]}}))}))},e.prototype.setHeaders=function(e){return this.options.headers=e,this},e.prototype.setHeader=function(e,t){var n,i=this.options.headers;return i?i[e]=t:this.options.headers=((n={})[e]=t,n),this},e.prototype.setEndpoint=function(e){return this.url=e,this},e}();function g(e){var t=e.url,i=e.query,r=e.variables,s=e.headers,c=e.operationName,l=e.fetch,h=e.method,f=void 0===h?"POST":h,d=e.fetchOptions;return o(this,void 0,void 0,(function(){var e,o,h,v,p,m,w,g,O,T;return u(this,(function(u){switch(u.label){case 0:return e="POST"===f.toUpperCase()?y:b,o=Array.isArray(i),[4,e({url:t,query:i,variables:r,operationName:c,headers:s,fetch:l,fetchOptions:d})];case 1:return[4,E(h=u.sent(),d.jsonSerializer)];case 2:if(v=u.sent(),p=o&&Array.isArray(v)?!v.some((function(e){return!e.data})):!!v.data,m=!v.errors||"all"===d.errorPolicy||"ignore"===d.errorPolicy,h.ok&&m&&p)return w=h.headers,g=h.status,O=a(v,["errors"]),T="ignore"===d.errorPolicy?O:v,[2,n(n({},o?{data:T}:T),{headers:w,status:g})];throw new L.ClientError(n(n({},"string"==typeof v?{error:v}:v),{status:h.status,headers:h.headers}),{query:i,variables:r})}}))}))}function O(e,t,i,r){return o(this,void 0,void 0,(function(){var s;return u(this,(function(){return s=P.parseRequestExtendedArgs(e,t,i,r),[2,new w(s.url).request(n({},s))]}))}))}function E(e,t){return void 0===t&&(t=V.defaultJsonSerializer),o(this,void 0,void 0,(function(){var n,i,r;return u(this,(function(s){switch(s.label){case 0:return e.headers.forEach((function(e,t){"content-type"===t.toLowerCase()&&(n=e)})),n&&n.toLowerCase().startsWith("application/json")?(r=(i=t).parse,[4,e.text()]):[3,2];case 1:return[2,r.apply(i,[s.sent()])];case 2:return[2,e.text()]}}))}))}function T(e){var t,n=void 0,i=e.definitions.filter((function(e){return"OperationDefinition"===e.kind}));return 1===i.length&&(n=null===(t=i[0].name)||void 0===t?void 0:t.value),n}function S(e){if("string"==typeof e){var t=void 0;try{t=T(N.parse(e))}catch(e){}return{query:e,operationName:t}}var n=T(e);return{query:A.print(e),operationName:n}}function j(e){return"function"==typeof e?e():e}t.GraphQLClient=w,t.rawRequest=function(e,t,i,r){return o(this,void 0,void 0,(function(){var s;return u(this,(function(){return s=P.parseRawRequestExtendedArgs(e,t,i,r),[2,new w(s.url).rawRequest(n({},s))]}))}))},t.request=O,t.batchRequests=function(e,t,i){return o(this,void 0,void 0,(function(){var r;return u(this,(function(){return r=P.parseBatchRequestsExtendedArgs(e,t,i),[2,new w(r.url).batchRequests(n({},r))]}))}))},t.default=O,t.resolveRequestDocument=S,t.gql=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return e.reduce((function(e,n,i){return""+e+n+(i in t?t[i]:"")}),"")},Object.defineProperty(t,"GraphQLWebSocketClient",{enumerable:!0,get:function(){return R.GraphQLWebSocketClient}})}));class G{static getQueryParams(e){const t=new Map,n=/[?&]?([^=]+)=([^&]*)/g;let i;for(e=(e=window.unescape(e)).split("+").join(" ");i=n.exec(e);)t.set(window.decodeURIComponent(i[1]),i[2]);return t.set("urlBase",this.getUrlBase()),window.moduleID&&window.URIServiceBroker&&(t.set("moduleID",window.moduleID),t.set("URIServiceBroker",window.URIServiceBroker)),t}static getUrlBase(){return window.mock_url?window.mock_url:`${location.protocol}//${location.hostname}${location.port?":"+location.port:""}`}static getResourceIdFromUrlToken(e){try{const t=e.split("/");return t[1]?atob(t[1]):null}catch(e){throw new Error("Erro ao obter resourceId:"+e)}}static getPkObjectFromUrlToken(e){try{let t=e.split("/")[2];return t?t.indexOf("&")>-1?JSON.parse(atob(t.split("&")[0])):JSON.parse(atob(t)):null}catch(e){throw new Error("Erro ao obter a PK do objeto:"+e)}}}class J{constructor(e,t,n){this.req=e,this.resolve=t,this.reject=n}putVariable(e,t){this.req.values[e]=t}reCall(){return Q.get().callGraphQL(this.req).then(this.resolve,this.reject)}putTXPro(t,n){this.req&&this.req.values&&(this.req.values.changes||[]).length&&this.req.values.changes[0].fields.push({dataType:e.TEXT,fieldName:`${a.DATA_UNIT_TRANSIENT_PREFIX_NAME}${t}`,value:n})}}class H{constructor(e,t,n,i){this.serviceName=e,this.requestBody=t,this.successCallback=n,this.errorCallback=i}reCall(e){return e&&(this.requestBody=e),Q.get().callServiceBroker(this.serviceName,this.requestBody).then(this.successCallback,this.errorCallback)}}var z=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(n){t[n]=e[n]&&function(t){return new Promise((function(i,r){!function(e,t,n,i){Promise.resolve(i).then((function(t){e({value:t,done:n})}),t)}(i,r,(t=e[n](t)).done,t.value)}))}}};class Q{constructor(){this.ready=!0,this.watingRequestsById=new Map}static get(){if(!Q.instance){Q.instance=new Q;const e=document.querySelector(this.appTagName);null===e?Q.instance.resume():(!0===t.getContextValue("__SNK__APPLICATION__LOADING__")&&Q.instance.pause(),e.addEventListener("applicationLoading",(()=>Q.instance.pause())),e.addEventListener("applicationLoaded",(()=>Q.instance.resume())))}return this.instance.application=t.getContextValue("__SNK__APPLICATION__"),this.instance}static getGraphQLPath(){return n.isEmpty(this.instance.graphqlPath)&&null!=this.instance.application&&(this.instance.graphqlPath=`/${this.instance.application.getModuleName()}/graphql`),this.instance.graphqlPath}static addRequestListener(e){Q.requestListener.indexOf(e)<0&&Q.requestListener.push(e)}static removeRequestListener(e){const t=Q.requestListener.indexOf(e);t>-1&&Q.requestListener.splice(t,1)}processGraphQlErrorInfo(e){var t,n;const s="Falha detectada",o=e[0];if(o.length>0){const e=o[0],u=(null==e?void 0:e.message)?null==e?void 0:e.message:"Não há mensagem de erro",a=(null===(t=null==e?void 0:e.extensions)||void 0===t?void 0:t.level)?e.extensions.level:"ERROR",c=(null===(n=null==e?void 0:e.extensions)||void 0===n?void 0:n.code)?e.extensions.code:"";return"WARNING"===a?new r(s,u,c):new i(s,u,c)}return new i(s,"Não há informações sobre o erro")}processServiceBrokerErrorInfo(e){const t="Falha detectada";let n,s,{statusMessage:o,tsError:u}=e||{};return o||(o="Não há informações sobre o erro"),u&&(n=u.tsErrorCode,s=u.tsErrorLevel),"WARNING"===s?new r(t,o,n):new i(t,o,n)}async callGraphQL(e,t=!1){var n;this.ready&&(this.pause(),window.requestAnimationFrame((()=>this.resume())));const i=this.getReqKey(e);if(e.queryID=i,e.values.queryID=i,Q.clientEventsByID){e.values.registeredEventListeners=[];for(let[t]of Q.clientEventsByID)e.values.registeredEventListeners.push(t)}return this.ready?new Promise((async(n,r)=>{let s=this.getQueryTemplate(e);const o=await this.fecthGraphQL([{document:s,variables:e.values}],t);o.errors.length>0?await this.proccesGraphQLClientEvents(null==o?void 0:o.extensions,e,n,r)||r(this.processGraphQlErrorInfo(o.errors)):(n(o.data[0][i]),await this.proccesGraphQLClientEvents(null==o?void 0:o.extensions,e,n,r))})):(this.watingRequestsById.has(i)||this.watingRequestsById.set(i,new K(e,t)),null===(n=this.watingRequestsById.get(i))||void 0===n?void 0:n.promise)}resolveURL(){return G.getUrlBase()}async proccesGraphQLClientEvents(e,t,n,i){if(null==e)return!1;for(const s in e){const{clientEvents:o}=e[s];if(!o)return!1;for(const e in o){if(!Q.hasClientEvent(e))throw console.warn(`Client event ${e} not registered`),new r("ClientEvent não registrado",`Ocorreu o client event ${e} porém não há client event registrado na aplicação.`);Q.clientEventsByID.get(e).forEach((async r=>{await r({id:e,content:JSON.parse(o[e])},new J(t,n,i))}))}return Object.keys(o).length>0}return!1}async processServiceBrokerClientEvents(e){var t,n,i,r,s,o,u,a;const{clientEvents:c,serviceName:l,payloadJson:h,accept:f,reject:d}=e;if(!(null==c?void 0:c.length))return;const v=new H(l,h,f,d);try{for(var p,m=!0,y=z(c);!(t=(p=await y.next()).done);){r=p.value,m=!1;try{const e=r;if(Q.hasClientEvent(e.id)){const t=Q.clientEventsByID.get(e.id),n={id:e.id,content:e};try{for(var b,w=!0,g=(o=void 0,z(t));!(s=(b=await g.next()).done);){a=b.value,w=!1;try{const e=a;await e(n,v)}finally{w=!0}}}catch(e){o={error:e}}finally{try{w||s||!(u=g.return)||await u.call(g)}finally{if(o)throw o.error}}}}finally{m=!0}}}catch(e){n={error:e}}finally{try{m||t||!(i=y.return)||await i.call(y)}finally{if(n)throw n.error}}}async processPrinting(e){"true"===(null==e?void 0:e.pendingPrinting)&&await u.getInstance().processPendingPrinting(null==e?void 0:e.transactionId),"localPrintings"in e&&u.getInstance().processLocalPrinting(null==e?void 0:e.localPrintings)}getContext(e){var t;const i=G.getQueryParams(location.search);return{baseUrl:`${this.resolveURL()}/${e}/service.sbr`,appName:window.APPLICATION_NAME||"SankhyaBlocks",mgeSession:`${window.mgeSession||i.get("mgeSession")}`,globalID:window.GLOBALID||n.generateUUID(),resourceID:window.resourceID||(null===(t=window.workspace)||void 0===t?void 0:t.resourceID)}}async callServiceBroker(e,t,n){return new Promise((async(r,o)=>{const u=e.split("@"),[a,c]=2===u.length?u:["mge",e],l=this.getContext(a);let h=`${l.baseUrl}?serviceName=${c}&counter=21&application=${l.appName}&outputType=json&preventTransform=false&mgeSession=${l.mgeSession}&resourceID=${l.resourceID}&globalID=${l.globalID}&allowConcurrentCalls=true`;h=await this.addUrlParams(n,h),document.cookie=`JSESSIONID=${l.mgeSession};`;const f=new XMLHttpRequest;var d={};"string"==typeof t&&(t=s.stringToObject(t)),t.hasOwnProperty("requestBody")?d=t:d.requestBody=t;for(let[e]of Q.clientEventsByID)d.requestBody.hasOwnProperty("clientEventList")||(d.requestBody.clientEventList={clientEvent:[]}),d.requestBody.clientEventList.clientEvent.push({$:e});Q.requestListener.forEach((e=>e.onRequestStart({url:h,requestBody:t}))),f.open("POST",h,!0),f.withCredentials=!0,f.send(s.objectToString(d)),f.onreadystatechange=async()=>{var n;if(4==f.readyState&&200==f.status)try{const t=JSON.parse(f.responseText);await this.processPrinting(t),this.isServiceBrokerError(t)?o(this.processServiceBrokerErrorInfo(t)):t.status==Q.SERVICE_BROKER_STATUS.SERVICE_CANCELED?t.statusMessage&&console.debug(`[DataFetcher] ${t.statusMessage}`):(r(t.responseBody),t.status==Q.SERVICE_BROKER_STATUS.INFO&&(null===(n=this.application)||void 0===n||n.info(t.statusMessage))),this.processServiceBrokerClientEvents({clientEvents:null==t?void 0:t.clientEvents,serviceName:e,payloadJson:d,accept:r,reject:o})}catch(e){console.warn(`Erro ao executar serviço: ${e}`),o(new i("Erro ao executar serviço",e))}else 4==f.readyState&&200!=f.status&&o(new i(`Erro ao executar serviço: ${e}`,f.responseText));Q.requestListener.forEach((e=>e.onRequestEnd({url:h,requestBody:t})))}}))}async addUrlParams(e,t){var i;const r=(null==e?void 0:e.urlParams)||{},s=await(null===(i=this.application)||void 0===i?void 0:i.getAttributeFromHTMLWrapper("VSS"));if(n.isEmpty(s)||(r.vss=s),0===Object.keys(r).length)return t;-1===t.indexOf("?")&&(t+="?");for(const e in r)t+=`&${e}=${r[e]}`;return t}isServiceBrokerError(e){return!e.hasOwnProperty("status")||e.status==Q.SERVICE_BROKER_STATUS.ERROR||e.status==Q.SERVICE_BROKER_STATUS.TIMEOUT}getReqKey(e){return window.btoa(n.hashCode(`${e.query}${JSON.stringify(e.values||"")}`)).replace(/=/g,"")}getQueryTemplate(e){return(e.query||"").replaceAll("$queryAlias$",e.queryID)}pause(){this.ready=!1}async resume(){if(this.ready=!0,this.watingRequestsById.size>0){const e=this.watingRequestsById;this.watingRequestsById=new Map,this.executePendingRequest(e)}}async executePendingRequest(e){const t=[];let n=!0;e.forEach((e=>{const i=this.getQueryTemplate(e.request);t.push({document:i,variables:Object.assign({},e.request.values)}),n=n&&e.quietMode}));const r=await this.fecthGraphQL(t,n),{data:s,errors:u,extensions:a}=r;u.forEach((t=>{Object.entries(t).forEach((async([n,r])=>{const s=e.get(r.request.variables[r.index].queryID),u=await this.proccesGraphQLClientEvents(a,s.request,s.resolve,s.reject);Promise.race([s.promise,new Promise((e=>{e(!1)}))]).then((n=>{var s,c;u&&!1!==n||(Object.keys(t[0].extensions).includes("SERVICE_CANCELED")||Object.keys(a).includes("isServiceCancelled")?((null===(s=e.get(r.request.variables[r.index].queryID))||void 0===s?void 0:s.reject)||Promise.reject)(new o("Service canceled",r.message)):((null===(c=e.get(r.request.variables[r.index].queryID))||void 0===c?void 0:c.reject)||Promise.reject)(new i("Falha detectada",r.message)))}))}))})),s.forEach((t=>{Object.entries(t).forEach((async([t,n])=>{const i=e.get(t);await this.proccesGraphQLClientEvents(a,i.request,i.resolve,i.reject),((null==i?void 0:i.resolve)||Promise.resolve)(n)}))}))}buildGraphQlURL(e){const t=G.getQueryParams(location.search),n=`${window.mgeSession||t.get("mgeSession")}`;let i=`${this.resolveURL()+Q.getGraphQLPath()}`;return n&&(i+=`?mgeSession=${n}`),e&&(i+=(i.indexOf("?")>-1?"&":"?")+"quietMode=true"),i}async fecthGraphQL(e,t){const n=[],r=[],s=[],o=this.buildGraphQlURL(t);Q.requestListener.forEach((t=>t.onRequestStart({url:o,requestBody:e})));try{(await B.batchRequests(o,e,{"Content-Type":`application/json; charset=${window.SERVER_ENCODING||"UTF-8"}`})).forEach(((t,i)=>{var o;(null===(o=null==t?void 0:t.errors)||void 0===o?void 0:o.length)>0?r.push(t.errors.map((t=>this.normalizeErrorResponse(t,e,i)))):n.push(t.data),t.extensions&&s.push(t.extensions)}))}catch(t){if(this.isHttpError(t))throw Q.requestListener.forEach((t=>t.onRequestEnd({url:o,requestBody:e}))),new i("Falha de comunicação",t.message);{const e=t.request;Object.entries(t.response).forEach((([t,i])=>{i.errors?r.push(i.errors.map((n=>(n.request=e,n.index=Number(t),n)))):i.data&&n.push(i.data)}))}}return Q.requestListener.forEach((t=>t.onRequestEnd({url:o,requestBody:e}))),{data:n,errors:r,extensions:s}}isHttpError(e){var t;return!e.response&&!e.request||(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.status)>=300}normalizeErrorResponse(e,t,n){const i=Object.assign({},t[n]),{variables:r}=i;return i.variables=[],i.variables[n]=r,e.request=i,e.index=Number(n),e}static addClientEvent(e,t){let n=Q.clientEventsByID.get(e);if(null!=n){if(n.some((e=>e.toString()===t.toString())))return;n.push(t)}else Q.clientEventsByID.set(e,[t])}static hasClientEvent(e){return Q.clientEventsByID.has(e)}static removeClientEvent(e){return Q.clientEventsByID.delete(e)}}Q.appTagName="snk-application",Q.requestListener=[],Q.SERVICE_BROKER_STATUS={ERROR:0,INFO:2,OK:1,TIMEOUT:3,SERVICE_CANCELED:4},Q.clientEventsByID=new Map;class K{constructor(e,t){this._resolve=()=>{},this._reject=()=>{},this._request=void 0,this._request=e,this._promisse=new Promise(((e,t)=>{this._resolve=e,this._reject=t})),this._quietMode=t}get resolve(){return this._resolve}get reject(){return this._reject}get promise(){return this._promisse}get request(){return this._request}get quietMode(){return this._quietMode}}export{Q as D,G as U,B as d}