smart-webcomponents-react
Version:
[](https://jqwidgets.com/license/)
6 lines (4 loc) • 230 kB
JavaScript
/* Smart UI v23.0.8 (2025-05-13)
Copyright (c) 2011-2024 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart.Utilities.Assign("Grid.Dialog",class{_createOverlay(){const e=document.createElement("div");return e.onpointerdown=function(){return!1},e.onpointerup=function(){return!1},e.onmousedown=function(){return!1},e.onclick=function(){},e.classList.add("smart-grid-dialog-overlay"),e}_createFormulaBuilderComponent(e,t){const a=this;e.innerHTML=`\n <div class="smart-formula-builder">\n <div class="smart-flex" style="justify-content: space-between;">\n <div style="flex-direction: column; display: flex;" class="smart-input-section">\n <label for="smart-formula-select">Select Formula:</label>\n <smart-input drop-down-max-height="250" drop-down-height="auto" auto-adjust-width drop-down-button-position="right" readonly class="underlined smart-formula-select">\n\n </smart-input>\n </div>\n <div style="column-gap: 10px;" class="smart-flex">\n <div style="flex-direction: column; display: flex;" class="smart-input-section">\n <label for="column-a">Column A:</label>\n <smart-input drop-down-max-height="250" drop-down-height="auto" auto-adjust-width drop-down-button-position="right" readonly class="underlined smart-column-a"></smart-input>\n </div>\n\n <div style="flex-direction: column; display: flex;" class="smart-input-section">\n <label for="column-b">Column B:</label>\n <smart-input drop-down-max-height="250" drop-down-height="auto" auto-adjust-width drop-down-button-position="right" readonly class="underlined smart-column-b"></smart-input>\n </div>\n </div>\n </div>\n <div style="border: 1px solid var(--smart-border); background: var(--smart-surface); padding: 10px; margin-top: 10px; margin-bottom:10px;" class="smart-hidden smart-documentation">\n <span class="smart-formula-doc">Select a formula to see tips and documentation here.</span>\n </div>\n\n <div class="smart-output">\n <smart-button style="margin-top:10px;" class="success smart-generate-formula">${a.localize("generate")}</smart-button>\n <p class="smart-generated-formula"><span class="smart-formula-result"></span></p>\n </div>\n </div>\n `;const l=e.querySelector(".smart-formula-select"),i=e.querySelector(".smart-column-a"),n=e.querySelector(".smart-column-b"),o=e.querySelector(".smart-documentation"),s=e.querySelector(".smart-formula-doc"),r=e.querySelector(".smart-generate-formula"),d=e.querySelector(".smart-formula-result");l.dataSource=[{label:"SUM",value:"sum"},{label:"AVERAGE",value:"average"},{label:"MULTIPLY",value:"multiply"},{label:"DIVIDE",value:"divide"},{label:"SUMIF",value:"sumif"},{label:"IF",value:"if"},{label:"MIN",value:"min"},{label:"MAX",value:"max"},{label:"CONCATENATE",value:"concatenate"}];let c=a.columns.map((e=>e.label));i.dataSource=[...c],n.dataSource=[...c];const u={sum:"SUM adds up all values in a range of cells. Example: =SUM(A,B)",average:"AVERAGE calculates the mean of a range of numbers. Example: =AVERAGE(A,B)",count:"COUNT counts the number of numeric values in a range. Example: =COUNT(A,B)",multiply:"MULTIPLY multiplies values from two columns. Example: =A*B",divide:"DIVIDE divides values from two columns. Example: =A/B",sumif:'SUMIF adds up values based on a condition. Example: =SUMIF(A:B, ">10")',if:'IF returns a value based on a condition. Example: =IF(A>B, "Yes", "No")',min:"MIN returns the smallest number in a range. Example: =MIN(A:B)",max:"MAX returns the largest number in a range. Example: =MAX(A:B)",concatenate:'CONCATENATE joins two or more text strings. Example: =CONCATENATE(A, " ", B)',left:"LEFT returns the leftmost characters from a text string. Example: =LEFT(A1, 5)",right:"RIGHT returns the rightmost characters from a text string. Example: =RIGHT(A1, 5)",len:"LEN returns the length of a text string. Example: =LEN(A1)",text:'TEXT formats a number as text in a specified format. Example: =TEXT(A1, "0.00")'};l.onchange=function(){o.classList.remove("smart-hidden");const e=l.value.toLowerCase();s.textContent=u[e]},r.addEventListener("click",(function(){const e=l.value.toLowerCase(),o=i.value,s=n.value;if(o&&s){let l="";switch(e){case"sum":l=`=SUM(COL(${o}),COL(${s}))`;break;case"average":l=`=AVERAGE(COL(${o}),COL(${s}))`;break;case"count":l=`=COUNT(COL(${o}),COL(${s}))`;break;case"multiply":l=`=COL(${o})*COL(${s})`;break;case"divide":l=`=COL(${o})/COL(${s})`;break;case"sumif":l=`=SUMIF(COL(${o}):COL(${s}), ">10")`;break;case"if":l=`=IF(COL(${o})>COL(${s}), "Yes", "No")`;break;case"min":l=`=MIN(COL(${o}),COL(${s}))`;break;case"max":l=`=MAX(COL(${o}),COL(${s}))`;break;case"concatenate":l=`=CONCATENATE(COL(${o}), " ", COL(${s}))`;break;case"left":l=`=LEFT(COL(${o}), COL(${s}), 5)`;break;case"right":l=`=RIGHT(COL(${o}),COL(${s}), 5)`;break;case"len":l=`=LEN(COL(${o}),COL(${s}))`;break;case"text":l=`=TEXT(COL(${o}),COL(${s}), "0.00")`}try{a._formulaParser.parse(l),t.value=l.substring(1)}catch(e){d.textContent=`Invalid Formula: ${e.message}`}}})),s.textContent=u[l.value]}updateRelation(e,t){const a=this;for(let l=0;l<a.dataSourceSettings.relations.length;){const i=a.dataSourceSettings.relations[l];if(i.id===e){t.label&&(i.label=t.label),t.label&&(i.label=t.label),t.columns&&(i.columns=t.columns),t.dataSource&&(i.dataSource=t.dataSource);for(let t=0;t<a.columns.length;t++){const l=a.columns[t];if(l.relationField&&l.relationId&&l.relationId===e){const e=a._getRelationData(l.relationId);l.editor?(l.editor.isDirty=!0,l.editor.dataSource=e):(l.templateSettings={dataFields:[l.relationField]},l.editor={template:"grid",relationId:l.relationId,relationField:l.relationField,relationCascadingFields:l.relationCascadingFields,dataSource:e,columns:a._getRelationFieldsData(l.relationId)})}}a._recycle();break}}}_dragDialog(e,t){const a=this,l=a._dialogDragDetails.dialog;if(!e||l.pinned||l.maximized)return;if(!a._dialogDragDetails.started)return;let i,n;i=e.pageX-a._dialogDragDetails.x,n=e.pageY-a._dialogDragDetails.y;const o=Math.max(a._windowParent.element.clientHeight,a._windowParent.scrollElement.scrollHeight),s=Math.max(a._windowParent.element.clientWidth,a._windowParent.scrollElement.scrollWidth);switch(t){case"horizontal":a._dialogDragDetails.windowX=Math.max(0,Math.min(a._dialogDragDetails.windowX+i,s-l.offsetWidth)),l.style.left=a._dialogDragDetails.windowX+"px";break;case"vertical":a._dialogDragDetails.windowY=Math.max(0,Math.min(a._dialogDragDetails.windowY+n,o-l.offsetHeight)),l.style.top=a._dialogDragDetails.windowY+"px";break;case"both":a._dialogDragDetails.windowX=Math.max(0,Math.min(a._dialogDragDetails.windowX+i,s-l.offsetWidth)),a._dialogDragDetails.windowY=Math.max(0,Math.min(a._dialogDragDetails.windowY+n,o-l.offsetHeight)),l.style.left=a._dialogDragDetails.windowX+"px",l.style.top=a._dialogDragDetails.windowY+"px"}a._dialogDragDetails.top=l.offsetTop,a._dialogDragDetails.left=l.offsetLeft,a._dialogDragDetails.x=Math.max(a._windowParent.offsetLeft+a._dialogDragDetails.offsetX-a._windowParent.scrollElement.scrollLeft,Math.min(a._windowParent.offsetLeft+a._windowParent.element.offsetWidth-(a._windowParent.element.offsetWidth-l.offsetLeft)+a._dialogDragDetails.offsetX,e.pageX)),a._dialogDragDetails.y=Math.max(a._windowParent.offsetTop+a._dialogDragDetails.offsetY-a._windowParent.scrollElement.scrollTop,Math.min(a._windowParent.offsetTop+a._windowParent.element.offsetHeight-(a._windowParent.element.offsetHeight-l.offsetTop)+a._dialogDragDetails.offsetY,e.pageY))}_updateDialogDragDetails(e,t,a){const l=this;if(l._windowParent={initialParent:t.parentElement,element:document.documentElement,scrollElement:document.scrollingElement},l._dialogDragDetails||(l._dialogDragDetails={}),void 0===l._dialogDragDetails.minWidth||void 0===l._dialogDragDetails.minHeight||void 0===l._dialogDragDetails.maxWidth||void 0===l._dialogDragDetails.maxHeight){const e=getComputedStyle(t);l._dialogDragDetails.minWidth=parseFloat(e.getPropertyValue("min-width"))||0,l._dialogDragDetails.minHeight=parseFloat(e.getPropertyValue("min-height"))||0,l._dialogDragDetails.maxWidth=parseFloat(e.getPropertyValue("max-width"))||0,l._dialogDragDetails.maxHeight=parseFloat(e.getPropertyValue("max-height"))||0}l._dialogDragDetails.dialog=t,l._dialogDragDetails.windowX=t.offsetLeft,l._dialogDragDetails.windowY=t.offsetTop;const i=t.getBoundingClientRect(),n=t.parentElement===document.body?document.documentElement.getBoundingClientRect():t.parentElement?t.parentElement.getBoundingClientRect():document.documentElement.getBoundingClientRect(),o=window.scrollX||window.pageXOffset,s=window.scrollY||window.pageYOffset;l._windowParent.offsetLeft=n.left+o,l._windowParent.offsetTop=n.top+s,a&&"object"==typeof a&&(l._dialogDragDetails.offsetX=a.clientX-i.left,l._dialogDragDetails.offsetY=a.clientY-i.top),t.collapsed||(l.hasAnimation&&"minimize"===e?(l._dialogDragDetails.width=l._dialogDragDetails.width?l._dialogDragDetails.width:t.offsetWidth,l._dialogDragDetails.height=l._dialogDragDetails.height?l._dialogDragDetails.height:t.offsetHeight):(l._dialogDragDetails.width=t.offsetWidth,l._dialogDragDetails.height=t.offsetHeight),(t.style.width||t.style.height)&&(l._dialogDragDetails.resized=!0)),"minimize"!==e&&e&&(l._dialogDragDetails.type=e,l._dialogDragDetails.started=!0,l._dialogDragDetails.snapWindowWidth=t.offsetWidth,l._dialogDragDetails.snapWindowHeight=t.offsetHeight,a&&"object"==typeof a?(l._dialogDragDetails.x=a.pageX,l._dialogDragDetails.y=a.pageY):(l._dialogDragDetails.x=t.offsetLeft,l._dialogDragDetails.y=t.offsetTop))}_createPopup(e){const t=this;let a=document.createElement("div");return a.setAttribute("animation","none"),a.classList.add("smart-window","smart-grid-popup"),e||(e=t.editing.dialog),a.style.width="auto"===e.width?e.width:e.width+"px",a.style.height="auto"===e.height?e.height:e.height+"px",e.width&&"string"==typeof e.width&&(a.style.width=e.width),e.height&&"string"==typeof e.height&&(a.style.height=e.height),a.style.left="",a.style.top="",a.innerHTML='<div class="smart-container">\n <div class ="smart-content-container" smart-id="container">\n <div class="smart-content"><div class="smart-content-container"></div></div>\n </div>\n </div>\n ',a.querySelector&&a.querySelector(".smart-content")&&(a.content=a.querySelector(".smart-content").firstChild),document.body.appendChild(a),a.remove=function(){},a.close=function(){a.classList.contains("open")&&(a.classList.remove("open"),delete t._resizeHandling,a.addEventListener("transitionend",a.remove),a.addEventListener("transitioncancel",a.remove),a.onClose&&a.onClose())},a.open=function(l,i){a.removeEventListener("transitionend",a.remove),a.removeEventListener("transitioncancel",a.remove),t._resizeHandling=!1,void 0===l&&(l=e.left),void 0===i&&(i=e.top),requestAnimationFrame((function(){a.classList.add("open");const e=a.querySelector('[bind="name"]');if(e){const a=e.querySelector("smart-input");a&&t.editing.enabled&&a.focus()}const n=function(e,l){let i=t.offset(t);switch((t.dropDownMode||a.dropDownMode)&&(i={left:0,top:0}),"center"===e&&"horizontal"===l&&(e="middle"),e){case"top":return i.top;case"bottom":return Math.max(i.top,i.top+t.offsetHeight-a.offsetHeight);case"center":return Math.max(i.top,i.top+t.offsetHeight/2-a.offsetHeight/2);case"left":return i.left;case"middle":return i.left+t.offsetWidth/2-a.offsetWidth/2;case"right":return i.left+t.offsetWidth-a.offsetWidth}return"horizontal"===l?parseInt(e)+i.left:"vertical"===l?parseInt(e)+i.top:"number"==typeof e?e:parseInt(e)};a.style.left=n(l,"horizontal")+"px",a.style.top=n(i,"vertical")+"px",a.setPosition=(e,t)=>{t?a.style.left=n(e,"horizontal")+"px":a.style.top=n(e,"vertical")+"px"},"center"===l&&parseInt(a.style.left)<0&&(a.style.left="5%",a.style.maxWidth="90%"),"screenMiddle"===l&&(a.style.left="calc(50% - "+a.offsetWidth/2+"px)"),"screenCenter"===i&&(a.style.top="calc(50% - "+a.offsetHeight/2+"px)")})),a.onOpen&&a.onOpen()},a}_createDialog(e){const t=this;let a=document.createElement("div");e||(e=t.editing.dialog),void 0!==e.modal&&(a.modal=e.modal),void 0!==e.screenModal&&(a.screenModal=e.screenModal),a.setAttribute("animation","none"),a.classList.add("smart-window","smart-grid-dialog"),a.style.width="auto"===e.width?e.width:e.width+"px",a.style.height="auto"===e.height?e.height:e.height+"px",e.width&&"string"==typeof e.width&&(a.style.width=e.width),e.height&&"string"==typeof e.height&&(a.style.height=e.height),a.style.left="",a.style.top="",a.innerHTML=`<div class="smart-container">\n <div class ="smart-content-container" smart-id="container">\n <div id="headerSection" class="smart-header-section">\n <div class="smart-header">\n </div>\n <div class="smart-buttons-container">\n <button title="${t.localize("contextMenuItemDelete")}" tabindex=-1 class="smart-visibility-hidden smart-hidden smart-delete-button smart-grid-icon smart-icon-delete show smart-button smart-element" aria-label="Delete Row" smart-id="deleteButton"></button>\n <button title="${t.localize("copyURL")}" tabindex=-1 class="smart-visibility-hidden smart-hidden smart-copy-row-button smart-grid-icon smart-icon-link show smart-button smart-element" aria-label="Copy URL" smart-id="urlButton"></button>\n <button title="${t.localize("AI")}" tabindex=-1 class="smart-visibility-hidden smart-hidden smart-ai-button smart-grid-icon smart-icon-ai smart-button smart-element" aria-label="AI" smart-id="aiButton"></button>\n <button title="${t.localize("dialogEditHeaderMenu")}" tabindex=-1 class ="smart-visibility-hidden smart-hidden checked smart-comments-button smart-grid-icon smart-icon-menu show smart-button smart-element" aria-label="Comments" smart-id="commentsButton"></button>\n <button title="${t.localize("download")}" tabindex=-1 class ="smart-visibility-hidden smart-hidden smart-download-button smart-grid-icon smart-icon-download smart-button smart-element" aria-label="Download" smart-id="downloadButton"></button>\n <button title="${t.localize("close")}" class ="smart-button smart-element smart-close-button" aria-label="Close" smart-id="closeButton"></button>\n </div>\n </div>\n <div class="smart-content"><div class="smart-content-container"></div></div>\n <div class ="smart-footer">\n \n <div class ="smart-stack-layout right spacing">\n <smart-button class ="smart-confirm-button item primary">Ok</smart-button>\n <smart-button class ="smart-cancel-button item">Cancel</smart-button>\n </div>\n </div>\n </div>\n </div>\n `,a.querySelector&&a.querySelector(".smart-content")&&(a.content=a.querySelector(".smart-content").firstChild),a.footer=a.querySelector(".smart-footer"),a.header=a.querySelector(".smart-header"),a.btnConfirm=a.querySelector(".smart-confirm-button"),a.btnCancel=a.querySelector(".smart-cancel-button"),a.btnDelete=a.querySelector(".smart-delete-button"),a.btnClose=a.querySelector(".smart-close-button"),a.btnComments=a.querySelector(".smart-comments-button"),a.btnLink=a.querySelector(".smart-copy-row-button"),a.btnAI=a.querySelector(".smart-ai-button"),a.btnDownload=a.querySelector(".smart-download-button"),a.headerSection=a.querySelector(".smart-header-section"),a.btnLink.onclick=()=>{let e=document.createElement("input"),t=window.location.href+"#activeRows="+a.row.id;navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(t).then((()=>{})):(document.body.appendChild(e),e.value=t,e.select(),document.execCommand("copy"),document.body.removeChild(e))},a.btnDelete.onclick=()=>{const e=a.row.id,l=t.editing.deleteDialog.enabled;t.editing.deleteDialog.enabled=!0,t.cancelEdit(),a.close(),t._openDeleteRowDialog(e,(function(e){t._endToolbarEdit&&t._endToolbarEdit(),t.deleteRow(e)})),t.editing.deleteDialog.enabled=l,a.close()},a.btnComments.onclick=()=>{const e=a.querySelector(".smart-grid-edit-dialog-layout");e&&e.classList.toggle("hide-activity"),a.btnComments.classList.toggle("checked")},!1!==a.allowDrag&&(a.headerSection.onpointerdown=e=>{t._updateDialogDragDetails("drag",a,e)},a.headerSection.onpointerup=()=>{t._dialogDragDetails&&(t._dialogDragDetails.started=!1)});const l=document.createElement("div");return l.classList.add("smart-grid-dialog-overlay"),l.onclick=function(){a.overlayClick&&a.overlayClick()},a.overlay=l,a.remove=function(){a.parentNode&&a.parentNode.removeChild(a)},a.close=function(){a.classList.contains("open")&&(a.classList.remove("open"),delete t._resizeHandling,a.addEventListener("transitionend",a.remove),a.addEventListener("transitioncancel",a.remove),a.modal&&a.overlay.parentNode&&a.overlay.parentNode.removeChild(a.overlay),t.layout.isDirty&&"grid"===t.view&&(t._resetCachedLayout(),t._refreshLayout(),t.refresh()),a.onClose&&a.onClose())},a.open=function(l,i){a.removeEventListener("transitionend",a.remove),a.removeEventListener("transitioncancel",a.remove),t.isInShadowDOM?t.getRootNode().appendChild(a):document.body.appendChild(a),t._resizeHandling=!1,void 0===l&&(l=e.left),void 0===i&&(i=e.top),requestAnimationFrame((function(){a.classList.add("open");const e=a.querySelector('[bind="name"]');if(e){const a=e.querySelector("smart-input");a&&t.editing.enabled&&a.focus()}const n=function(e,l){const i=t.offset(t);switch("center"===e&&"horizontal"===l&&(e="middle"),e){case"top":return i.top;case"bottom":return Math.max(i.top,i.top+t.offsetHeight-a.offsetHeight);case"center":return Math.max(i.top,i.top+t.offsetHeight/2-a.offsetHeight/2);case"left":return i.left;case"middle":return i.left+t.offsetWidth/2-a.offsetWidth/2;case"right":return i.left+t.offsetWidth-a.offsetWidth}return"horizontal"===l?parseInt(e)+i.left:"vertical"===l?parseInt(e)+i.top:"number"==typeof e?e:parseInt(e)};a.style.left=n(l,"horizontal")+"px",a.style.top=n(i,"vertical")+"px",a.setPosition=(e,t)=>{t?a.style.left=n(e,"horizontal")+"px":a.style.top=n(e,"vertical")+"px"},"center"===l&&parseInt(a.style.left)<0&&(a.style.left="5%",a.style.maxWidth="90%"),"screenMiddle"===l&&(a.style.left="calc(50% - "+a.offsetWidth/2+"px)"),"screenCenter"===i&&(a.style.top="calc(50% - "+a.offsetHeight/2+"px)")})),a.modal&&(a.screenModal?t.isInShadowDOM?t.getRootNode().appendChild(a.overlay):document.body.appendChild(a.overlay):t.appendChild(a.overlay)),a.onOpen&&a.onOpen()},a}_resizable(e,t,a,l,i){const n=e;let o,s,r,d,c,u,m=!1,p="";function g(t){const{clientX:l,clientY:i}=t,o=n.getBoundingClientRect();let s="";return e.resizeMode&&(a=e.resizeMode),a.indexOf("bottom")>=0&&o.bottom-i<=10&&o.bottom-i>=0&&(s+="bottom"),a.indexOf("right")>=0&&o.right-l<=10&&o.right-l>=0&&(s+="right"),a.indexOf("left")>=0&&l-o.left<=10&&l-o.left>=0&&(s+="left"),a.indexOf("top")>=0&&i-o.top<=10&&i-o.top>=0&&(s+="top"),s}function b(e){return e.includes("top")&&e.includes("left")?"nwse-resize":e.includes("top")&&e.includes("right")||e.includes("bottom")&&e.includes("left")?"nesw-resize":e.includes("bottom")&&e.includes("right")?"nwse-resize":e.includes("left")||e.includes("right")?"ew-resize":e.includes("top")||e.includes("bottom")?"ns-resize":"default"}n.addEventListener("mousedown",(e=>{p=g(e),p&&(m=!0,o=e.pageX,s=e.pageY,r=n.offsetWidth,d=n.offsetHeight,c=n.offsetLeft,u=n.offsetTop,e.preventDefault())})),window.addEventListener("mousemove",(e=>{const a=g(e);if(m){const a=e.pageX-o,m=e.pageY-s;let g=r,f=d,h=c,y=u;p.includes("right")&&(g=r+a),p.includes("left")&&(g=r-a,h=c+a),p.includes("bottom")&&(f=d+m),p.includes("top")&&(f=d-m,y=u+m),l||(l=50),i||(i=50),g>l&&(n.style.width=g+"px",n.style.left=h+"px",t&&(t.style.width=g+"px")),f>i&&(n.style.height=f+"px",n.style.top=y+"px",t&&(t.style.height=f+"px")),document.body.style.cursor=b(p)}else document.body.style.cursor=b(a)})),window.addEventListener("mouseup",(()=>{m=!1,p="",document.body.style.cursor=""}))}_openAddRowDialog(e,t){const a=this;if(!a.editing.addDialog.enabled)return!1;const l=a._dialogAddRow||a._createDialog(),i="{{message}}"===a.editing.dialog.header?a.localize("dialogAddHeader"):a.editing.dialog.header,n=l.content;l.header.innerHTML=i,e.grid=a,void 0===e.index&&(e.index=a.rows.length,a._rowsAdded&&(e.index+=a._rowsAdded.length));const o=e.cells;let s=null,r=0;if(a._cellEditors||(a._cellEditors=[]),!a._dialogAddRow){l.modal=!0,l.btnConfirm.innerHTML=a.localize("dialogAddButtonConfirm"),l.btnCancel.innerHTML=a.localize("dialogAddButtonCancel"),l.onOpen=function(){a.editing.dialog.visible=!0},l.onClose=function(){a.editing.dialog.visible=!1},l.btnCancel.onclick=function(){l.close()},l.btnClose.onclick=function(){l.close()},l.btnConfirm.onclick=function(){const e={};for(let t=0;t<o.length;t++){const l=o[t],i=a._getEditorValue(l),n=a._getEditorId(l),s=a._cellEditors[n];s&&(i&&i.error?(e[l.column.dataField]=i.value,s.detach()):(e[l.column.dataField]=i,s.detach()))}const i=a._rowsAdded?a._rowsAdded.length:0,n=new Smart.Grid.Row({index:a.rows.length+i,id:Smart.Utilities.Core.createGUID(),grid:a,data:e});l.close(),t(n,0===l.index)},l.onkeydown=function(e){const t=e.key;"Enter"===t?l.btnConfirm.onclick():"Escape"===t&&l.close()},n.classList.add("smart-grid-layout");for(let e=0;e<a.columns.length;e++){const t=a.columns[e];if(!t.allowEdit)continue;r%2==0&&(s=document.createElement("div"),s.classList.add("smart-grid-edit-dialog-row"),n.appendChild(s));const l=document.createElement("div");l.classList.add("col-sm-6");const i=document.createElement("div");i.classList.add("column");const o=document.createElement("label");o.innerHTML=a.columns[e].label;const d=document.createElement("div");d.classList.add("smart-grid-dialog-editor"),d.setAttribute("editor",t.dataField),d.setAttribute("template",t.editor.template),l.appendChild(i),s.appendChild(l),i.appendChild(o),i.appendChild(d),r++}}l.open(),l.index=e.index;let d=0;for(let e=0;e<o.length;e++){const t=o[e],i=t.column,n=i.dataField,s=l.querySelector("[editor="+n+"]");if(!s)continue;s.innerHTML="";let r="";void 0!==t.value&&(r=t.value),"int64"!==i.dataType&&"number"!==i.dataType&&"int"!==i.dataType&&"float"!==i.dataType||(r=0),"date"===i.dataType&&(r=new Date),"bool"!==i.dataType&&"boolean"!==i.dataType||(r=!1);let c=null;switch(t.editor.template){default:case"custom":c=a._getCustomCellEditor(t);break;case"image":c=a._getImageCellEditor(t);break;case"checkBox":c=a._getCheckBoxCellEditor(t);break;case"autoComplete":c=a._getAutoCompleteCellEditor(t);break;case"dropDownList":c=a._getAutoCompleteCellEditor(t),c.readonly=!0,c.dropDownButtonPosition="right";break;case"comboBox":c=a._getAutoCompleteCellEditor(t),c.readonly=!1,c.dropDownButtonPosition="right";break;case"maskedTextBox":c=a._getMaskCellEditor(t);break;case"checkInput":c=a._getCheckInputCellEditor(t),c.readonly=!0,c.dropDownButtonPosition="right";break;case"multiInput":c=a._getMultiInputCellEditor(t),c.readonly=!0,c.dropDownButtonPosition="right";break;case"multiComboInput":c=a._getMultiComboInputCellEditor(t),c.readonly=!0,c.dropDownButtonPosition="right";break;case"time":case"timeInput":c=a._getTimeInputCellEditor(t);break;case"date":case"dateInput":c=a._getDateInputCellEditor(t);break;case"dateRangeInput":c=a._getDateRangeInputCellEditor(t);break;case"dateTimePicker":c=a._getDateTimePickerCellEditor(t);break;case"textArea":case"textarea":c=a._getTextAreaCellEditor(t);break;case"numberInput":case"text":case"input":c="numberInput"===t.editor.template?a._getNumberInputCellEditor(t):a._getInputCellEditor(t)}if(c.attach(),t.editor.instance=c,c.setValue(r),0===d&&setTimeout((()=>{a.editing.enabled&&c.focus()}),100),!t.editor.isInitialized&&(t.editor.isInitialized=!0,t.editor.onInit)){const e=t.editor.onInit(t.row.index,t.column.dataField,t.editor.instance.element,t.row.data);if(e&&e instanceof Promise)e.then((e=>{const a="custom"===t.editor.template?t.editor.instance.element.firstElementChild:t.editor.instance.element;for(let t in e)a[t]=e[t]}));else if(e){const a=e,l="custom"===t.editor.template?t.editor.instance.element.firstElementChild:t.editor.instance.element;for(let e in a)l[e]=a[e]}}if(t.editor.onRender){const e=t.editor.onRender(t.row.index,t.column.dataField,t.editor.instance.element,t.row.data);if(e&&e instanceof Promise)e.then((e=>{const a="custom"===t.editor.template?t.editor.instance.element.firstElementChild:t.editor.instance.element;for(let t in e)a[t]=e[t]}));else if(e){const a=e,l="custom"===t.editor.template?t.editor.instance.element.firstElementChild:t.editor.instance.element;for(let e in a)l[e]=a[e]}}s.appendChild(c.element),c.element.onfocus=()=>{s.setAttribute("focus","")},c.element.onblur=()=>{s.removeAttribute("focus")},d++}a._dialogAddRow=l}_createAiPromptDropdown(e){const t=this;if(document.querySelector(".smart-grid-edit-dialog-ai-prompt-dropdown"))return void(e.onclick=a=>{const l=document.querySelector(".smart-grid-edit-dialog-ai-prompt-dropdown");document.querySelector(".smart-grid-edit-dialog-ai-prompt-dropdown-content").classList.toggle("show");const i=t.offset(e);l.style.top=i.top+e.offsetHeight+"px",l.style.left=i.left+"px",l.querySelector("textarea").focus(),a.stopPropagation()});const a=document.createElement("style");a.innerHTML="\n .smart-grid-edit-dialog-ai-prompt-dropdown-content {\n position: absolute;\n background-color: var(--smart-surface);\n min-width: 300px;\n box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);\n padding: 12px 16px;\n z-index: 1;\n border-radius: 5px;\n margin-top: 10px;\n opacity: 0;\n transform: scaleY(0);\n transform-origin: top;\n transition: opacity 0.3s ease, transform 0.3s ease;\n }\n\n textarea {\n min-width: 300px;\n border: 1px solid var(--smart-border);\n }\n textarea:focus {\n border: 1px solid var(--smart-primary);\n }\n\n .smart-grid-edit-dialog-ai-prompt-dropdown-content.show {\n opacity: 1;\n transform: scaleY(1);\n }\n\n .smart-grid-edit-dialog-ai-prompt-result {\n margin-top: 10px;\n padding: 10px;\n background-color: var(--smart-surface);\n border-radius: 5px;\n display: none;\n overflow: auto;\n max-height: 400px;\n }\n\n .smart-grid-edit-dialog-ai-prompt-result.show {\n display: block;\n }\n\n .smart-grid-edit-dialog-ai-prompt-dropdown {\n z-index: 99999;\n position: absolute;\n }\n\n .smart-grid-edit-dialog-ai-prompt-input {\n width: 100%;\n height: 80px;\n }\n ",document.head.appendChild(a);const l=document.createElement("div");l.classList.add("smart-grid-edit-dialog-ai-prompt-dropdown"),l.innerHTML=`\n <div class="smart-grid-edit-dialog-ai-prompt-dropdown-content">\n <p>${t.localize("aiPrompt")}</p>\n <textarea resize="both" placeholder="${t.localize("minPromptChars")}" class="smart-input smart-text-area smart-element smart-grid-edit-dialog-ai-prompt-input" id="aiPromptInput" rows="4" cols="50"></textarea>\n <smart-button><span style="padding-left: 16px; padding-right: 16px;">${t.localize("generate")}</span></smart-button>\n <div class="smart-grid-edit-dialog-ai-prompt-result"></div><smart-button style="margin-top:10px;" class="smart-copy-button smart-hidden" title="${t.localize("copy")}"><div class="smart-flex"><span class="show smart-grid-icon smart-icon-copy-record"></span>${t.localize("copy")}</div></smart-button>\n </div>\n `,document.body.appendChild(l);const i=l.querySelector(".smart-grid-edit-dialog-ai-prompt-dropdown-content"),n=l.querySelector("smart-button"),o=l.querySelector(".smart-grid-edit-dialog-ai-prompt-input"),s=l.querySelector(".smart-grid-edit-dialog-ai-prompt-result"),r=l.querySelector(".smart-copy-button");e.onclick=a=>{i.classList.toggle("show");const n=t.offset(e);l.style.top=n.top+e.offsetHeight+"px",l.style.left=n.left+"px",a.stopPropagation()},document.addEventListener("click",(t=>{i.contains(t.target)||t.target===e||i.classList.remove("show")})),n.disabled=!0,o.oninput=()=>{n.disabled=!0,o.value.length>=20&&o.value.indexOf(" ")>=0&&(n.disabled=!1)},r.onclick=()=>{((e,t)=>{if(!(e&&e instanceof HTMLElement))return;const a=e.textContent;function l(e,t){const a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.select();try{document.execCommand("copy"),i(t,"Copied!")}catch(e){}document.body.removeChild(a)}function i(e,t){e.setAttribute("title",t),setTimeout((()=>{e.removeAttribute("title")}),1e3),setTimeout((()=>{e.disabled=!1}),1e3)}t.disabled=!0,navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(a).then((()=>{i(t,"Copied!")})).catch((e=>{l(a,t)})):l(a,t)})(s,r)},n.addEventListener("click",(e=>{(e=>{const a=t.ai.url,l=t.ai.key;e.stopPropagation(),e.preventDefault(),e.target.classList.add("smart-grid-loading");let i=""+o.value;i?async function(e){const i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`},body:JSON.stringify({model:t.ai.model,messages:[{role:"user",content:e}],max_tokens:t.ai.maxTokens,temperature:t.ai.temperature})});if(!i.ok)throw new Error(`Error: ${i.statusText}`);return(await i.json()).choices[0].message.content.trim()}(i).then((t=>{s.textContent=t,s.classList.add("show"),r.classList.remove("smart-hidden"),e.target.classList.remove("smart-grid-loading")})).catch((t=>{console.error("Error:",t),e.target.classList.remove("smart-grid-loading")})):(s.textContent="",s.classList.add("show"),r.classList.remove("smart-hidden"),e.target.classList.remove("smart-grid-loading"))})(e)})),setTimeout((()=>{o.focus()}),100)}_openRowSettingsDialog(e){let t=this;t.getSelectedRows||(t=t.grid);const a=t.editing.dialog.enabled,l=t.editing.mode,i=t.context;t.context=t,t.editing.dialog.enabled=!0,t.editing.mode="row",t._settingsDialogRowId=e;let n=t._isUpdating;"grid"!==t.view&&"card"!==t.view&&(t._isUpdating=0),t.beginEdit(e),t._isUpdating=n,t._endToolbarEdit?(t.removeEventListener("endEdit",t._endToolbarEdit,null),t.removeEventListener("cancelEdit",t._endToolbarEdit,null)):t._endToolbarEdit=()=>{t.context=t,t.editing.dialog.enabled=a,t.editing.mode=l,t.editing.isEditing=!1,t.context=i,delete t._settingsDialogRowId,delete t._dialogEdit},t.addEventListener("endEdit",t._endToolbarEdit),t.addEventListener("cancelEdit",t._endToolbarEdit)}_openEditDialog(e,t){const a=this;if(!a.editing.dialog.enabled)return!1;const l=a._dialogEdit||a._createDialog();let i="{{message}}"===a.editing.dialog.header?a.localize("dialogEditHeader",{value:a.editing.editRow?e.row.visibleIndex+1:e.column.label}):a.editing.dialog.header;const n=l.content;!1===a.editing.enabled?(l.classList.add("disable-edit"),i="{{message}}"===a.editing.dialog.header?a.localize("dialogEditHeaderDisabled",{value:a.editing.editRow?e.row.visibleIndex+1:e.column.label}):a.editing.dialog.header):l.classList.remove("disable-edit"),l.header.innerHTML=i,l.footer.classList.add("smart-hidden"),l.row=a.editing.editRow;const o=l.row.canNotify;l.row.canNotify=!1,l.row.showDetail=!1,l.row.canNotify=o,l.overlayClick=()=>{l.btnConfirm.click()};let s,r,d=null,c=0;if(void 0!==a._settingsDialogRowId){const e=`<div class="smart-buttons-container">\n <button title="${a.localize("pagerPreviousButton")}" tabindex=-1 class =" smart-button smart-element smart-prev-button" aria-label="Previous Record" smart-id="prevButton"></button>\n <button title="${a.localize("pagerNextButton")}" tabindex=-1 class =" smart-button smart-element smart-next-button" aria-label="Next Record" smart-id="nextButton"></button>\n </div>`;l.header.innerHTML=e+"<span>"+i+"</span>",l.btnPrev=l.querySelector(".smart-prev-button"),l.btnNext=l.querySelector(".smart-next-button"),l.header.style.display="flex",l.header.style.alignItems="center",a.editing.enabled?(l.btnDelete.classList.remove("smart-hidden"),l.btnComments.classList.remove("smart-hidden"),l.btnLink.classList.remove("smart-hidden"),l.btnDelete.classList.remove("smart-visibility-hidden"),l.btnComments.classList.remove("smart-visibility-hidden"),l.btnLink.classList.remove("smart-visibility-hidden"),a.ai.key&&(l.btnAI.classList.remove("smart-visibility-hidden"),l.btnAI.classList.add("show"),this._createAiPromptDropdown(l.btnAI)),0===a.users.length||a.users.length&&"guest"===a._currentUser.info?(l.btnLink.classList.add("smart-visibility-hidden"),l.btnDelete.classList.add("smart-visibility-hidden"),l.btnComments.classList.add("smart-visibility-hidden")):(l.btnLink.classList.remove("smart-visibility-hidden"),l.btnDelete.classList.remove("smart-visibility-hidden"),l.btnComments.classList.remove("smart-visibility-hidden"))):l.btnLink.style.width=l.btnDelete.style.width=l.btnComments.style.width="0px";const t=e=>{const t=a.editing.editRow,i=a._recyclingRows.indexOf(t);let o=e?a._recyclingRows[i+1]:a._recyclingRows[i-1];if(a.grouping.enabled&&a.dataSource.groupBy&&a.dataSource.groupBy.length>0){let t=1;for(;o&&!o.leaf;)o=e?a._recyclingRows[i+t]:a._recyclingRows[i-t],t++}const s=t;if(void 0!==a._settingsDialogRowId&&a.editing.dialog.autoSave){const e=a.rowById[a._settingsDialogRowId];e&&(l.saveRowData(e,!1),a._disableEndEdit=!0,a._recycle(!1,!0),a._disableEndEdit=!1)}if(o){if(a.editing.recordNavigation=!0,a.editing.editRow=o,a._settingsDialogRowId=o.id,s.isEditing=!1,s.element.removeAttribute("edit"),"gallery"===a.view){const e=a.querySelector('.smart-card[row-id="'+l.row.id+'"]');e&&e.removeAttribute("edit");const t=a.querySelector('.smart-card[row-id="'+o.id+'"]');t&&t.setAttribute("edit","")}const e=o,t=s.cells,i=e.cells;"kanban"===a.view&&a._kanban&&a._kanban.selectTask(e.id),l.row=o,l.header.querySelector("span").innerHTML=a.localize("dialogEditHeader",{value:a.editing.editRow.visibleIndex+1}),"gallery"!==a.view&&e.element.row.data.$.id===e.data.$.id&&e.element.setAttribute("edit","");for(let a=0;a<i.length;a++){const l=i[a],n=l.column;if(!n.allowEdit||!1===n._visible)continue;l.isEditing=!0,t[a].isEditing=!1;const o=e.data[n.dataField];l.editor&&l.editor.instance&&l.editor.instance.setValue(o)}a._applySettingsDialogLayout(l,n,a.editing.editRow,!0),a.editing.enabled&&setTimeout((()=>{const e=l.querySelector(".smart-grid-dialog-editor input");e&&e.focus()}),100)}};l.btnNext.onmousedown=e=>{t(!0),e.preventDefault(),e.stopPropagation()},l.btnPrev.onmousedown=e=>{t(!1),e.preventDefault(),e.stopPropagation()}}if(!a._dialogEdit){l.modal=!0,l.btnConfirm.innerHTML=a.localize("dialogEditButtonConfirm"),l.btnCancel.innerHTML=a.localize("dialogEditButtonCancel"),a.editing.dialog.sidePanel&&l.classList.add("smart-grid-side-panel"),l.onOpen=function(){if(!a.editing.dialog.visible&&(a.editing.dialog.visible=!0,void 0!==a._settingsDialogRowId&&l.editorsContent&&l.editorsContent.offsetHeight)){if(l.editorsContent.style.maxHeight=l.editorsContent.offsetHeight+40+"px",l.editorsContent.style.alignContent="start",l.editorsContent.offsetWidth>a.offsetWidth||l.editorsContent.offsetHeight>window.innerHeight||l.editorsContent.offsetWidth>window.innerWidth){if(Smart.Utilities.Core.isMobile)return;setTimeout((()=>{const e=a.offset(a);l.style.left=e.left+"px",l.style.top=e.top+"px",l.style.width=l.style.minWidth=l.style.maxWidth=a.offsetWidth+"px",l.style.height=l.style.minHeight=l.style.maxHeight=a.offsetHeight+"px",l.editorsContent.style.maxHeight=""}))}else l.style.width=l.style.minWidth="",l.style.height=l.style.minHeight="",400!==a.editing.dialog.height&&(l.style.height=l.style.minHeight=a.editing.dialog.height+"px",l.editorsContent.style.maxHeight=l.editorsContent.offsetHeight+40+"px"),400!==a.editing.dialog.width&&(l.style.width=l.style.minWidth=a.editing.dialog.width+"px"),requestAnimationFrame((()=>{if(a.editing.dialog.sidePanel&&!Smart.Utilities.Core.isMobile){const e=a.offset(a);l.style.left=e.left+a.offsetWidth-l.offsetWidth+"px",l.style.top=e.top+"px",l.style.height=l.style.maxHeight=a.offsetHeight+"px"}const e=a.offset(l);if(e.left+l.offsetWidth>window.innerWidth||e.top+l.offsetHeight>window.innerHeight){const e=a.offset(a);l.style.left=e.left+"px",l.style.top=e.top+"px",l.style.width=l.style.minWidth=l.style.maxWidth=a.offsetWidth+"px",l.style.height=l.style.minHeight=l.style.maxHeight=a.offsetHeight+"px",l.editorsContent.style.maxHeight=""}})),"gallery"===a.view&&setTimeout((()=>{a.querySelector('.smart-card[row-id="'+l.row.id+'"]')}));a.editing.enabled&&setTimeout((()=>{const e=l.querySelector(".smart-grid-dialog-editor input");e&&e.focus(),a._focusCommentInput&&l.querySelector(".comments-layout smart-text-area").focus()}),100)}},l.onClose=function(){a.editing.dialog.visible=!1,l.row&&(l.row.showDetail=!1)},l.btnCancel.onclick=function(){a.editing.isEditing=!0,a.cancelEdit()},l.btnClose.onclick=function(){a.editing.isEditing=!0,a.cancelEdit()};const t=(e,t=!0)=>{if(!e)return!1;const i=e.cells;let n={};e.element.removeAttribute("error");for(let e=0;e<i.length;e++){const t=i[e],l=a._getEditorValue(t);n[t.column.dataField]=l}const o=a.validateRow(e.id,n);if(Object.keys(o).length>0){let e=!0;for(let t=0;t<i.length;t++){const n=i[t],s=o[n.column.dataField],r=l.querySelector(`[label-for="${n.column.dataField}"]`);if(r&&(r.innerHTML=""),s)for(let t in s){const l=s[t];let i="";if(!l)continue;let o=l[t];"minLength"!==t&&"maxLength"!==t||(o=l[t.toLowerCase()]),i=l.message?l.message:"required"===t||"valueMissing"===t?a.localize("requiredValue",{value:n.column.label}):"min"===t?a.localize("invalidMinValue",{value:n.column.label,min:o.min}):"max"===t?a.localize("invalidMaxValue",{value:n.column.label,max:o.max}):"minLength"===t?a.localize("invalidMinLengthValue",{value:n.column.label,min:o.requiredLength}):"maxLength"===t?a.localize("invalidMaxLengthValue",{value:n.column.label,max:o.requiredLength}):a.localize("invalidValue"),e=!1,r&&(r.innerHTML=i)}}if(!e)return!1}const s=e.style;e.updatedDate=new Date,e.updatedBy=a.currentUser,e.style=l._rowStyle,e.comments=l._rowComments;const r=a.dataSource.dataItemById[e.id];if(r){const t=r.$.index;a.dataSource&&e.comments!==a.dataSource.boundSource[t].comments&&(a._sortedColumns&&a._sortedColumns.length>0?r.comments=e.comments:a.dataSource.boundSource[t].comments=e.comments)}if(e.style=l._rowStyle,a.onRowStyle&&s!==e.style&&(null===s?a.onRowStyle(e.index,e,e.style):s.background===e.style.background&&s.color===e.style.color&&s.fontSize===e.style.fontSize&&s.fontStyle===e.style.fontStyle&&s.fontFamily===e.style.fontFamily&&s.fontWeight===e.style.fontWeight&&s.status===e.style.status&&s.textDecoration===e.style.textDecoration||a.onRowStyle(e.index,e,e.style)),!t){for(let t=0;t<i.length;t++){const l=i[t],n=a._getEditorValue(l),o=l.column.dataField;if(e.canNotify=!1,e.data.canNotify=!1,e.data[o]=n,r){const e=r.$.index;a.dataSource&&(a._sortedColumns&&a._sortedColumns.length>0?r[o]=n:a.dataSource.boundSource[e][o]=n)}e.canNotify=!0,e.data.canNotify=!0}a._onSaveRowData&&a._onSaveRowData(e)}return!0};if(l.saveRowData=t,l.btnConfirm.onclick=function(){if(void 0!==a._settingsDialogRowId){const e=a.rowById[a._settingsDialogRowId];let i=!0;if(e&&(i=t(e)),!i)return;if(l.columnVisibility){let e=!1;const t=a.columns.canNotify;a.columns.canNotify=!1;for(let t in l.columnVisibility){const i=a.columnByDataField[t];i.visible!==l.columnVisibility[t]&&(i.visible=l.columnVisibility[t],e=!0)}if(a.columns.canNotify=t,e)return a.endEdit(),a.refresh(!1),void(a.dataSource&&a.dataSource.boundHierarchy&&(a.dataSource.refreshHierarchy(),a._refreshRowHierarchy(),a.refresh()))}}a.endEdit(),a.dataSource&&a.dataSource.boundHierarchy&&(a.dataSource.refreshHierarchy(),a._refreshRowHierarchy(),a.refresh())},l.onkeydown=function(e){const t=e.key,l=a.editing.commandKeys;for(let e in l){const i=l[e];if(t===i.key){a._applyCommand(i.command);break}}},a.editing.editRow)if(void 0!==a._settingsDialogRowId)a._applySettingsDialogLayout(l,n,a.editing.editRow);else{n.classList.add("smart-grid-layout");for(let e=0;e<a.columns.length;e++){const t=a.columns[e];if(!t.allowEdit)continue;c%2==0&&(d=document.createElement("div"),d.classList.add("smart-grid-edit-dialog-row"),n.appendChild(d));const l=document.createElement("div");l.classList.add("col-sm-6");const i=document.createElement("div");i.classList.add("column");const o=a._settingsDialogRowId?document.createElement("div"):document.createElement("label");o.innerHTML=a.columns[e].label;const s=document.createElement("div");s.classList.add("smart-grid-dialog-editor"),s.setAttribute("editor",t.dataField),s.setAttribute("template",t.editor.template),l.appendChild(i),d.appendChild(l),i.appendChild(o),i.appendChild(s),c++}}else{const t=e.column,a=document.createElement("div");a.classList.add("smart-grid-dialog-editor"),a.setAttribute("editor",""),a.setAttribute("template",t.editor.template),n.appendChild(a)}}if(a._dialogEditPosition){const e=a.offset(a);s=parseInt(a._dialogEditPosition.left)-e.left,r=parseInt(a._dialogEditPosition.top)-e.top}if(a.editing.dialog.visible||l.open(s,r),a.editing.editRow){const a=l.querySelector("[editor="+e.column.dataField+"]");a&&(a.innerHTML="",a.appendChild(t.element),a.editor=t,a.editorValue=t.getValue(),t.element.onfocus=()=>{a.setAttribute("focus",""),a.setAttribute("touched",""),a.editorValue=t.getValue()},t.element.onblur=()=>{a.removeAttribute("focus"),a.editorValue!==t.getValue()&&a.setAttribute("pending","")})}else{const a=e.column,i=l.querySelector("[editor]");i.innerHTML="",i.setAttribute("template",a.editor.template),i.appendChild(t.element),i.editor=t,i.editorValue=t.getValue(),t.element.onfocus=()=>{i.setAttribute("focus",""),i.setAttribute("touched",""),i.editorValue=t.getValue()},t.element.onblur=()=>{i.removeAttribute("focus"),i.editorValue!==t.getValue()&&i.setAttribute("pending","")}}a._dialogEdit=l}_refreshCurrentUser(){const e=this,t=e.users;let a=e.currentUser,l=!0,i=!0,n=e.editing.enabled,o=!0;t&&null!==a&&(a=t.find((e=>e.id===a)),a&&(l=!1!==a.allowAdd,i=!1!==a.allowComment,n=n&&!1!==a.allowEdit,o=!1!==a.allowRemove)),t&&t.length&&(null!==e.currentUser&&!1!==e.currentUser||(l=!1,i=!1,n=!1,o=!1,a="guest")),e._currentUser={allowAdd:l,allowComment:i,allowEdit:n,allowRemove:o,info:a}}_getColorInput(){const e=document.createElement("smart-color-input");return e.dataSource=["#D50000","#E67C73","#F4511E","#F6BF26","#0B8043","#33B679","#3F51B5","#039BE5","#7986CB","#8C47FF","#8E24AA","#FF36C2","#616161","#454545","#949494","#000000"],e.additionalColors=["#FF9EB7","#FFCFC9","#FFD66D","#FFEBB6","#93DF89","#D1F7C4","#9DC7FF","#D0F0FD","#CDAFFF","#ECE1FD","#FA9DE2","#FFDAF6","#CBCBCB","#EDEDED","#FFFFFF",""],e.valueDisplayMode="colorBox",e.classList.add("underlined","smart-grid-color-input"),e.style.width="auto",e.readonly=!0,e.onRender=()=>{const t=e.$.scrollView;t&&t.classList.add("smart-grid-color-input")},e}_applySettingsDialogLayout(e,t,a,l){const i=this;e.classList.add("smart-grid-dialog-expand-row");const n=e._rowStyle=JSON.parse(JSON.stringify(a._style)),o=e._rowComments=JSON.parse(JSON.stringify(a.comments));l&&e.activityContent.remove();const s=[];e.columnVisibility=s;let r=document.createElement("div"),d=document.createElement("div"),c=document.createElement("div"),u=document.createElement("div");l?(r=e.editorsContent,c=e.layoutContent,c.appendChild(d)):(c.appendChild(r),c.appendChild(u),c.appendChild(d),t.appendChild(c)),c.classList.add("smart-grid-edit-dialog-layout"),r.classList.add("smart-grid-edit-dialog-editors-container"),d.classList.add("smart-grid-edit-dialog-activity-container"),u.classList.add("smart-footer"),!Smart.Utilities.Core.isMobile&&i.appearance.showRowEditDialogDetails||(c.classList.add("hide-activity"),e.btnComments.classList.remove("checked")),!1===i.editing.enabled&&d.classList.add("smart-hidden"),(0===i.users.length||i.users.length&&i._currentUser&&i._currentUser.info&&"guest"===i._currentUser.info)&&(d.classList.add("smart-hidden"),e.btnComments.classList.add("smart-hidden"),c.classList.add("hide-activity"),e.btnComments.classList.remove("checked"),e.btnComments.classList.add("smart-hidden"),e.btnLink.classList.add("smart-hidden")),i.appearance.showRowEditDialogDetails||(e.btnComments.classList.remove("show"),e.btnLink.classList.remove("show"),e.classList.add("collapsed"));const m=document.createElement("smart-button");m.innerHTML=`<span>${i.localize("dialogEditButtonSave")}</span>`,m.classList.add("primary");const p=document.createElement("smart-button");p.innerHTML=`<span>${i.localize("dialogEditButtonCancel")}</span>`;const g=document.createElement("div");g.classList.add("smart-flex"),g.style.flexDirection="row-reverse",g.appendChild(m),g.appendChild(p),p.style.marginRight="10px",u.appendChild(g);const b=document.createElement("div");b.classList.add("smart-flex"),b.style.alignItems="center",b.innerHTML=`<label style="margin-right: 5px;">${i.localize("dialogEditButtonAutoSave")}</label>\n <label title="${i.localize("dialogEditButtonAutoSave")}" class="smart-switch">\n <input type="checkbox">\n <span class="slider round"></span>\n </label>`,u.appendChild(b),i.users&&i.users.length&&(!1!==i.currentUser&&null!==i.currentUser&&void 0!==i.currentUser||u.classList.add("smart-hidden"));const f=b.querySelector("input");f.onchange=()=>{i.editing.dialog.autoSave=f.checked},i._currentUser.info&&!i._currentUser.allowEdit&&(u.classList.add("smart-hidden"),e.btnComments.classList.add("smart-hidden"),e.btnLink.classList.add("smart-hidden"),e.btnDelete.classList.add("smart-hidden")),!0===i.editing.dialog.autoSave&&(f.checked=!0),p.onclick=()=>{e.btnCancel.click()},m.onclick=()=>{e.btnConfirm.click()},Smart.Utilities.Core.isMobile&&(c.setAttribute("mobile",""),e.setAttribute("mobile",""));let h=0;for(let e=0;e<i.columns.length;e++){const t=i.columns[e];t.allowEdit&&!1!==t._visible&&h++}h>=8?r.classList.add("many"):r.classList.remove("many"),e.editorsContent=r,e.activityContent=d,e.layoutContent=c,e.footerContent=u,setTimeout((()=>{e.editorsContent.scrollHeight>e.editorsContent.offsetHeight?(u.style.setProperty("--smart-background","var(--smart-surface)"),u.style.borderTopStyle="solid",u.style.borderTopColor="var(--smart-border)",u.style.borderTopWidth="1px",p.classList.add("flat")):(u.style.setProperty("--smart-background",""),u.style.borderTopStyle="",u.style.borderTopColor="",u.style.borderTopWidth="",p.classList.remove("flat"))}),200);const y=document.createElement("div"),v=document.createElement("div");d.appendChild(y),d.appendChild(v);let C=o&&o.length?" ("+o.length+")":"";y.innerHTML=`\n <div class="tabs">\n <div view="comments" class="active tab"><div class="smart-flex tab-label"><span class="smart-grid-icon smart-icon-comment show"></span><span>${i.localize("commentsTab")}<span>${C}</span></span></div></div>\n <div view="history" class="tab smart-hidden"><div class="smart-flex tab-label"><span class="smart-grid-icon smart-icon-history show"></span>${i.localize("historyTab")}</div></div>\n <div view="details" class="tab"><div class="smart-flex tab-label"><span class="smart-grid-icon smart-icon-font show"></span>${i.localize("detailsTab")}</div></div>\n </div>\n <div class="smart-hidden details-tab">\n <div class="smart-grid-edit-dialog-row" style="grid-template-rows: auto;"><div class="column"><div class="header smart-grid-edit-dialog-column-info">${i.localize("format").replace(":","")}\n <span title="${i.localize("resetFormat")}" class="reset-format smart-grid-icon smart-icon-reload show"></span>\n </div>\n </div>\n <div class="format-layout">\n <div class="format-layout button-group">\n <span title="${i.localize("bold")}" class="formatbtn bold smart-grid-icon smart-icon-bold show"></span>\n <span title="${i.localize("italic")}" class="formatbtn italic smart-grid-icon smart-icon-italic show"></span>\n <span title="${i.localize("underline")}" class="formatbtn underline smart-grid-icon smart-icon-underline show"></span>\n <span style="text-decoration: line-through;" title="${i.localize("linethrough")}" class="formatbtn linethrough smart-grid-icon smart-icon-font show"></span>\n </div>\n </div>\n <div style="display: flex; flex-direction: column; justify-content: center;" class="format-layout font-group smart-flex">\n <span>${i.localize("fontFamily").replace(":","")}</span>\n <div title="${i.localize("fontFamily").replace(":","")}" class="format smart-grid-edit-dialog-column-info">\n <span class="smart-grid-icon sm