@prolibu-suite/cobalt-core 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/custom-elements.json +113 -34
  2. package/dist/cjs/co-button.cjs.entry.js +1 -1
  3. package/dist/cjs/co-chip_2.cjs.entry.js +1 -1
  4. package/dist/cjs/co-document-editor.cjs.entry.js +1 -1
  5. package/dist/cjs/co-modal.cjs.entry.js +27 -1
  6. package/dist/cjs/co-overlay.cjs.entry.js +205 -34
  7. package/dist/cjs/co-rich-text-editor.cjs.entry.js +2 -2
  8. package/dist/cjs/co-rich-text-viewer.cjs.entry.js +1 -1
  9. package/dist/cjs/cobalt.cjs.js +1 -1
  10. package/dist/cjs/{index-oMHzCXm6.js → index-BbSD1Eyw.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/cjs/{pagination-DV43TRj9.js → pagination-S2sSAgdl.js} +26 -2
  13. package/dist/cobalt/cobalt.esm.js +1 -1
  14. package/dist/cobalt/{p-d6e7c258.entry.js → p-02ff847e.entry.js} +1 -1
  15. package/dist/cobalt/{p-87e62e2b.entry.js → p-12914c0a.entry.js} +1 -1
  16. package/dist/cobalt/p-38eb2615.entry.js +1 -0
  17. package/dist/cobalt/{p-47eca182.entry.js → p-6c7e423c.entry.js} +1 -1
  18. package/dist/cobalt/p-93063876.entry.js +1 -0
  19. package/dist/cobalt/{p-RVQJEYxa.js → p-Ch-Tygdb.js} +1 -1
  20. package/dist/cobalt/p-DGLDAl09.js +1 -0
  21. package/dist/cobalt/{p-3b6efb79.entry.js → p-bb7bbe70.entry.js} +1 -1
  22. package/dist/cobalt/p-efd3e0de.entry.js +1 -0
  23. package/dist/collection/components/co-autocomplete/co-autocomplete.js +1 -1
  24. package/dist/collection/components/co-avatar-group/co-avatar-group.js +1 -1
  25. package/dist/collection/components/co-button/co-button.css +15 -0
  26. package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +1 -1
  27. package/dist/collection/components/co-chip/co-chip.css +16 -11
  28. package/dist/collection/components/co-color-area/co-color-area.js +2 -2
  29. package/dist/collection/components/co-color-slider/co-color-slider.js +1 -1
  30. package/dist/collection/components/co-combobox/co-combobox.js +1 -1
  31. package/dist/collection/components/co-command-search/co-command-search.js +1 -1
  32. package/dist/collection/components/co-data-table/co-data-table.js +1 -1
  33. package/dist/collection/components/co-date-range-picker/co-date-range-picker.js +2 -2
  34. package/dist/collection/components/co-document-editor/co-document-editor.js +5 -5
  35. package/dist/collection/components/co-modal/co-modal.js +68 -1
  36. package/dist/collection/components/co-overlay/co-overlay.css +7 -0
  37. package/dist/collection/components/co-overlay/co-overlay.js +130 -26
  38. package/dist/collection/components/co-overlay/focusTrap.js +111 -3
  39. package/dist/collection/components/co-popover/co-popover.js +1 -1
  40. package/dist/collection/components/co-radio-group/co-radio-group.js +1 -1
  41. package/dist/collection/components/co-ref-field/co-ref-field.js +4 -4
  42. package/dist/collection/components/co-segmented-bar/co-segmented-bar.js +1 -1
  43. package/dist/collection/components/co-select/co-select.js +1 -1
  44. package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +1 -1
  45. package/dist/collection/components/co-toast/co-toast.js +2 -2
  46. package/dist/collection/components/co-transfer-list/co-transfer-list.js +1 -1
  47. package/dist/collection/components/co-tree-item/co-tree-item.js +2 -2
  48. package/dist/components/co-autocomplete.js +1 -1
  49. package/dist/components/co-button.js +1 -1
  50. package/dist/components/co-chip.js +1 -1
  51. package/dist/components/co-column-picker.js +1 -1
  52. package/dist/components/co-combobox.js +1 -1
  53. package/dist/components/co-command-search.js +1 -1
  54. package/dist/components/co-data-table.js +1 -1
  55. package/dist/components/co-date-picker.js +1 -1
  56. package/dist/components/co-date-range-picker.js +1 -1
  57. package/dist/components/co-date-range.js +1 -1
  58. package/dist/components/co-date-time-picker.js +1 -1
  59. package/dist/components/co-document-editor.js +1 -1
  60. package/dist/components/co-drawer.js +1 -1
  61. package/dist/components/co-modal.js +1 -1
  62. package/dist/components/co-overlay.js +1 -1
  63. package/dist/components/co-rich-text-editor.js +1 -1
  64. package/dist/components/co-rich-text-viewer.js +1 -1
  65. package/dist/components/{p-BVdCvEza.js → p-BI_VaFsx.js} +1 -1
  66. package/dist/components/{p-Du8EpQb-.js → p-C_6szR7t.js} +1 -1
  67. package/dist/components/{p-RVQJEYxa.js → p-Ch-Tygdb.js} +1 -1
  68. package/dist/components/{p-zJ3pjFzW.js → p-DB8DGMc-.js} +1 -1
  69. package/dist/components/p-DGLDAl09.js +1 -0
  70. package/dist/components/{p-Hi57w2_2.js → p-DhPxNA2f.js} +1 -1
  71. package/dist/components/p-wUXcJGdy.js +1 -0
  72. package/dist/esm/co-button.entry.js +1 -1
  73. package/dist/esm/co-chip_2.entry.js +1 -1
  74. package/dist/esm/co-document-editor.entry.js +1 -1
  75. package/dist/esm/co-modal.entry.js +28 -2
  76. package/dist/esm/co-overlay.entry.js +205 -34
  77. package/dist/esm/co-rich-text-editor.entry.js +2 -2
  78. package/dist/esm/co-rich-text-viewer.entry.js +1 -1
  79. package/dist/esm/cobalt.js +1 -1
  80. package/dist/esm/{index-Cpo8HTwr.js → index-CgyOJePd.js} +1 -1
  81. package/dist/esm/loader.js +1 -1
  82. package/dist/esm/{pagination-D9OfZUnY.js → pagination-BzrIQtrk.js} +26 -2
  83. package/dist/types/components/co-modal/co-modal.d.ts +23 -0
  84. package/dist/types/components/co-overlay/co-overlay.d.ts +29 -1
  85. package/dist/types/components/co-overlay/focusTrap.d.ts +24 -3
  86. package/dist/types/components.d.ts +21 -2
  87. package/package.json +4 -4
  88. package/dist/cobalt/p-1a5bec8c.entry.js +0 -1
  89. package/dist/cobalt/p-67a024dd.entry.js +0 -1
  90. package/dist/cobalt/p-B1JT7us1.js +0 -1
  91. package/dist/cobalt/p-c4c997f3.entry.js +0 -1
  92. package/dist/components/p-B1JT7us1.js +0 -1
  93. package/dist/components/p-nrwDl_gx.js +0 -1
@@ -1 +1 @@
1
- import{t,p as e,H as o,c as i,f as s,h as r,a}from"./index.js";import{d as c,g as n}from"./p-B9wdMd_0.js";import{b as d,s as h}from"./p-BmdKHBZP.js";import{d as l}from"./p-KK2vAKs-.js";import{d as u}from"./p-DsuFNmTI.js";import{d as g}from"./p-8XzG8pzY.js";import{d as p}from"./p-BdmzslA5.js";import{d as m}from"./p-9VoFSbIH.js";import{B as b,F as f,E as v,w as y,r as x,Q as _,s as w,q as k,x as z,z as C,W as P,I as H,P as S,G as E}from"./p-RVQJEYxa.js";const M={top:38,right:38,bottom:38,left:38},N=new Set(["letter","a4","legal"]);function $(t){if("string"==typeof t){if(N.has(t))return t;try{return $(JSON.parse(t))}catch(t){return"letter"}}if(t&&"object"==typeof t){const{width:e,height:o}=t;if(Number(e)>0&&Number(o)>0)return{width:Number(e),height:Number(o)}}return"letter"}const j=/@(import|charset|namespace)[^;]*;/gi;function I(t,e){return t?F(t.replace(/\/\*[\s\S]*?\*\//g,"").replace(j,""),e).trim():""}function O(t,e){let o=0,i=null;for(let s=e;s<t.length;s+=1){const e=t[s];if(i)e===i&&"\\"!==t[s-1]&&(i=null);else if('"'===e||"'"===e)i=e;else if("{"===e)o+=1;else if("}"===e&&(o-=1,0===o))return s}return-1}function L(t,e){const o=t.trim();if(!o)return"";const i=`:where(${e})`;if("*"===o)return`${i}, ${i} *, ${i} :is(pre, code)`;const s=o.replace(/^(?:(?:html|body|:root)(?=$|[\s>+~.#:[])\s*)+/i,"").trim();return s?`${i} ${s}`:i}function F(t,e){let o="",i=0;for(;i<t.length;){const s=t.indexOf("{",i);if(-1===s)break;const r=O(t,s);if(-1===r)break;const a=t.slice(i,s).trim(),c=t.slice(s+1,r);if(i=r+1,!a)continue;if(a.startsWith("@")){const t=a.slice(1).split(/[\s(]/)[0].toLowerCase();"media"===t||"supports"===t?o+=`${a}{${F(c,e)}}`:t.endsWith("keyframes")&&(o+=`${a}{${c}}`);continue}const n=a.split(",").map((t=>L(t,e))).filter(Boolean);n.length&&(o+=`${n.join(", ")}{${c}}`)}return o}function B(t){return Number.isFinite(t)?Math.round(1e3*Math.min(3,Math.max(.25,t)))/1e3:1}function G(t,e,o){return o>0?(t-e)/o:0}function R(t,e,o,i){return t+e*o-i}const A={inline:"image-square","wrap-left":"text-align-left","wrap-right":"text-align-right",break:"rows"},J={width:124,height:34};function T(t,e){let o=0,i=t;for(;i&&i!==e;)o+=i.offsetLeft,i=i.offsetParent;return o}let V=0;const D=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.coChange=i(this,"coChange",3),this.coFieldsChange=i(this,"coFieldsChange",3),this.coHeaderChange=i(this,"coHeaderChange",3),this.coPagesChange=i(this,"coPagesChange",3),this.coAction=i(this,"coAction",3),this.coReady=i(this,"coReady",3),this.value=null,this.headerHtml="",this.showPageNumber=!1,this.pageSize="letter",this.headerHeight=45,this.pageStyles="",this.readonly=!1,this.locale="en",this.ready=!1,this.pageCount=1,this.zoomMode="fit",this.scale=1,this.stageHeight=0,this.headerEditing=!1,this.draftShowPageNumber=!1,this.imageBar=null,this.currentHeaderHtml="",this.currentShowPageNumber=!1,this.headerDoc=null,this.instanceId=++V+"",this.applyingExternal=!1,this.lastAppliedValue=null,this.userDirty=!1,this.lastFieldsKey="",this.pendingImageSrcs=new Set,this.changeThrottle=function(t,e){let o=null;return{run(){o||(o=setTimeout((()=>{o=null,e()}),250))},flush(){o&&(clearTimeout(o),o=null,e())},cancel(){o&&clearTimeout(o),o=null},get pending(){return null!==o}}}(0,(()=>this.emitPendingChange())),this.updateImageBar=()=>{const t=this.editor,e=null==t?void 0:t.state.selection,o=null==e?void 0:e.node;if(!t||this.readonly||!o||"image"!==o.type.name)return void(this.imageBar&&(this.imageBar=null));const i=t.view.nodeDOM(e.from),s=this.el.querySelector(".co-doc-editor__sheet");if(!i||!s)return void(this.imageBar&&(this.imageBar=null));const r=E(i,s),a=function(t,e,o=J,i=4){const s=t.top+t.height+i,r=t.top-i-o.height;let a=s,c="below";e.height>0&&s+o.height>e.height&&(r>=0?(a=r,c="above"):(a=Math.max(0,Math.min(t.top+t.height-i-o.height,e.height-o.height)),c="inside"));let n=t.left;return e.width>0&&(n=Math.max(0,Math.min(n,e.width-o.width))),{top:a,left:n,placement:c}}({top:r.top,height:r.height,left:T(i,s)},{width:s.offsetWidth,height:s.offsetHeight}),c=b({wrapperStyle:o.attrs.wrapperStyle,containerStyle:o.attrs.containerStyle}),n=this.imageBar;n&&n.mode===c&&n.top===a.top&&n.left===a.left||(this.imageBar={mode:c,top:a.top,left:a.left})},this.onBodyImageLoad=t=>{const e=t.target,o=this.editor;if(!o||!e||"IMG"!==e.tagName)return;const i=e.getAttribute("src")||"";if(!this.pendingImageSrcs.has(i))return;let s=-1;o.state.doc.descendants(((t,e)=>!(s>=0||("image"!==t.type.name||t.attrs.width||t.attrs.src!==i||(s=e),0))));const r=s>=0?o.state.doc.nodeAt(s):null;if(!r)return;const a=this.marginsPx,c=function(t,e){const o=t>0?t:0,i=e>0?e:0,s=o&&i?Math.min(o,i):o||i;return s?Math.max(1,Math.round(s)):null}(e.naturalWidth,this.pageSizePx.width-a.left-a.right);if(!c)return;let n=!1;o.state.doc.descendants(((t,e)=>(e===s||"image"!==t.type.name||t.attrs.width||t.attrs.src!==i||(n=!0),!n))),n||this.pendingImageSrcs.delete(i);const d=o.state.selection.node&&o.state.selection.from===s;o.view.dispatch(o.state.tr.setNodeMarkup(s,void 0,Object.assign(Object.assign({},r.attrs),{width:c}))),d&&o.commands.setNodeSelection(s)},this.onEditorBlur=()=>{this.changeThrottle.flush()},this.onHostKeydown=t=>{"Escape"===t.key&&this.changeThrottle.flush()},this.onTransaction=({transaction:t})=>{t.docChanged&&(this.applyingExternal||!!t.getMeta(f)||(this.userDirty=!0,this.trackInsertedImages(t)),this.changeThrottle.run())},this.handleToolbarAction=t=>{t.stopPropagation();const{action:e,payload:o}=t.detail||{};o&&!0===o.extra?this.coAction.emit({action:e,payload:{extra:!0}}):"documentHeader"===e&&this.startHeaderEdit()},this.startHeaderEdit=()=>{this.readonly||this.headerEditing||!this.editor||(this.draftShowPageNumber=this.currentShowPageNumber,this.headerEditing=!0,this.refreshPagination())},this.onHeaderTransaction=({transaction:t})=>{t.docChanged&&this.changeThrottle.run()},this.onHeaderImageLoad=t=>{const e=t.target,o=this.headerEditor;if(!o||!e||"IMG"!==e.tagName)return;const i=v({w:e.naturalWidth,h:e.naturalHeight});if(!i)return;let s=-1;try{const t=o.view.posAtDOM(e,0),i=o.state.doc.nodeAt(t);i&&"image"===i.type.name&&(s=t)}catch(t){}if(s<0){const t=e.getAttribute("src");o.state.doc.descendants(((e,o)=>!(s>=0||("image"!==e.type.name||e.attrs.width||e.attrs.src!==t||(s=o),0))))}const r=s>=0?o.state.doc.nodeAt(s):null;r&&!r.attrs.width&&o.view.dispatch(o.state.tr.setNodeMarkup(s,void 0,Object.assign(Object.assign({},r.attrs),{width:i})))},this.onDocumentPointer=t=>{const e=t.composedPath();this.headerBandEl&&e.includes(this.headerBandEl)||this.toolbarEl&&e.includes(this.toolbarEl)||this.commitHeader()},this.onHeaderKeydown=t=>{var e;if("Escape"!==t.key||t.isComposing)return;const o=this.toolbarEl;o&&t.currentTarget===o&&(null===(e=o.shadowRoot)||void 0===e?void 0:e.querySelector('[aria-expanded="true"]'))||(t.preventDefault(),t.stopPropagation(),this.cancelHeader(!0))},this.commitHeader=(t=!1)=>{var e;const o=this.headerEditor;if(!o)return;const i=t&&this.focusIsInBandOrLost(),s=o.isEmpty?"":y(o.state.doc,"print-header",this.resolvedFeatures),r=this.draftShowPageNumber;this.teardownHeaderEditor(),this.currentHeaderHtml=s,this.currentShowPageNumber=r,this.headerDoc=s?x(s,"print-header",this.resolvedFeatures):null,this.headerEditing=!1,this.refreshPagination(),this.coHeaderChange.emit({html:s,showPageNumber:r}),this.emitFieldsIfChanged(),i&&(null===(e=this.editor)||void 0===e||e.commands.focus())},this.cancelHeader=(t=!1)=>{var e;this.headerEditing&&(this.teardownHeaderEditor(),this.headerEditing=!1,this.refreshPagination(),this.emitFieldsIfChanged(),t&&(null===(e=this.editor)||void 0===e||e.commands.focus()))},this.renderedScale=1,this.onCanvasWheel=t=>{(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.zoomTo(function(t,e){return Number.isFinite(e)?B(t*Math.exp(.01*-e)):t}(this.scale,1===t.deltaMode?16*t.deltaY:t.deltaY),t.clientX,t.clientY))},this.gestureBase=1,this.onGestureStart=t=>{t.preventDefault(),this.gestureBase=this.scale},this.onGestureChange=t=>{var e,o,i,s;t.preventDefault();const r=null===(e=this.canvasEl)||void 0===e?void 0:e.getBoundingClientRect(),a=null!==(o=t.clientX)&&void 0!==o?o:r?r.left+r.width/2:0,c=null!==(i=t.clientY)&&void 0!==i?i:r?r.top+r.height/2:0;this.zoomTo(B(this.gestureBase*(null!==(s=t.scale)&&void 0!==s?s:1)),a,c)}}get s(){return n(this.locale)}get resolvedFeatures(){var t;return null!==(t=d(this.features))&&void 0!==t?t:{}}get parsedExtraItems(){const t=d(this.extraItems);return Array.isArray(t)?t:[]}get pageSizePx(){return _($(this.pageSize))}get marginsPx(){return function(t){let e=t;if("string"==typeof t)try{e=JSON.parse(t)}catch(t){return Object.assign({},M)}if(!e||"object"!=typeof e)return Object.assign({},M);const o=e,i=t=>Number.isFinite(Number(o[t]))&&void 0!==o[t]?Number(o[t]):M[t];return{top:i("top"),right:i("right"),bottom:i("bottom"),left:i("left")}}(this.margins)}get hasHeader(){return!!this.currentHeaderHtml||this.headerEditing}get sanitizedHeaderHtml(){return w(this.currentHeaderHtml,"print-header")}get pageScope(){return`.co-doc-editor__sheet[data-co-doc="${this.instanceId}"]`}get activeEditor(){var t;return null!==(t=this.headerEditor)&&void 0!==t?t:this.editor}get documentHeaderEnabled(){return!this.readonly&&!this.headerEditing}buildCustomExtensions(){return[k.configure({page:this.pageSizePx,margins:this.marginsPx,header:{height:this.hasHeader?this.headerHeight:0},footer:{height:0},renderHeader:(t,e)=>this.buildHeaderClone(t,e),onPagesChange:t=>{this.pageCount=t,this.coPagesChange.emit(t)}})]}collectAllFields(){if(!this.editor)return[];const t=z(this.editor.state.doc),e=this.headerEditor?this.headerEditor.state.doc:this.headerDoc;return e&&z(e,t),t}connectedCallback(){this.el.addEventListener("keydown",this.onHostKeydown,!0)}componentWillLoad(){this.ready=!1,this.pageCount=1,this.zoomMode="fit",this.scale=1,this.stageHeight=0,this.headerEditing=!1,this.draftShowPageNumber=!1,this.imageBar=null}componentDidLoad(){var t,e,o;this.contentEl&&(this.syncHeaderFromProps(),this.editor=C({preset:"print",element:this.contentEl,content:this.value?this.parseBody(this.value):null,editable:!this.readonly,features:this.resolvedFeatures,labels:{signature:t=>`${this.s.signature} ${t}`,fieldName:this.s.fieldNamePlaceholder},customExtensions:this.buildCustomExtensions(),imageUpload:this.imageUpload}),this.lastAppliedValue=this.value,this.wireEditor(this.editor),this.applyPageStyles(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver((()=>this.updateScale())),this.canvasEl&&this.resizeObserver.observe(this.canvasEl),this.stageEl&&this.resizeObserver.observe(this.stageEl)),null===(t=this.canvasEl)||void 0===t||t.addEventListener("wheel",this.onCanvasWheel,{passive:!1}),null===(e=this.canvasEl)||void 0===e||e.addEventListener("gesturestart",this.onGestureStart),null===(o=this.canvasEl)||void 0===o||o.addEventListener("gesturechange",this.onGestureChange),this.updateScale(),this.syncToolbar(),this.ready=!0,this.emitFieldsIfChanged(),this.coReady.emit())}componentDidRender(){this.applyPendingAnchor(),this.headerEditing&&!this.headerEditor&&this.headerMountEl&&this.mountHeaderEditor(),this.syncToolbar()}disconnectedCallback(){var t,e,o,i;this.el.removeEventListener("keydown",this.onHostKeydown,!0),this.changeThrottle.cancel(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0,null===(e=this.canvasEl)||void 0===e||e.removeEventListener("wheel",this.onCanvasWheel),null===(o=this.canvasEl)||void 0===o||o.removeEventListener("gesturestart",this.onGestureStart),null===(i=this.canvasEl)||void 0===i||i.removeEventListener("gesturechange",this.onGestureChange),this.toolbarEl&&(this.toolbarEl.editor=void 0),this.teardownHeaderEditor(!1),this.headerEditing=!1,this.editor&&(this.editor.off("transaction",this.onTransaction),this.editor.off("blur",this.onEditorBlur),this.editor.off("transaction",this.updateImageBar),this.editor.view.dom.removeEventListener("load",this.onBodyImageLoad,!0),this.editor.destroy()),this.editor=void 0,this.pendingImageSrcs.clear(),this.imageBar=null}onValueChange(t){t!==this.lastAppliedValue&&(this.editor&&t&&t===y(this.editor.state.doc,"print",this.resolvedFeatures)?this.lastAppliedValue=t:this.applyBody(t))}onReadonlyChange(){var t;null===(t=this.editor)||void 0===t||t.setEditable(!this.readonly),this.readonly&&this.headerEditing&&this.cancelHeader(),this.updateImageBar()}onPageGeometryChange(){this.refreshPagination(),this.updateScale()}onHeaderPropsChange(){this.headerEditing||(this.syncHeaderFromProps(),this.refreshPagination(),this.emitFieldsIfChanged())}onPageStylesChange(){this.applyPageStyles()}onLabelChange(){this.editor&&this.editor.view.dom.setAttribute("aria-label",this.label||this.s.documentEditor)}onLocaleChange(){this.currentShowPageNumber&&this.refreshPagination()}async getPrintHtml(){return this.editor?y(this.editor.state.doc,"print",this.resolvedFeatures):""}async getHeaderHtml(){return this.currentHeaderHtml}async getJSON(){return this.editor?this.editor.getJSON():null}async flushChange(){this.changeThrottle.flush()}async isEmpty(){return!this.editor||this.editor.isEmpty}async setContent(t){this.applyBody(t)}async setFieldValues(t){var e,o;if(null===(e=this.editor)||void 0===e||e.commands.setFieldValues(t),null===(o=this.headerEditor)||void 0===o||o.commands.setFieldValues(t),!this.currentHeaderHtml)return;const i=P(this.currentHeaderHtml,t,"print-header",this.resolvedFeatures);i!==this.currentHeaderHtml&&(this.currentHeaderHtml=i,this.headerDoc=x(i,"print-header",this.resolvedFeatures),this.headerEditing||(this.refreshPagination(),s(this)))}async insertField(t,e){var o;null===(o=this.editor)||void 0===o||o.chain().focus().insertField(t,e).run()}async insertSignatureSlot(){var t;null===(t=this.editor)||void 0===t||t.chain().focus().insertSignatureSlot().run()}async focusEditor(){var t;null===(t=this.editor)||void 0===t||t.commands.focus()}async getEditorInstance(){var t;return null!==(t=this.editor)&&void 0!==t?t:null}wireEditor(t){const e=t.view.dom;e.classList.add("tiptap"),e.setAttribute("aria-label",this.label||this.s.documentEditor),e.setAttribute("aria-multiline","true"),t.on("transaction",this.onTransaction),t.on("transaction",this.updateImageBar),t.on("blur",this.onEditorBlur),e.addEventListener("load",this.onBodyImageLoad,!0)}imageModeLabel(t){const e=this.s;return{inline:e.imageLayoutInline,"wrap-left":e.imageLayoutWrapLeft,"wrap-right":e.imageLayoutWrapRight,break:e.imageLayoutBreak}[t]}setImageMode(t){var e;null===(e=this.editor)||void 0===e||e.commands.setImageLayoutMode(t),this.updateImageBar()}trackInsertedImages(t){var e,o,i;if(t.getMeta("history$"))return;const s=[];for(const r of t.steps)null===(i=null===(o=null===(e=r.slice)||void 0===e?void 0:e.content)||void 0===o?void 0:o.descendants)||void 0===i||i.call(o,(t=>{"image"===t.type.name&&!t.attrs.width&&t.attrs.src&&s.push(t.attrs.src)}));if(!s.length)return;const r=new Set;t.before.descendants((t=>{"image"!==t.type.name||t.attrs.width||r.add(t.attrs.src)})),s.forEach((t=>{r.has(t)||this.pendingImageSrcs.add(t)}))}parseBody(t){const e=t.trim();if(e.startsWith("{"))try{return JSON.parse(e)}catch(t){}return x(t,"print",this.resolvedFeatures)}applyBody(t){if(this.editor){this.pendingImageSrcs.clear(),this.applyingExternal=!0;try{t?this.editor.commands.setContent(this.parseBody(t),{emitUpdate:!1}):this.editor.commands.clearContent(!1)}finally{this.applyingExternal=!1,this.lastAppliedValue=t}}}emitPendingChange(){this.editor&&(this.emitFieldsIfChanged(),this.userDirty&&(this.userDirty=!1,this.coChange.emit()))}emitFieldsIfChanged(){const t=this.collectAllFields(),e=JSON.stringify(t);e!==this.lastFieldsKey&&(this.lastFieldsKey=e,this.coFieldsChange.emit(t))}syncToolbar(){h(this.toolbarEl,this.activeEditor,this.imageUpload)}syncHeaderFromProps(){this.currentHeaderHtml=this.headerHtml||"",this.currentShowPageNumber=function(t){return!0===t||"true"===t}(this.showPageNumber),this.headerDoc=this.currentHeaderHtml?x(this.currentHeaderHtml,"print-header",this.resolvedFeatures):null}mountHeaderEditor(){var t,e;const o=C({preset:"print-header",element:this.headerMountEl,content:this.currentHeaderHtml?x(this.currentHeaderHtml,"print-header",this.resolvedFeatures):null,editable:!0,features:{fields:this.resolvedFeatures.fields},labels:{fieldName:this.s.fieldNamePlaceholder},imageUpload:this.imageUpload});this.headerEditor=o;const i=o.view.dom;i.classList.add("tiptap"),i.setAttribute("aria-label",this.s.documentHeader),o.on("transaction",this.onHeaderTransaction),i.addEventListener("load",this.onHeaderImageLoad,!0),document.addEventListener("mousedown",this.onDocumentPointer,!0),null===(t=this.headerBandEl)||void 0===t||t.addEventListener("keydown",this.onHeaderKeydown,!0),null===(e=this.toolbarEl)||void 0===e||e.addEventListener("keydown",this.onHeaderKeydown,!0),o.commands.focus("end"),this.syncToolbar()}teardownHeaderEditor(t=!0){var e,o;document.removeEventListener("mousedown",this.onDocumentPointer,!0),null===(e=this.headerBandEl)||void 0===e||e.removeEventListener("keydown",this.onHeaderKeydown,!0),null===(o=this.toolbarEl)||void 0===o||o.removeEventListener("keydown",this.onHeaderKeydown,!0);const i=this.headerEditor;this.headerEditor=void 0,t?this.syncToolbar():this.toolbarEl&&i&&this.toolbarEl.editor===i&&(this.toolbarEl.editor=void 0),i&&(i.off("transaction",this.onHeaderTransaction),i.view.dom.removeEventListener("load",this.onHeaderImageLoad,!0),i.destroy())}focusIsInBandOrLost(){const t=document.activeElement;return!t||t===document.body||!(!this.headerBandEl||!this.headerBandEl.contains(t))}refreshPagination(){var t;null===(t=this.editor)||void 0===t||t.commands.setPaginationOptions({page:this.pageSizePx,margins:this.marginsPx,header:{height:this.hasHeader?this.headerHeight:0}})}applyPageStyles(){this.styleEl&&(this.styleEl.textContent=I(this.pageStyles,this.pageScope))}buildHeaderClone(t,e){if(!this.currentHeaderHtml)return null;const o=document.createElement("div");o.className="co-doc-editor__header-static",o.style.height=this.headerHeight+"px";const i=document.createElement("div");if(i.className="co-doc-editor__header-html",i.innerHTML=this.sanitizedHeaderHtml,o.appendChild(i),this.currentShowPageNumber){const i=document.createElement("span");i.className="co-doc-editor__page-number",i.textContent=`${this.s.page} ${t} / ${e}`,o.appendChild(i)}return o}updateScale(){var t,e,o,i;if("custom"!==this.zoomMode){const o="actual"===this.zoomMode?1:function(t,e){return t>0&&e>0?Math.round(1e3*Math.min(1,Math.max(.25,t/e)))/1e3:1}((null!==(e=null===(t=this.canvasEl)||void 0===t?void 0:t.clientWidth)&&void 0!==e?e:0)-32,this.pageSizePx.width);o!==this.scale&&(this.scale=o)}const s=null!==(i=null===(o=this.stageEl)||void 0===o?void 0:o.offsetHeight)&&void 0!==i?i:0;s!==this.stageHeight&&(this.stageHeight=s)}zoomTo(t,e,o){if(this.canvasEl&&this.stageEl&&t!==this.scale){if(this.pendingAnchor)this.pendingAnchor.cx=e,this.pendingAnchor.cy=o;else{const t=this.stageEl.getBoundingClientRect();this.pendingAnchor={px:G(e,t.left,this.renderedScale),py:G(o,t.top,this.renderedScale),cx:e,cy:o}}this.zoomMode="custom",this.scale=t}}applyPendingAnchor(){const t=this.pendingAnchor,e=this.canvasEl;if(this.renderedScale=this.scale,!t||!e||!this.stageEl)return;this.pendingAnchor=void 0;const o=this.stageEl.getBoundingClientRect();e.scrollLeft+=R(o.left,t.px,this.scale,t.cx),e.scrollTop+=R(o.top,t.py,this.scale,t.cy)}setZoom(t){this.zoomMode=t,this.updateScale()}renderHeaderBand(){const t=this.s;return r("div",{key:"header-band",class:{"co-doc-editor__header-band":!0,"co-doc-editor__header-band--editing":this.headerEditing},part:"header-band",hidden:!this.hasHeader,ref:t=>this.headerBandEl=t,onDblClick:()=>this.startHeaderEdit()},this.headerEditing?r("div",{key:"header-editing",class:"co-doc-editor__header-editing"},r("div",{class:"co-doc-editor__header-editor",ref:t=>this.headerMountEl=t}),r("div",{class:"co-doc-editor__header-tools"},r("co-switch",{checked:this.draftShowPageNumber,label:t.pageNumber,disabled:!1,required:!1,status:"default",onCoChange:t=>{t.stopPropagation(),this.draftShowPageNumber=!!t.detail}}),r("co-tooltip",{content:t.confirmHeader},r("co-icon-button",{icon:"check",variant:"ghost",size:"xs",boxSize:28,iconSize:16,label:t.confirmHeader,onClick:()=>this.commitHeader(!0)})))):r("div",{key:"header-static",class:"co-doc-editor__header-static"},r("div",{class:"co-doc-editor__header-html",innerHTML:this.sanitizedHeaderHtml}),this.currentShowPageNumber&&r("span",{class:"co-doc-editor__page-number"},`${t.page} 1 / ${this.pageCount}`)))}renderOverlays(){const t=this.imageBar;return!t||this.readonly||this.headerEditing?null:r("div",{key:"image-bar",class:"co-doc-editor__image-bar",role:"toolbar","aria-label":this.s.imageLayoutLabel,style:{top:t.top+"px",left:t.left+"px"},onMouseDown:t=>t.preventDefault()},H.map((e=>{const o=this.imageModeLabel(e),i=t.mode===e;return r("co-tooltip",{key:e,content:o},r("button",{type:"button",class:{"co-doc-editor__image-mode":!0,"co-doc-editor__image-mode--active":i},"data-mode":e,"aria-label":o,"aria-pressed":i+"",onClick:()=>this.setImageMode(e)},r("co-icon",{name:A[e],size:16,"aria-hidden":"true"})))})))}render(){const t=this.s,e=this.pageSizePx,o=this.marginsPx,i={"--co-doc-page-w":e.width+"px","--co-doc-page-h":e.height+"px","--co-doc-margin-top":o.top+"px","--co-doc-margin-right":o.right+"px","--co-doc-margin-bottom":o.bottom+"px","--co-doc-margin-left":o.left+"px","--co-doc-header-h":(this.hasHeader?this.headerHeight:0)+"px","--co-doc-pages":this.pageCount+"","--co-doc-gap":S+"px"},s={width:e.width*this.scale+"px",height:this.stageHeight?this.stageHeight*this.scale+"px":"auto"},c=(t,e)=>r("button",{key:"da1c68e89c973899e18720d3cf25b861d158f7c1",type:"button",class:{"co-doc-editor__zoom-btn":!0,"co-doc-editor__zoom-btn--active":this.zoomMode===t},"aria-pressed":(this.zoomMode===t)+"",onClick:()=>this.setZoom(t)},e);return r(a,{key:"254d9df102441f867dc46eb71039df92d99ad102"},r("div",{key:"29723bbee5dd3eae004c6df4c330e8589388636d",class:{"co-doc-editor":!0,"co-doc-editor--readonly":this.readonly,"co-doc-editor--loading":!this.ready},part:"wrapper"},r("div",{key:"9257d370d8547f08402fbaaed2d4a6aa30d94e70",class:"co-doc-editor__bar",part:"bar"},!this.readonly&&r("co-rich-text-toolbar",{key:"8fff97e80464889cb0e6e60d8d9f69308f987e9f",class:"co-doc-editor__toolbar",part:"toolbar",variant:"document",position:"top",disabled:!1,locale:this.locale,attachmentsEnabled:!1,documentHeaderEnabled:this.documentHeaderEnabled,extraItems:this.parsedExtraItems,onCoAction:this.handleToolbarAction,ref:t=>this.toolbarEl=t}),r("div",{key:"00ff09c93887815f84bbb9c68e9485fd64c3c0b6",class:"co-doc-editor__zoom",role:"group","aria-label":t.zoom},"custom"===this.zoomMode&&r("span",{key:"956f0fa4e803a0e27fa32a28116d1e397a2dc402",class:"co-doc-editor__zoom-level"},Math.round(100*this.scale)+" %"),c("fit",t.zoomFit),c("actual",t.zoomActual))),r("div",{key:"4a44bc41d6a641a5f4543422bd7263f2bd962f99",class:"co-doc-editor__body"},r("div",{key:"467491e684b9487d507861d54c37b06b752216f4",class:"co-doc-editor__canvas",part:"canvas",ref:t=>this.canvasEl=t},r("div",{key:"66653efbda8e0dffb7bc1fdb07d0be31b4f5c8a9",class:"co-doc-editor__zoom-frame",style:s},r("div",{key:"06407fc5177c21f4edc60b900a17a8c44ef193ab",class:"co-doc-editor__stage",style:{transform:`scale(${this.scale})`},ref:t=>this.stageEl=t},r("div",{key:"440f1ced158d76650618bc0f153c3201503550a1",class:"co-doc-editor__sheet",part:"sheet","data-co-doc":this.instanceId,style:i},r("style",{key:"page-styles","data-co-doc-page-styles":"",ref:t=>this.styleEl=t}),r("div",{key:"paper",class:"co-doc-editor__paper","data-theme":"light"},this.renderHeaderBand(),r("div",{key:"content",class:"co-doc-editor__content",ref:t=>this.contentEl=t}),this.renderOverlays()))))),r("slot",{key:"1478889436471ed2707db4e361d878faf7c56f2e",name:"aside"}))))}get el(){return this}static get watchers(){return{value:[{onValueChange:0}],readonly:[{onReadonlyChange:0}],pageSize:[{onPageGeometryChange:0}],margins:[{onPageGeometryChange:0}],headerHeight:[{onPageGeometryChange:0}],headerHtml:[{onHeaderPropsChange:0}],showPageNumber:[{onHeaderPropsChange:0}],pageStyles:[{onPageStylesChange:0}],label:[{onLabelChange:0}],locale:[{onLabelChange:0},{onLocaleChange:0}]}}static get style(){return"co-document-editor{display:block;height:100%;min-height:0}.co-doc-editor{--co-doc-canvas:var(--co-semantic-surface-muted);--co-doc-sheet-shadow:0 1px 3px var(--co-color-opacity-negro-16), 0 0 0 1px var(--co-color-opacity-negro-8);display:flex;flex-direction:column;height:100%;min-height:0;background:var(--co-doc-canvas);color:var(--co-semantic-text-default);font-family:var(--co-font-family-primary)}.co-doc-editor__bar{display:flex;align-items:center;gap:var(--co-spacing-sm2);min-width:0;padding-inline:var(--co-spacing-md);background:var(--co-semantic-surface-page);border-bottom:1px solid var(--co-semantic-border-subtle)}.co-doc-editor__toolbar{flex:1 1 auto;min-width:0}.co-doc-editor__body{flex:1 1 auto;display:flex;min-height:0}.co-doc-editor__body>[slot='aside']{flex:0 0 var(--co-doc-aside-width, 320px);width:var(--co-doc-aside-width, 320px);min-width:0;min-height:0;box-sizing:border-box;border-left:1px solid var(--co-semantic-border-subtle)}.co-doc-editor__canvas{flex:1 1 auto;min-width:0;overflow:auto;box-sizing:border-box;padding:var(--co-spacing-2xl) var(--co-spacing-lg)}.co-doc-editor__content .ProseMirror{position:relative;outline:none}.co-doc-editor--loading .co-doc-editor__content{visibility:hidden}.co-doc-field{--co-doc-field-bg:var(--co-color-primary-amarillo);background:var(--co-doc-field-bg);box-shadow:0 0 0 2px var(--co-doc-field-bg);border-radius:var(--co-border-radius-xxs);color:var(--co-color-base-negro);cursor:pointer}.co-doc-field--empty{--co-doc-field-bg:color-mix(in srgb, var(--co-color-primary-amarillo) 55%, var(--co-color-base-blanco))}.co-doc-field--required.co-doc-field--empty{box-shadow:0 0 0 2px var(--co-doc-field-bg), inset 0 -2px 0 var(--co-color-status-error)}.co-doc-field__input{width:14ch;border:0;outline:1px solid var(--co-semantic-border-focus);background:var(--co-color-base-blanco);font:inherit}.co-doc-signature{display:inline-flex;align-items:center;justify-content:center;vertical-align:top;box-sizing:border-box;outline:1px dashed var(--co-color-primary-azul);outline-offset:-1px;background:color-mix(in srgb, var(--co-color-primary-azul) 6%, transparent);color:var(--co-color-primary-azul);font-size:var(--co-font-size-12);user-select:none}.co-doc-hb{background:color-mix(in srgb, var(--co-color-primary-azul) 12%, transparent);border-radius:var(--co-border-radius-xxs)}.co-doc-editor__zoom{display:inline-flex;flex-shrink:0;align-items:center;gap:var(--co-spacing-xxs);margin-inline-start:auto}.co-doc-editor__zoom-level{min-width:5ch;padding-inline:var(--co-spacing-xs);font-size:var(--co-font-size-13);font-variant-numeric:tabular-nums;text-align:end;color:var(--co-semantic-text-secondary)}.co-doc-editor__zoom-btn{padding:var(--co-spacing-xs) var(--co-spacing-sm2);border:0;border-radius:var(--co-border-radius-xs);background:transparent;color:var(--co-semantic-text-secondary);font:inherit;font-size:var(--co-font-size-13);white-space:nowrap;cursor:pointer}.co-doc-editor__zoom-btn:hover{background:var(--co-semantic-surface-hover)}.co-doc-editor__zoom-btn--active{background:var(--co-semantic-surface-hover);color:var(--co-semantic-text-default)}.co-doc-editor__zoom-btn:focus-visible{outline:1px solid var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-doc-editor__zoom-frame{margin-inline:auto}.co-doc-editor__stage{width:var(--co-doc-page-w);transform-origin:top left}.co-doc-editor__sheet{--co-semantic-surface-page:var(--co-color-base-blanco);--co-semantic-surface-hover:var(--co-color-opacity-negro-8);--co-semantic-text-default:var(--co-color-base-negro);--co-semantic-text-secondary:var(--co-color-gray-600);--co-semantic-text-muted:var(--co-color-gray-500);--co-semantic-border-default:var(--co-color-opacity-negro-16);--co-semantic-border-subtle:var(--co-color-opacity-negro-8);--co-semantic-border-field:var(--co-color-opacity-negro-25);--co-semantic-border-focus:var(--co-color-opacity-negro-50);--co-semantic-border-focus-ring:var(--co-color-opacity-negro-8);position:relative;width:var(--co-doc-page-w);min-height:calc(var(--co-doc-pages, 1) * var(--co-doc-page-h) + (var(--co-doc-pages, 1) - 1) * var(--co-doc-gap));box-sizing:border-box;padding-top:calc(var(--co-doc-margin-top) + var(--co-doc-header-h, 0px));padding-right:var(--co-doc-margin-right);padding-bottom:var(--co-doc-margin-bottom);padding-left:var(--co-doc-margin-left);overflow:clip;background:var(--co-color-base-blanco);color:var(--co-color-base-negro);color-scheme:light;box-shadow:var(--co-doc-sheet-shadow)}.co-doc-editor__paper{display:contents;color:var(--co-semantic-text-default)}.co-doc-editor .co-doc-editor__sheet .co-doc-editor__content .ProseMirror.tiptap{padding:0 !important;min-height:1em}.co-doc-editor__header-band{position:absolute;top:var(--co-doc-margin-top);left:var(--co-doc-margin-left);right:var(--co-doc-margin-right);height:var(--co-doc-header-h);box-sizing:border-box}.co-doc-editor__header-band[hidden]{display:none}.co-doc-editor__header-band:hover{outline:1px dashed var(--co-color-opacity-negro-25)}.co-doc-editor__header-static{display:flex;align-items:center;justify-content:space-between;height:100%;overflow:hidden;font-size:var(--co-font-size-12);line-height:1.5;user-select:none}.co-doc-editor__header-html{flex:1 1 auto;min-width:0;max-height:100%;overflow:hidden}.co-doc-editor__page-number{flex-shrink:0;margin-inline-start:var(--co-spacing-sm2);white-space:nowrap;color:var(--co-color-gray-600)}.co-doc-page-gap,.co-doc-page-gap__foot,.co-doc-page-gap__between,.co-doc-page-gap__head{margin:0 !important;padding:0 !important;border-width:0 !important;box-sizing:border-box !important}.co-doc-editor__sheet .co-doc-page-gap{position:relative;margin-left:calc(-1 * var(--co-doc-margin-left)) !important;margin-right:calc(-1 * var(--co-doc-margin-right)) !important;user-select:none}.co-doc-page-gap__between{background:var(--co-doc-canvas);border-image:linear-gradient(var(--co-doc-canvas), var(--co-doc-canvas)) fill 0 / 0 / 0 100vmax;box-shadow:inset 0 1px 0 var(--co-color-opacity-negro-8), inset 0 4px 3px -3px var(--co-color-opacity-negro-16), inset 0 -1px 0 var(--co-color-opacity-negro-8)}:is(ul,ol)>.co-doc-page-gap{list-style:none}.co-doc-editor__sheet .co-doc-page-gap__head{padding-top:var(--co-doc-margin-top) !important;padding-left:var(--co-doc-margin-left) !important;padding-right:var(--co-doc-margin-right) !important}.co-doc-page-gap-row>td{padding:0 !important;border:0 !important;background:transparent !important}.co-doc-editor__header-band--editing,.co-doc-editor__header-band--editing:hover{outline:1px solid var(--co-semantic-border-focus);outline-offset:2px}.co-doc-editor__header-editing{display:flex;align-items:center;gap:var(--co-spacing-sm2);height:100%}.co-doc-editor__header-editor{flex:1 1 auto;min-width:0;max-height:100%;overflow:hidden;font-size:var(--co-font-size-12);line-height:1.5}.co-doc-editor__header-editor .ProseMirror{outline:none}.co-doc-editor__header-tools{position:absolute;right:0;bottom:100%;display:flex;align-items:center;gap:var(--co-spacing-xs);padding:var(--co-spacing-xxs) var(--co-spacing-xs);box-sizing:border-box;background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs)}.co-doc-editor__image-bar{position:absolute;z-index:2;display:flex;gap:var(--co-spacing-xxs);padding:var(--co-spacing-xxs);box-sizing:border-box;background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);user-select:none}.co-doc-editor__image-bar co-tooltip{display:inline-flex}.co-doc-editor__image-mode{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--co-border-radius-xxs);background:transparent;color:var(--co-semantic-text-default);cursor:pointer}.co-doc-editor__image-mode:hover,.co-doc-editor__image-mode--active{background:var(--co-semantic-surface-hover)}.co-doc-editor__image-mode--active{box-shadow:inset 0 0 0 1px var(--co-semantic-border-focus)}.co-doc-editor__image-mode:focus-visible{outline:1px solid var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-doc-editor__image-mode--active:focus-visible{box-shadow:inset 0 0 0 1px var(--co-semantic-border-focus), 0 0 0 2px var(--co-semantic-border-focus-ring)}"}},[260,"co-document-editor",{value:[1],headerHtml:[1,"header-html"],showPageNumber:[8,"show-page-number"],pageSize:[1,"page-size"],margins:[1],headerHeight:[2,"header-height"],pageStyles:[1,"page-styles"],features:[1],imageUpload:[16],readonly:[4],locale:[1],extraItems:[1,"extra-items"],label:[1],ready:[32],pageCount:[32],zoomMode:[32],scale:[32],stageHeight:[32],headerEditing:[32],draftShowPageNumber:[32],imageBar:[32],getPrintHtml:[64],getHeaderHtml:[64],getJSON:[64],flushChange:[64],isEmpty:[64],setContent:[64],setFieldValues:[64],insertField:[64],insertSignatureSlot:[64],focusEditor:[64],getEditorInstance:[64]},void 0,{value:[{onValueChange:0}],readonly:[{onReadonlyChange:0}],pageSize:[{onPageGeometryChange:0}],margins:[{onPageGeometryChange:0}],headerHeight:[{onPageGeometryChange:0}],headerHtml:[{onHeaderPropsChange:0}],showPageNumber:[{onHeaderPropsChange:0}],pageStyles:[{onPageStylesChange:0}],label:[{onLabelChange:0}],locale:[{onLabelChange:0},{onLocaleChange:0}]}]);function q(){"undefined"!=typeof customElements&&["co-document-editor","co-icon","co-icon-button","co-kbd","co-rich-text-toolbar","co-switch","co-tooltip"].forEach((e=>{switch(e){case"co-document-editor":customElements.get(t(e))||customElements.define(t(e),D);break;case"co-icon":customElements.get(t(e))||l();break;case"co-icon-button":customElements.get(t(e))||u();break;case"co-kbd":customElements.get(t(e))||g();break;case"co-rich-text-toolbar":customElements.get(t(e))||c();break;case"co-switch":customElements.get(t(e))||p();break;case"co-tooltip":customElements.get(t(e))||m()}}))}q();const K=D,U=q;export{K as CoDocumentEditor,U as defineCustomElement}
1
+ import{t,p as e,H as o,c as i,f as s,h as r,a}from"./index.js";import{d as c,g as n}from"./p-B9wdMd_0.js";import{b as d,s as h}from"./p-BmdKHBZP.js";import{d as l}from"./p-KK2vAKs-.js";import{d as g}from"./p-DsuFNmTI.js";import{d as u}from"./p-8XzG8pzY.js";import{d as p}from"./p-BdmzslA5.js";import{d as m}from"./p-9VoFSbIH.js";import{B as b,F as f,E as v,w as y,r as _,Q as x,s as w,q as k,x as z,z as C,W as P,I as H,P as S,G as E}from"./p-Ch-Tygdb.js";const M={top:38,right:38,bottom:38,left:38},N=new Set(["letter","a4","legal"]);function $(t){if("string"==typeof t){if(N.has(t))return t;try{return $(JSON.parse(t))}catch(t){return"letter"}}if(t&&"object"==typeof t){const{width:e,height:o}=t;if(Number(e)>0&&Number(o)>0)return{width:Number(e),height:Number(o)}}return"letter"}const j=/@(import|charset|namespace)[^;]*;/gi;function I(t,e){return t?F(t.replace(/\/\*[\s\S]*?\*\//g,"").replace(j,""),e).trim():""}function O(t,e){let o=0,i=null;for(let s=e;s<t.length;s+=1){const e=t[s];if(i)e===i&&"\\"!==t[s-1]&&(i=null);else if('"'===e||"'"===e)i=e;else if("{"===e)o+=1;else if("}"===e&&(o-=1,0===o))return s}return-1}function L(t,e){const o=t.trim();if(!o)return"";const i=`:where(${e})`;if("*"===o)return`${i}, ${i} *, ${i} :is(pre, code)`;const s=o.replace(/^(?:(?:html|body|:root)(?=$|[\s>+~.#:[])\s*)+/i,"").trim();return s?`${i} ${s}`:i}function F(t,e){let o="",i=0;for(;i<t.length;){const s=t.indexOf("{",i);if(-1===s)break;const r=O(t,s);if(-1===r)break;const a=t.slice(i,s).trim(),c=t.slice(s+1,r);if(i=r+1,!a)continue;if(a.startsWith("@")){const t=a.slice(1).split(/[\s(]/)[0].toLowerCase();"media"===t||"supports"===t?o+=`${a}{${F(c,e)}}`:t.endsWith("keyframes")&&(o+=`${a}{${c}}`);continue}const n=a.split(",").map((t=>L(t,e))).filter(Boolean);n.length&&(o+=`${n.join(", ")}{${c}}`)}return o}function B(t){return Number.isFinite(t)?Math.round(1e3*Math.min(3,Math.max(.25,t)))/1e3:1}function G(t,e,o){return o>0?(t-e)/o:0}function T(t,e,o,i){return t+e*o-i}const A={inline:"image-square","wrap-left":"text-align-left","wrap-right":"text-align-right",break:"rows"},R={width:124,height:34};function J(t,e){let o=0,i=t;for(;i&&i!==e;)o+=i.offsetLeft,i=i.offsetParent;return o}let V=0;const D=e(class extends o{constructor(t){super(),!1!==t&&this.__registerHost(),this.coChange=i(this,"coChange",3),this.coFieldsChange=i(this,"coFieldsChange",3),this.coHeaderChange=i(this,"coHeaderChange",3),this.coPagesChange=i(this,"coPagesChange",3),this.coAction=i(this,"coAction",3),this.coReady=i(this,"coReady",3),this.value=null,this.headerHtml="",this.showPageNumber=!1,this.pageSize="letter",this.headerHeight=45,this.pageStyles="",this.readonly=!1,this.locale="en",this.ready=!1,this.pageCount=1,this.zoomMode="fit",this.scale=1,this.stageHeight=0,this.headerEditing=!1,this.draftShowPageNumber=!1,this.imageBar=null,this.currentHeaderHtml="",this.currentShowPageNumber=!1,this.headerDoc=null,this.instanceId=++V+"",this.applyingExternal=!1,this.lastAppliedValue=null,this.userDirty=!1,this.lastFieldsKey="",this.pendingImageSrcs=new Set,this.changeThrottle=function(t,e){let o=null;return{run(){o||(o=setTimeout((()=>{o=null,e()}),250))},flush(){o&&(clearTimeout(o),o=null,e())},cancel(){o&&clearTimeout(o),o=null},get pending(){return null!==o}}}(0,(()=>this.emitPendingChange())),this.updateImageBar=()=>{const t=this.editor,e=null==t?void 0:t.state.selection,o=null==e?void 0:e.node;if(!t||this.readonly||!o||"image"!==o.type.name)return void(this.imageBar&&(this.imageBar=null));const i=t.view.nodeDOM(e.from),s=this.el.querySelector(".co-doc-editor__sheet");if(!i||!s)return void(this.imageBar&&(this.imageBar=null));const r=E(i,s),a=function(t,e,o=R,i=4){const s=t.top+t.height+i,r=t.top-i-o.height;let a=s,c="below";e.height>0&&s+o.height>e.height&&(r>=0?(a=r,c="above"):(a=Math.max(0,Math.min(t.top+t.height-i-o.height,e.height-o.height)),c="inside"));let n=t.left;return e.width>0&&(n=Math.max(0,Math.min(n,e.width-o.width))),{top:a,left:n,placement:c}}({top:r.top,height:r.height,left:J(i,s)},{width:s.offsetWidth,height:s.offsetHeight}),c=b({wrapperStyle:o.attrs.wrapperStyle,containerStyle:o.attrs.containerStyle}),n=this.imageBar;n&&n.mode===c&&n.top===a.top&&n.left===a.left||(this.imageBar={mode:c,top:a.top,left:a.left})},this.onBodyImageLoad=t=>{const e=t.target,o=this.editor;if(!o||!e||"IMG"!==e.tagName)return;const i=e.getAttribute("src")||"";if(!this.pendingImageSrcs.has(i))return;let s=-1;o.state.doc.descendants(((t,e)=>!(s>=0||("image"!==t.type.name||t.attrs.width||t.attrs.src!==i||(s=e),0))));const r=s>=0?o.state.doc.nodeAt(s):null;if(!r)return;const a=this.marginsPx,c=function(t,e){const o=t>0?t:0,i=e>0?e:0,s=o&&i?Math.min(o,i):o||i;return s?Math.max(1,Math.round(s)):null}(e.naturalWidth,this.pageSizePx.width-a.left-a.right);if(!c)return;let n=!1;o.state.doc.descendants(((t,e)=>(e===s||"image"!==t.type.name||t.attrs.width||t.attrs.src!==i||(n=!0),!n))),n||this.pendingImageSrcs.delete(i);const d=o.state.selection.node&&o.state.selection.from===s;o.view.dispatch(o.state.tr.setNodeMarkup(s,void 0,Object.assign(Object.assign({},r.attrs),{width:c}))),d&&o.commands.setNodeSelection(s)},this.onEditorBlur=()=>{this.changeThrottle.flush()},this.onHostKeydown=t=>{"Escape"===t.key&&this.changeThrottle.flush()},this.onTransaction=({transaction:t})=>{t.docChanged&&(this.applyingExternal||!!t.getMeta(f)||(this.userDirty=!0,this.trackInsertedImages(t)),this.changeThrottle.run())},this.handleToolbarAction=t=>{t.stopPropagation();const{action:e,payload:o}=t.detail||{};o&&!0===o.extra?this.coAction.emit({action:e,payload:{extra:!0}}):"documentHeader"===e&&this.startHeaderEdit()},this.startHeaderEdit=()=>{this.readonly||this.headerEditing||!this.editor||(this.draftShowPageNumber=this.currentShowPageNumber,this.headerEditing=!0,this.refreshPagination())},this.onHeaderTransaction=({transaction:t})=>{t.docChanged&&this.changeThrottle.run()},this.onHeaderImageLoad=t=>{const e=t.target,o=this.headerEditor;if(!o||!e||"IMG"!==e.tagName)return;const i=v({w:e.naturalWidth,h:e.naturalHeight});if(!i)return;let s=-1;try{const t=o.view.posAtDOM(e,0),i=o.state.doc.nodeAt(t);i&&"image"===i.type.name&&(s=t)}catch(t){}if(s<0){const t=e.getAttribute("src");o.state.doc.descendants(((e,o)=>!(s>=0||("image"!==e.type.name||e.attrs.width||e.attrs.src!==t||(s=o),0))))}const r=s>=0?o.state.doc.nodeAt(s):null;r&&!r.attrs.width&&o.view.dispatch(o.state.tr.setNodeMarkup(s,void 0,Object.assign(Object.assign({},r.attrs),{width:i})))},this.onDocumentPointer=t=>{const e=t.composedPath();this.headerBandEl&&e.includes(this.headerBandEl)||this.toolbarEl&&e.includes(this.toolbarEl)||this.commitHeader()},this.onHeaderKeydown=t=>{var e;if("Escape"!==t.key||t.isComposing)return;const o=this.toolbarEl;o&&t.currentTarget===o&&(null===(e=o.shadowRoot)||void 0===e?void 0:e.querySelector('[aria-expanded="true"]'))||(t.preventDefault(),t.stopPropagation(),this.cancelHeader(!0))},this.commitHeader=(t=!1)=>{var e;const o=this.headerEditor;if(!o)return;const i=t&&this.focusIsInBandOrLost(),s=o.isEmpty?"":y(o.state.doc,"print-header",this.resolvedFeatures),r=this.draftShowPageNumber;this.teardownHeaderEditor(),this.currentHeaderHtml=s,this.currentShowPageNumber=r,this.headerDoc=s?_(s,"print-header",this.resolvedFeatures):null,this.headerEditing=!1,this.refreshPagination(),this.coHeaderChange.emit({html:s,showPageNumber:r}),this.emitFieldsIfChanged(),i&&(null===(e=this.editor)||void 0===e||e.commands.focus())},this.cancelHeader=(t=!1)=>{var e;this.headerEditing&&(this.teardownHeaderEditor(),this.headerEditing=!1,this.refreshPagination(),this.emitFieldsIfChanged(),t&&(null===(e=this.editor)||void 0===e||e.commands.focus()))},this.renderedScale=1,this.onCanvasWheel=t=>{(t.ctrlKey||t.metaKey)&&(t.preventDefault(),this.zoomTo(function(t,e){return Number.isFinite(e)?B(t*Math.exp(.01*-e)):t}(this.scale,1===t.deltaMode?16*t.deltaY:t.deltaY),t.clientX,t.clientY))},this.gestureBase=1,this.onGestureStart=t=>{t.preventDefault(),this.gestureBase=this.scale},this.onGestureChange=t=>{var e,o,i,s;t.preventDefault();const r=null===(e=this.canvasEl)||void 0===e?void 0:e.getBoundingClientRect(),a=null!==(o=t.clientX)&&void 0!==o?o:r?r.left+r.width/2:0,c=null!==(i=t.clientY)&&void 0!==i?i:r?r.top+r.height/2:0;this.zoomTo(B(this.gestureBase*(null!==(s=t.scale)&&void 0!==s?s:1)),a,c)}}get s(){return n(this.locale)}get resolvedFeatures(){var t;return null!==(t=d(this.features))&&void 0!==t?t:{}}get parsedExtraItems(){const t=d(this.extraItems);return Array.isArray(t)?t:[]}get pageSizePx(){return x($(this.pageSize))}get marginsPx(){return function(t){let e=t;if("string"==typeof t)try{e=JSON.parse(t)}catch(t){return Object.assign({},M)}if(!e||"object"!=typeof e)return Object.assign({},M);const o=e,i=t=>Number.isFinite(Number(o[t]))&&void 0!==o[t]?Number(o[t]):M[t];return{top:i("top"),right:i("right"),bottom:i("bottom"),left:i("left")}}(this.margins)}get hasHeader(){return!!this.currentHeaderHtml||this.headerEditing}get sanitizedHeaderHtml(){return w(this.currentHeaderHtml,"print-header")}get pageScope(){return`.co-doc-editor__sheet[data-co-doc="${this.instanceId}"]`}get activeEditor(){var t;return null!==(t=this.headerEditor)&&void 0!==t?t:this.editor}get documentHeaderEnabled(){return!this.readonly&&!this.headerEditing}buildCustomExtensions(){return[k.configure({page:this.pageSizePx,margins:this.marginsPx,header:{height:this.hasHeader?this.headerHeight:0},footer:{height:0},renderHeader:(t,e)=>this.buildHeaderClone(t,e),onPagesChange:t=>{this.pageCount=t,this.coPagesChange.emit(t)}})]}collectAllFields(){if(!this.editor)return[];const t=z(this.editor.state.doc),e=this.headerEditor?this.headerEditor.state.doc:this.headerDoc;return e&&z(e,t),t}connectedCallback(){this.el.addEventListener("keydown",this.onHostKeydown,!0)}componentWillLoad(){this.ready=!1,this.pageCount=1,this.zoomMode="fit",this.scale=1,this.stageHeight=0,this.headerEditing=!1,this.draftShowPageNumber=!1,this.imageBar=null}componentDidLoad(){var t,e,o;this.contentEl&&(this.syncHeaderFromProps(),this.editor=C({preset:"print",element:this.contentEl,content:this.value?this.parseBody(this.value):null,editable:!this.readonly,features:this.resolvedFeatures,labels:{signature:t=>`${this.s.signature} ${t}`,fieldName:this.s.fieldNamePlaceholder},customExtensions:this.buildCustomExtensions(),imageUpload:this.imageUpload}),this.lastAppliedValue=this.value,this.wireEditor(this.editor),this.applyPageStyles(),"undefined"!=typeof ResizeObserver&&(this.resizeObserver=new ResizeObserver((()=>this.updateScale())),this.canvasEl&&this.resizeObserver.observe(this.canvasEl),this.stageEl&&this.resizeObserver.observe(this.stageEl)),null===(t=this.canvasEl)||void 0===t||t.addEventListener("wheel",this.onCanvasWheel,{passive:!1}),null===(e=this.canvasEl)||void 0===e||e.addEventListener("gesturestart",this.onGestureStart),null===(o=this.canvasEl)||void 0===o||o.addEventListener("gesturechange",this.onGestureChange),this.updateScale(),this.syncToolbar(),this.ready=!0,this.emitFieldsIfChanged(),this.coReady.emit())}componentDidRender(){this.applyPendingAnchor(),this.headerEditing&&!this.headerEditor&&this.headerMountEl&&this.mountHeaderEditor(),this.syncToolbar()}disconnectedCallback(){var t,e,o,i;this.el.removeEventListener("keydown",this.onHostKeydown,!0),this.changeThrottle.cancel(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0,null===(e=this.canvasEl)||void 0===e||e.removeEventListener("wheel",this.onCanvasWheel),null===(o=this.canvasEl)||void 0===o||o.removeEventListener("gesturestart",this.onGestureStart),null===(i=this.canvasEl)||void 0===i||i.removeEventListener("gesturechange",this.onGestureChange),this.toolbarEl&&(this.toolbarEl.editor=void 0),this.teardownHeaderEditor(!1),this.headerEditing=!1,this.editor&&(this.editor.off("transaction",this.onTransaction),this.editor.off("blur",this.onEditorBlur),this.editor.off("transaction",this.updateImageBar),this.editor.view.dom.removeEventListener("load",this.onBodyImageLoad,!0),this.editor.destroy()),this.editor=void 0,this.pendingImageSrcs.clear(),this.imageBar=null}onValueChange(t){t!==this.lastAppliedValue&&(this.editor&&t&&t===y(this.editor.state.doc,"print",this.resolvedFeatures)?this.lastAppliedValue=t:this.applyBody(t))}onReadonlyChange(){var t;null===(t=this.editor)||void 0===t||t.setEditable(!this.readonly),this.readonly&&this.headerEditing&&this.cancelHeader(),this.updateImageBar()}onPageGeometryChange(){this.refreshPagination(),this.updateScale()}onHeaderPropsChange(){this.headerEditing||(this.syncHeaderFromProps(),this.refreshPagination(),this.emitFieldsIfChanged())}onPageStylesChange(){this.applyPageStyles()}onLabelChange(){this.editor&&this.editor.view.dom.setAttribute("aria-label",this.label||this.s.documentEditor)}onLocaleChange(){this.currentShowPageNumber&&this.refreshPagination()}async getPrintHtml(){return this.editor?y(this.editor.state.doc,"print",this.resolvedFeatures):""}async getHeaderHtml(){return this.currentHeaderHtml}async getJSON(){return this.editor?this.editor.getJSON():null}async flushChange(){this.changeThrottle.flush()}async isEmpty(){return!this.editor||this.editor.isEmpty}async setContent(t){this.applyBody(t)}async setFieldValues(t){var e,o;if(null===(e=this.editor)||void 0===e||e.commands.setFieldValues(t),null===(o=this.headerEditor)||void 0===o||o.commands.setFieldValues(t),!this.currentHeaderHtml)return;const i=P(this.currentHeaderHtml,t,"print-header",this.resolvedFeatures);i!==this.currentHeaderHtml&&(this.currentHeaderHtml=i,this.headerDoc=_(i,"print-header",this.resolvedFeatures),this.headerEditing||(this.refreshPagination(),s(this)))}async insertField(t,e){var o;null===(o=this.editor)||void 0===o||o.chain().focus().insertField(t,e).run()}async insertSignatureSlot(){var t;null===(t=this.editor)||void 0===t||t.chain().focus().insertSignatureSlot().run()}async focusEditor(){var t;null===(t=this.editor)||void 0===t||t.commands.focus()}async getEditorInstance(){var t;return null!==(t=this.editor)&&void 0!==t?t:null}wireEditor(t){const e=t.view.dom;e.classList.add("tiptap"),e.setAttribute("aria-label",this.label||this.s.documentEditor),e.setAttribute("aria-multiline","true"),t.on("transaction",this.onTransaction),t.on("transaction",this.updateImageBar),t.on("blur",this.onEditorBlur),e.addEventListener("load",this.onBodyImageLoad,!0)}imageModeLabel(t){const e=this.s;return{inline:e.imageLayoutInline,"wrap-left":e.imageLayoutWrapLeft,"wrap-right":e.imageLayoutWrapRight,break:e.imageLayoutBreak}[t]}setImageMode(t){var e;null===(e=this.editor)||void 0===e||e.commands.setImageLayoutMode(t),this.updateImageBar()}trackInsertedImages(t){var e,o,i;if(t.getMeta("history$"))return;const s=[];for(const r of t.steps)null===(i=null===(o=null===(e=r.slice)||void 0===e?void 0:e.content)||void 0===o?void 0:o.descendants)||void 0===i||i.call(o,(t=>{"image"===t.type.name&&!t.attrs.width&&t.attrs.src&&s.push(t.attrs.src)}));if(!s.length)return;const r=new Set;t.before.descendants((t=>{"image"!==t.type.name||t.attrs.width||r.add(t.attrs.src)})),s.forEach((t=>{r.has(t)||this.pendingImageSrcs.add(t)}))}parseBody(t){const e=t.trim();if(e.startsWith("{"))try{return JSON.parse(e)}catch(t){}return _(t,"print",this.resolvedFeatures)}applyBody(t){if(this.editor){this.pendingImageSrcs.clear(),this.applyingExternal=!0;try{t?this.editor.commands.setContent(this.parseBody(t),{emitUpdate:!1}):this.editor.commands.clearContent(!1)}finally{this.applyingExternal=!1,this.lastAppliedValue=t}}}emitPendingChange(){this.editor&&(this.emitFieldsIfChanged(),this.userDirty&&(this.userDirty=!1,this.coChange.emit()))}emitFieldsIfChanged(){const t=this.collectAllFields(),e=JSON.stringify(t);e!==this.lastFieldsKey&&(this.lastFieldsKey=e,this.coFieldsChange.emit(t))}syncToolbar(){h(this.toolbarEl,this.activeEditor,this.imageUpload)}syncHeaderFromProps(){this.currentHeaderHtml=this.headerHtml||"",this.currentShowPageNumber=function(t){return!0===t||"true"===t}(this.showPageNumber),this.headerDoc=this.currentHeaderHtml?_(this.currentHeaderHtml,"print-header",this.resolvedFeatures):null}mountHeaderEditor(){var t,e;const o=C({preset:"print-header",element:this.headerMountEl,content:this.currentHeaderHtml?_(this.currentHeaderHtml,"print-header",this.resolvedFeatures):null,editable:!0,features:{fields:this.resolvedFeatures.fields},labels:{fieldName:this.s.fieldNamePlaceholder},imageUpload:this.imageUpload});this.headerEditor=o;const i=o.view.dom;i.classList.add("tiptap"),i.setAttribute("aria-label",this.s.documentHeader),o.on("transaction",this.onHeaderTransaction),i.addEventListener("load",this.onHeaderImageLoad,!0),document.addEventListener("mousedown",this.onDocumentPointer,!0),null===(t=this.headerBandEl)||void 0===t||t.addEventListener("keydown",this.onHeaderKeydown,!0),null===(e=this.toolbarEl)||void 0===e||e.addEventListener("keydown",this.onHeaderKeydown,!0),o.commands.focus("end"),this.syncToolbar()}teardownHeaderEditor(t=!0){var e,o;document.removeEventListener("mousedown",this.onDocumentPointer,!0),null===(e=this.headerBandEl)||void 0===e||e.removeEventListener("keydown",this.onHeaderKeydown,!0),null===(o=this.toolbarEl)||void 0===o||o.removeEventListener("keydown",this.onHeaderKeydown,!0);const i=this.headerEditor;this.headerEditor=void 0,t?this.syncToolbar():this.toolbarEl&&i&&this.toolbarEl.editor===i&&(this.toolbarEl.editor=void 0),i&&(i.off("transaction",this.onHeaderTransaction),i.view.dom.removeEventListener("load",this.onHeaderImageLoad,!0),i.destroy())}focusIsInBandOrLost(){const t=document.activeElement;return!t||t===document.body||!(!this.headerBandEl||!this.headerBandEl.contains(t))}refreshPagination(){var t;null===(t=this.editor)||void 0===t||t.commands.setPaginationOptions({page:this.pageSizePx,margins:this.marginsPx,header:{height:this.hasHeader?this.headerHeight:0}})}applyPageStyles(){this.styleEl&&(this.styleEl.textContent=I(this.pageStyles,this.pageScope))}buildHeaderClone(t,e){if(!this.currentHeaderHtml)return null;const o=document.createElement("div");o.className="co-doc-editor__header-static",o.style.height=this.headerHeight+"px";const i=document.createElement("div");if(i.className="co-doc-editor__header-html",i.innerHTML=this.sanitizedHeaderHtml,o.appendChild(i),this.currentShowPageNumber){const i=document.createElement("span");i.className="co-doc-editor__page-number",i.textContent=`${this.s.page} ${t} / ${e}`,o.appendChild(i)}return o}updateScale(){var t,e,o,i;if("custom"!==this.zoomMode){const o="actual"===this.zoomMode?1:function(t,e){return t>0&&e>0?Math.round(1e3*Math.min(1,Math.max(.25,t/e)))/1e3:1}((null!==(e=null===(t=this.canvasEl)||void 0===t?void 0:t.clientWidth)&&void 0!==e?e:0)-32,this.pageSizePx.width);o!==this.scale&&(this.scale=o)}const s=null!==(i=null===(o=this.stageEl)||void 0===o?void 0:o.offsetHeight)&&void 0!==i?i:0;s!==this.stageHeight&&(this.stageHeight=s)}zoomTo(t,e,o){if(this.canvasEl&&this.stageEl&&t!==this.scale){if(this.pendingAnchor)this.pendingAnchor.cx=e,this.pendingAnchor.cy=o;else{const t=this.stageEl.getBoundingClientRect();this.pendingAnchor={px:G(e,t.left,this.renderedScale),py:G(o,t.top,this.renderedScale),cx:e,cy:o}}this.zoomMode="custom",this.scale=t}}applyPendingAnchor(){const t=this.pendingAnchor,e=this.canvasEl;if(this.renderedScale=this.scale,!t||!e||!this.stageEl)return;this.pendingAnchor=void 0;const o=this.stageEl.getBoundingClientRect();e.scrollLeft+=T(o.left,t.px,this.scale,t.cx),e.scrollTop+=T(o.top,t.py,this.scale,t.cy)}setZoom(t){this.zoomMode=t,this.updateScale()}renderHeaderBand(){const t=this.s;return r("div",{key:"header-band",class:{"co-doc-editor__header-band":!0,"co-doc-editor__header-band--editing":this.headerEditing},part:"header-band",hidden:!this.hasHeader,ref:t=>this.headerBandEl=t,onDblClick:()=>this.startHeaderEdit()},this.headerEditing?r("div",{key:"header-editing",class:"co-doc-editor__header-editing"},r("div",{class:"co-doc-editor__header-editor",ref:t=>this.headerMountEl=t}),r("div",{class:"co-doc-editor__header-tools"},r("co-switch",{checked:this.draftShowPageNumber,label:t.pageNumber,disabled:!1,required:!1,status:"default",onCoChange:t=>{t.stopPropagation(),this.draftShowPageNumber=!!t.detail}}),r("co-tooltip",{content:t.confirmHeader},r("co-icon-button",{icon:"check",variant:"ghost",size:"xs",boxSize:28,iconSize:16,label:t.confirmHeader,onClick:()=>this.commitHeader(!0)})))):r("div",{key:"header-static",class:"co-doc-editor__header-static"},r("div",{class:"co-doc-editor__header-html",innerHTML:this.sanitizedHeaderHtml}),this.currentShowPageNumber&&r("span",{class:"co-doc-editor__page-number"},`${t.page} 1 / ${this.pageCount}`)))}renderOverlays(){const t=this.imageBar;return!t||this.readonly||this.headerEditing?null:r("div",{key:"image-bar",class:"co-doc-editor__image-bar",role:"toolbar","aria-label":this.s.imageLayoutLabel,style:{top:t.top+"px",left:t.left+"px"},onMouseDown:t=>t.preventDefault()},H.map((e=>{const o=this.imageModeLabel(e),i=t.mode===e;return r("co-tooltip",{key:e,content:o},r("button",{type:"button",class:{"co-doc-editor__image-mode":!0,"co-doc-editor__image-mode--active":i},"data-mode":e,"aria-label":o,"aria-pressed":i+"",onClick:()=>this.setImageMode(e)},r("co-icon",{name:A[e],size:16,"aria-hidden":"true"})))})))}render(){const t=this.s,e=this.pageSizePx,o=this.marginsPx,i={"--co-doc-page-w":e.width+"px","--co-doc-page-h":e.height+"px","--co-doc-margin-top":o.top+"px","--co-doc-margin-right":o.right+"px","--co-doc-margin-bottom":o.bottom+"px","--co-doc-margin-left":o.left+"px","--co-doc-header-h":(this.hasHeader?this.headerHeight:0)+"px","--co-doc-pages":this.pageCount+"","--co-doc-gap":S+"px"},s={width:e.width*this.scale+"px",height:this.stageHeight?this.stageHeight*this.scale+"px":"auto"},c=(t,e)=>r("button",{key:"da1c68e89c973899e18720d3cf25b861d158f7c1",type:"button",class:{"co-doc-editor__zoom-btn":!0,"co-doc-editor__zoom-btn--active":this.zoomMode===t},"aria-pressed":(this.zoomMode===t)+"",onClick:()=>this.setZoom(t)},e);return r(a,{key:"254d9df102441f867dc46eb71039df92d99ad102"},r("div",{key:"29723bbee5dd3eae004c6df4c330e8589388636d",class:{"co-doc-editor":!0,"co-doc-editor--readonly":this.readonly,"co-doc-editor--loading":!this.ready},part:"wrapper"},r("div",{key:"9257d370d8547f08402fbaaed2d4a6aa30d94e70",class:"co-doc-editor__bar",part:"bar"},!this.readonly&&r("co-rich-text-toolbar",{key:"8fff97e80464889cb0e6e60d8d9f69308f987e9f",class:"co-doc-editor__toolbar",part:"toolbar",variant:"document",position:"top",disabled:!1,locale:this.locale,attachmentsEnabled:!1,documentHeaderEnabled:this.documentHeaderEnabled,extraItems:this.parsedExtraItems,onCoAction:this.handleToolbarAction,ref:t=>this.toolbarEl=t}),r("div",{key:"00ff09c93887815f84bbb9c68e9485fd64c3c0b6",class:"co-doc-editor__zoom",role:"group","aria-label":t.zoom},"custom"===this.zoomMode&&r("span",{key:"956f0fa4e803a0e27fa32a28116d1e397a2dc402",class:"co-doc-editor__zoom-level"},Math.round(100*this.scale)+" %"),c("fit",t.zoomFit),c("actual",t.zoomActual))),r("div",{key:"4a44bc41d6a641a5f4543422bd7263f2bd962f99",class:"co-doc-editor__body"},r("div",{key:"467491e684b9487d507861d54c37b06b752216f4",class:"co-doc-editor__canvas",part:"canvas",ref:t=>this.canvasEl=t},r("div",{key:"66653efbda8e0dffb7bc1fdb07d0be31b4f5c8a9",class:"co-doc-editor__zoom-frame",style:s},r("div",{key:"06407fc5177c21f4edc60b900a17a8c44ef193ab",class:"co-doc-editor__stage",style:{transform:`scale(${this.scale})`},ref:t=>this.stageEl=t},r("div",{key:"440f1ced158d76650618bc0f153c3201503550a1",class:"co-doc-editor__sheet",part:"sheet","data-co-doc":this.instanceId,style:i},r("style",{key:"page-styles","data-co-doc-page-styles":"",ref:t=>this.styleEl=t}),r("div",{key:"paper",class:"co-doc-editor__paper","data-theme":"light"},this.renderHeaderBand(),r("div",{key:"content",class:"co-doc-editor__content",ref:t=>this.contentEl=t}),this.renderOverlays()))))),r("slot",{key:"1478889436471ed2707db4e361d878faf7c56f2e",name:"aside"}))))}get el(){return this}static get watchers(){return{value:[{onValueChange:0}],readonly:[{onReadonlyChange:0}],pageSize:[{onPageGeometryChange:0}],margins:[{onPageGeometryChange:0}],headerHeight:[{onPageGeometryChange:0}],headerHtml:[{onHeaderPropsChange:0}],showPageNumber:[{onHeaderPropsChange:0}],pageStyles:[{onPageStylesChange:0}],label:[{onLabelChange:0}],locale:[{onLabelChange:0},{onLocaleChange:0}]}}static get style(){return"co-document-editor{display:block;height:100%;min-height:0}.co-doc-editor{--co-doc-canvas:var(--co-semantic-surface-muted);--co-doc-sheet-shadow:0 1px 3px var(--co-color-opacity-negro-16), 0 0 0 1px var(--co-color-opacity-negro-8);display:flex;flex-direction:column;height:100%;min-height:0;background:var(--co-doc-canvas);color:var(--co-semantic-text-default);font-family:var(--co-font-family-primary)}.co-doc-editor__bar{display:flex;align-items:center;gap:var(--co-spacing-sm2);min-width:0;padding-inline:var(--co-spacing-md);background:var(--co-semantic-surface-page);border-bottom:1px solid var(--co-semantic-border-subtle)}.co-doc-editor__toolbar{flex:1 1 auto;min-width:0}.co-doc-editor__body{flex:1 1 auto;display:flex;min-height:0}.co-doc-editor__body>[slot='aside']{flex:0 0 var(--co-doc-aside-width, 320px);width:var(--co-doc-aside-width, 320px);min-width:0;min-height:0;box-sizing:border-box;border-left:1px solid var(--co-semantic-border-subtle)}.co-doc-editor__canvas{flex:1 1 auto;min-width:0;overflow:auto;box-sizing:border-box;padding:var(--co-spacing-2xl) var(--co-spacing-lg)}.co-doc-editor__content .ProseMirror{position:relative;outline:none}.co-doc-editor--loading .co-doc-editor__content{visibility:hidden}.co-doc-field{--co-doc-field-bg:var(--co-color-primary-amarillo);background:var(--co-doc-field-bg);box-shadow:0 0 0 2px var(--co-doc-field-bg);border-radius:var(--co-border-radius-xxs);color:var(--co-color-base-negro);cursor:pointer}.co-doc-field--empty{--co-doc-field-bg:color-mix(in srgb, var(--co-color-primary-amarillo) 55%, var(--co-color-base-blanco))}.co-doc-field--required.co-doc-field--empty{box-shadow:0 0 0 2px var(--co-doc-field-bg), inset 0 -2px 0 var(--co-color-status-error)}.co-doc-field__input{width:14ch;border:0;outline:1px solid var(--co-semantic-border-focus);background:var(--co-color-base-blanco);font:inherit}.co-doc-signature{display:inline-flex;align-items:center;justify-content:center;vertical-align:top;box-sizing:border-box;outline:1px dashed var(--co-color-primary-azul);outline-offset:-1px;background:color-mix(in srgb, var(--co-color-primary-azul) 6%, transparent);color:var(--co-color-primary-azul);font-size:var(--co-font-size-12);user-select:none}.co-doc-hb{background:color-mix(in srgb, var(--co-color-primary-azul) 12%, transparent);border-radius:var(--co-border-radius-xxs)}.co-doc-editor__zoom{display:inline-flex;flex-shrink:0;align-items:center;gap:var(--co-spacing-xxs);margin-inline-start:auto}.co-doc-editor__zoom-level{min-width:5ch;padding-inline:var(--co-spacing-xs);font-size:var(--co-font-size-13);font-variant-numeric:tabular-nums;text-align:end;color:var(--co-semantic-text-secondary)}.co-doc-editor__zoom-btn{padding:var(--co-spacing-xs) var(--co-spacing-sm2);border:0;border-radius:var(--co-border-radius-xs);background:transparent;color:var(--co-semantic-text-secondary);font:inherit;font-size:var(--co-font-size-13);white-space:nowrap;cursor:pointer}.co-doc-editor__zoom-btn:hover{background:var(--co-semantic-surface-hover)}.co-doc-editor__zoom-btn--active{background:var(--co-semantic-surface-hover);color:var(--co-semantic-text-default)}.co-doc-editor__zoom-btn:focus-visible{outline:1px solid var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-doc-editor__zoom-frame{margin-inline:auto}.co-doc-editor__stage{width:var(--co-doc-page-w);transform-origin:top left}.co-doc-editor__sheet{--co-semantic-surface-page:var(--co-color-base-blanco);--co-semantic-surface-hover:var(--co-color-opacity-negro-8);--co-semantic-text-default:var(--co-color-base-negro);--co-semantic-text-secondary:var(--co-color-gray-600);--co-semantic-text-muted:var(--co-color-gray-500);--co-semantic-border-default:var(--co-color-opacity-negro-16);--co-semantic-border-subtle:var(--co-color-opacity-negro-8);--co-semantic-border-field:var(--co-color-opacity-negro-25);--co-semantic-border-focus:var(--co-color-opacity-negro-50);--co-semantic-border-focus-ring:var(--co-color-opacity-negro-8);position:relative;width:var(--co-doc-page-w);min-height:calc(var(--co-doc-pages, 1) * var(--co-doc-page-h) + (var(--co-doc-pages, 1) - 1) * var(--co-doc-gap));box-sizing:border-box;padding-top:calc(var(--co-doc-margin-top) + var(--co-doc-header-h, 0px));padding-right:var(--co-doc-margin-right);padding-bottom:var(--co-doc-margin-bottom);padding-left:var(--co-doc-margin-left);overflow:clip;background:var(--co-color-base-blanco);color:var(--co-color-base-negro);color-scheme:light;box-shadow:var(--co-doc-sheet-shadow)}.co-doc-editor__paper{display:contents;color:var(--co-semantic-text-default)}.co-doc-editor .co-doc-editor__sheet .co-doc-editor__content .ProseMirror.tiptap{padding:0 !important;min-height:1em}.co-doc-editor__header-band{position:absolute;top:var(--co-doc-margin-top);left:var(--co-doc-margin-left);right:var(--co-doc-margin-right);height:var(--co-doc-header-h);box-sizing:border-box}.co-doc-editor__header-band[hidden]{display:none}.co-doc-editor__header-band:hover{outline:1px dashed var(--co-color-opacity-negro-25)}.co-doc-editor__header-static{display:flex;align-items:center;justify-content:space-between;height:100%;overflow:hidden;font-size:var(--co-font-size-12);line-height:1.5;user-select:none}.co-doc-editor__header-html{flex:1 1 auto;min-width:0;max-height:100%;overflow:hidden}.co-doc-editor__page-number{flex-shrink:0;margin-inline-start:var(--co-spacing-sm2);white-space:nowrap;color:var(--co-color-gray-600)}.co-doc-page-gap,.co-doc-page-gap__foot,.co-doc-page-gap__between,.co-doc-page-gap__head{margin:0 !important;padding:0 !important;border-width:0 !important;box-sizing:border-box !important}.co-doc-editor__sheet .co-doc-page-gap{position:relative;margin-left:calc(-1 * var(--co-doc-margin-left)) !important;margin-right:calc(-1 * var(--co-doc-margin-right)) !important;user-select:none}.co-doc-page-gap__between{background:var(--co-doc-canvas);border-image:linear-gradient(var(--co-doc-canvas), var(--co-doc-canvas)) fill 0 / 0 / 0 100vmax;box-shadow:inset 0 1px 0 var(--co-color-opacity-negro-8), inset 0 4px 3px -3px var(--co-color-opacity-negro-16), inset 0 -1px 0 var(--co-color-opacity-negro-8)}:is(ul,ol)>.co-doc-page-gap{list-style:none}.co-doc-editor__sheet .co-doc-page-gap__head{padding-top:var(--co-doc-margin-top) !important;padding-left:var(--co-doc-margin-left) !important;padding-right:var(--co-doc-margin-right) !important}.co-doc-page-gap-row>td{padding:0 !important;border:0 !important;background:transparent !important}.co-doc-editor__header-band--editing,.co-doc-editor__header-band--editing:hover{outline:1px solid var(--co-semantic-border-focus);outline-offset:2px}.co-doc-editor__header-editing{display:flex;align-items:center;gap:var(--co-spacing-sm2);height:100%}.co-doc-editor__header-editor{flex:1 1 auto;min-width:0;max-height:100%;overflow:hidden;font-size:var(--co-font-size-12);line-height:1.5}.co-doc-editor__header-editor .ProseMirror{outline:none}.co-doc-editor__header-tools{position:absolute;right:0;bottom:100%;display:flex;align-items:center;gap:var(--co-spacing-xs);padding:var(--co-spacing-xxs) var(--co-spacing-xs);box-sizing:border-box;background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs)}.co-doc-editor__image-bar{position:absolute;z-index:2;display:flex;gap:var(--co-spacing-xxs);padding:var(--co-spacing-xxs);box-sizing:border-box;background:var(--co-semantic-surface-page);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);user-select:none}.co-doc-editor__image-bar co-tooltip{display:inline-flex}.co-doc-editor__image-mode{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--co-border-radius-xxs);background:transparent;color:var(--co-semantic-text-default);cursor:pointer}.co-doc-editor__image-mode:hover,.co-doc-editor__image-mode--active{background:var(--co-semantic-surface-hover)}.co-doc-editor__image-mode--active{box-shadow:inset 0 0 0 1px var(--co-semantic-border-focus)}.co-doc-editor__image-mode:focus-visible{outline:1px solid var(--co-semantic-border-focus);box-shadow:0 0 0 2px var(--co-semantic-border-focus-ring)}.co-doc-editor__image-mode--active:focus-visible{box-shadow:inset 0 0 0 1px var(--co-semantic-border-focus), 0 0 0 2px var(--co-semantic-border-focus-ring)}"}},[260,"co-document-editor",{value:[1],headerHtml:[1,"header-html"],showPageNumber:[8,"show-page-number"],pageSize:[1,"page-size"],margins:[1],headerHeight:[2,"header-height"],pageStyles:[1,"page-styles"],features:[1],imageUpload:[16],readonly:[4],locale:[1],extraItems:[1,"extra-items"],label:[1],ready:[32],pageCount:[32],zoomMode:[32],scale:[32],stageHeight:[32],headerEditing:[32],draftShowPageNumber:[32],imageBar:[32],getPrintHtml:[64],getHeaderHtml:[64],getJSON:[64],flushChange:[64],isEmpty:[64],setContent:[64],setFieldValues:[64],insertField:[64],insertSignatureSlot:[64],focusEditor:[64],getEditorInstance:[64]},void 0,{value:[{onValueChange:0}],readonly:[{onReadonlyChange:0}],pageSize:[{onPageGeometryChange:0}],margins:[{onPageGeometryChange:0}],headerHeight:[{onPageGeometryChange:0}],headerHtml:[{onHeaderPropsChange:0}],showPageNumber:[{onHeaderPropsChange:0}],pageStyles:[{onPageStylesChange:0}],label:[{onLabelChange:0}],locale:[{onLabelChange:0},{onLocaleChange:0}]}]);function q(){"undefined"!=typeof customElements&&["co-document-editor","co-icon","co-icon-button","co-kbd","co-rich-text-toolbar","co-switch","co-tooltip"].forEach((e=>{switch(e){case"co-document-editor":customElements.get(t(e))||customElements.define(t(e),D);break;case"co-icon":customElements.get(t(e))||l();break;case"co-icon-button":customElements.get(t(e))||g();break;case"co-kbd":customElements.get(t(e))||u();break;case"co-rich-text-toolbar":customElements.get(t(e))||c();break;case"co-switch":customElements.get(t(e))||p();break;case"co-tooltip":customElements.get(t(e))||m()}}))}q();const K=D,U=q;export{K as CoDocumentEditor,U as defineCustomElement}
@@ -1 +1 @@
1
- import{C as o,d as p}from"./p-zJ3pjFzW.js";const s=o,r=p;export{s as CoDrawer,r as defineCustomElement}
1
+ import{C as o,d as s}from"./p-DB8DGMc-.js";const p=o,r=s;export{p as CoDrawer,r as defineCustomElement}
@@ -1 +1 @@
1
- import{t as o,p as a,H as t,c as e,h as i}from"./index.js";import{d as r,a as s}from"./p-nrwDl_gx.js";import{s as n}from"./p-CBX_oabB.js";import{d as c}from"./p-KK2vAKs-.js";function d(o,a,t){const e=Math.min(a,0),i=Math.max(t,0);return Math.min(Math.max(o,e),i)}const l=a(class extends t{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.coClose=e(this,"coClose",7),this.coAfterClose=e(this,"coAfterClose",3),this.coAfterOpen=e(this,"coAfterOpen",3),this.open=!1,this.heading="",this.closable=!0,this.closeOnOverlay=!0,this.closeOnEscape=!1,this.size="md",this.noDividers=!1,this.headerDivider=!0,this.appearance="default",this.backdrop="default",this.inline=!1,this.movable=!1,this.hasFooter=!1,this.handleFooterSlotChange=o=>{this.hasFooter=n(o)},this.handleOverlayClick=()=>{this.closeOnOverlay&&this.coClose.emit()},this.handleCloseClick=()=>{this.coClose.emit()},this.stopPropagation=o=>{o.stopPropagation()},this.handleTransitionEnd=o=>{if(o.target!==this.modalEl)return;const a=s(o.propertyName,this.open,"transform");"after-open"===a?this.coAfterOpen.emit():"after-close"===a&&this.coAfterClose.emit()},this.dragging=!1,this.committedOffset={x:0,y:0},this.liveOffset={x:0,y:0},this.handleDragDown=o=>{var a;if(!this.movable||this.dragging||0!==o.button)return;if(function(o,a){const t="function"==typeof o.composedPath?o.composedPath():[o.target];for(const o of t){if(a&&o===a)return!1;if(o&&"function"==typeof o.matches&&o.matches('button, a[href], input, select, textarea, [role="button"], [role="checkbox"], [role="radio"], [role="switch"], [role="combobox"], [role="option"], [role="menuitem"], [role="slider"], [role="tab"], [role="separator"], [data-no-drag]'))return!0}return!1}(o,this.headerEl))return;const t=null===(a=this.modalEl)||void 0===a?void 0:a.getBoundingClientRect();t&&(o.preventDefault(),this.dragging=!0,this.dragPointerId=o.pointerId,this.dragStart={x:o.clientX,y:o.clientY},this.dragRect={left:t.left-this.committedOffset.x,top:t.top-this.committedOffset.y,width:t.width,height:t.height},this.dragViewport={width:window.innerWidth,height:window.innerHeight},this.capturePointer(o),window.addEventListener("blur",this.handleWindowBlur))},this.handleDragMove=o=>{if(!this.isActiveDragPointer(o))return;if(!this.dragStart||!this.dragRect||!this.dragViewport)return;const a=function(o,a,t){return{x:o.x+t.x-a.x,y:o.y+t.y-a.y}}(this.committedOffset,this.dragStart,{x:o.clientX,y:o.clientY});this.writeOffset(function(o,a,t,e=48){const i=Math.min(e,a.width),r=Math.min(e,a.height);return{x:d(o.x,i-a.left-a.width,t.width-i-a.left),y:d(o.y,-a.top,t.height-r-a.top)}}(a,this.dragRect,this.dragViewport))},this.handleDragUp=o=>{this.isActiveDragPointer(o)&&(this.committedOffset=this.liveOffset,this.releasePointer(o),this.endDrag())},this.handleDragCancel=o=>{this.isActiveDragPointer(o)&&(this.releasePointer(o),this.writeOffset(this.committedOffset),this.endDrag())},this.handleWindowBlur=()=>{this.dragging&&(this.writeOffset(this.committedOffset),this.endDrag())}}get usesOverlay(){return"none"!==this.backdrop&&!this.inline}handleKeydown(o){this.open&&this.closeOnEscape&&"Escape"===o.key&&this.coClose.emit()}resetPositionOnOpen(o){this.endDrag(),o&&(this.committedOffset={x:0,y:0},this.writeOffset({x:0,y:0}))}disconnectedCallback(){window.removeEventListener("blur",this.handleWindowBlur)}endDrag(){window.removeEventListener("blur",this.handleWindowBlur),this.dragging=!1,this.dragPointerId=void 0,this.dragStart=void 0,this.dragRect=void 0,this.dragViewport=void 0}isActiveDragPointer(o){return this.dragging&&o.pointerId==this.dragPointerId}capturePointer(o){const a=this.headerEl;if(a&&"function"==typeof a.setPointerCapture&&null!=o.pointerId)try{a.setPointerCapture(o.pointerId)}catch(o){}}releasePointer(o){const a=this.headerEl;if(a&&"function"==typeof a.releasePointerCapture&&null!=o.pointerId)try{a.releasePointerCapture(o.pointerId)}catch(o){}}writeOffset(o){this.liveOffset=o;const a=this.modalEl;a&&(0===o.x&&0===o.y?a.style.removeProperty("--co-modal-translate"):a.style.setProperty("--co-modal-translate",`${o.x}px ${o.y}px`))}render(){const o="panel"!==this.appearance&&"dialog"!==this.appearance,a=o?20:18,t=i("div",{class:{"co-modal__frame":!0,"co-sq-elevation-fallback":o,"co-modal__frame--standalone":!this.usesOverlay}},i("div",{class:{"co-modal":!0,"co-sq-clip":o,"co-sq-elevation":o,"co-modal--open":this.open,"co-modal--xs":"xs"===this.size,"co-modal--sm":"sm"===this.size,"co-modal--lg":"lg"===this.size,"co-modal--full":"full"===this.size,"co-modal--no-dividers":this.noDividers,"co-modal--no-header-divider":!this.headerDivider,"co-modal--panel":"panel"===this.appearance,"co-modal--dialog":"dialog"===this.appearance,"co-modal--movable":this.movable},part:"modal",ref:o=>this.modalEl=o,role:"dialog","aria-modal":"true","aria-labelledby":this.heading?"modal-heading":void 0,onClick:this.usesOverlay?this.stopPropagation:void 0,onTransitionEnd:this.handleTransitionEnd},i("div",{class:{"co-modal__header":!0,"co-modal__header--movable":this.movable,"co-modal__header--dragging":this.dragging},part:"header",ref:o=>this.headerEl=o,onPointerDown:this.movable?this.handleDragDown:void 0,onPointerMove:this.movable?this.handleDragMove:void 0,onPointerUp:this.movable?this.handleDragUp:void 0,onPointerCancel:this.movable?this.handleDragCancel:void 0},i("slot",{name:"header-leading"}),i("div",{class:"co-modal__header-text",part:"header-text"},i("h2",{class:"co-modal__heading",part:"heading",id:"modal-heading"},this.heading),this.description&&i("p",{class:"co-modal__description",part:"description"},this.description)),i("slot",{name:"header-actions"}),this.closable&&i("button",{class:"co-modal__close",type:"button","aria-label":"Close",onClick:this.handleCloseClick},i("co-icon",{name:"x",size:a}))),!this.noDividers&&i("div",{class:"co-modal__body",part:"body"},i("slot",null)),i("div",{class:{"co-modal__footer":!0,"co-modal__footer--empty":!this.hasFooter},part:"footer"},i("slot",{name:"footer",onSlotchange:this.handleFooterSlotChange}))));return this.usesOverlay?i("co-overlay",{open:this.open,onCoClose:this.handleOverlayClick},t):t}static get watchers(){return{open:[{resetPositionOnOpen:0}]}}static get style(){return'.co-sq-elevation{border-radius:var(--co-sq-r);corner-shape:squircle;box-shadow:var(--co-sq-shadow)}.co-sq-clip{overflow:hidden;border-radius:var(--co-sq-r);corner-shape:squircle}@supports not (corner-shape: squircle){.co-sq-elevation{box-shadow:none}.co-sq-elevation-fallback{filter:var(--co-sq-drop-shadow)}.co-sq-clip{border-radius:0;--co-sq-tl:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M100 0L97.5 0L95 0L92.5 0L90 0L87.5 0.01L85 0.01L82.5 0.02L80 0.04L77.5 0.06L75 0.1L72.5 0.14L70 0.2L67.5 0.28L65 0.38L62.5 0.5L60 0.65L57.5 0.83L55 1.04L52.5 1.3L50 1.6L47.5 1.96L45 2.37L42.5 2.85L40 3.41L37.5 4.05L35 4.8L32.5 5.65L30 6.63L27.5 7.77L25 9.07L22.5 10.58L20 12.34L17.5 14.41L15 16.85L12.5 19.79L10 23.42L7.5 28.06L5 34.37L2.5 44.29L0 100L100 100Z%27 fill=%27%23fff%27/></svg>");--co-sq-tr:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M0 0L2.5 0L5 0L7.5 0L10 0L12.5 0.01L15 0.01L17.5 0.02L20 0.04L22.5 0.06L25 0.1L27.5 0.14L30 0.2L32.5 0.28L35 0.38L37.5 0.5L40 0.65L42.5 0.83L45 1.04L47.5 1.3L50 1.6L52.5 1.96L55 2.37L57.5 2.85L60 3.41L62.5 4.05L65 4.8L67.5 5.65L70 6.63L72.5 7.77L75 9.07L77.5 10.58L80 12.34L82.5 14.41L85 16.85L87.5 19.79L90 23.42L92.5 28.06L95 34.37L97.5 44.29L100 100L0 100Z%27 fill=%27%23fff%27/></svg>");--co-sq-bl:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M0 0L2.5 55.71L5 65.63L7.5 71.94L10 76.58L12.5 80.21L15 83.15L17.5 85.59L20 87.66L22.5 89.42L25 90.93L27.5 92.23L30 93.37L32.5 94.35L35 95.2L37.5 95.95L40 96.59L42.5 97.15L45 97.63L47.5 98.04L50 98.4L52.5 98.7L55 98.96L57.5 99.17L60 99.35L62.5 99.5L65 99.62L67.5 99.72L70 99.8L72.5 99.86L75 99.9L77.5 99.94L80 99.96L82.5 99.98L85 99.99L87.5 99.99L90 100L92.5 100L95 100L97.5 100L100 100L100 0Z%27 fill=%27%23fff%27/></svg>");--co-sq-br:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M100 0L97.5 55.71L95 65.63L92.5 71.94L90 76.58L87.5 80.21L85 83.15L82.5 85.59L80 87.66L77.5 89.42L75 90.93L72.5 92.23L70 93.37L67.5 94.35L65 95.2L62.5 95.95L60 96.59L57.5 97.15L55 97.63L52.5 98.04L50 98.4L47.5 98.7L45 98.96L42.5 99.17L40 99.35L37.5 99.5L35 99.62L32.5 99.72L30 99.8L27.5 99.86L25 99.9L22.5 99.94L20 99.96L17.5 99.98L15 99.99L12.5 99.99L10 100L7.5 100L5 100L2.5 100L0 100L0 0Z%27 fill=%27%23fff%27/></svg>");-webkit-mask:var(--co-sq-tl) top left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-tr) top right / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-bl) bottom left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-br) bottom right / var(--co-sq-r) var(--co-sq-r) no-repeat, linear-gradient(#fff 0 0) center / 100% calc(100% - 2 * var(--co-sq-r) + 2px) no-repeat, linear-gradient(#fff 0 0) center / calc(100% - 2 * var(--co-sq-r) + 2px) 100% no-repeat;mask:var(--co-sq-tl) top left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-tr) top right / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-bl) bottom left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-br) bottom right / var(--co-sq-r) var(--co-sq-r) no-repeat, linear-gradient(#fff 0 0) center / 100% calc(100% - 2 * var(--co-sq-r) + 2px) no-repeat, linear-gradient(#fff 0 0) center / calc(100% - 2 * var(--co-sq-r) + 2px) 100% no-repeat}}:host{display:contents;--co-overlay-blur:8px;--co-overlay-bg:rgba(31, 28, 27, 0.35)}.co-modal__frame{display:flex;contain:layout;--co-sq-drop-shadow:drop-shadow(0 1px 2px rgba(31, 28, 27, 0.06)) drop-shadow(0 14px 34px rgba(31, 28, 27, 0.16))}.co-modal{display:flex;flex-direction:column;background:var(--co-semantic-surface-secondary);--co-modal-r:var(--co-border-radius-xl);--co-sq-r:var(--co-modal-r);--co-sq-shadow:0 1px 4px rgba(31, 28, 27, 0.06), 0 14px 68px rgba(31, 28, 27, 0.16);max-width:540px;width:90vw;max-height:80vh;font-family:var(--co-font-family-primary);transform:scale(0.96);opacity:0;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-in), opacity var(--co-motion-duration-fast) var(--co-motion-ease-in)}.co-modal--sm{max-width:400px}.co-modal--lg{max-width:680px}.co-modal--full{max-width:min(1400px, 95vw);width:95vw;height:92vh;max-height:92vh}.co-modal--full .co-modal__body{flex:1;min-height:0;padding:0;overflow:hidden}.co-modal--open{transform:scale(1);opacity:1;transition:transform var(--co-motion-duration-base) var(--co-motion-ease-out), opacity var(--co-motion-duration-base) var(--co-motion-ease-out)}.co-modal__header{display:flex;align-items:flex-start;gap:var(--co-spacing-md);padding:var(--co-spacing-xl) var(--co-spacing-xl) var(--co-spacing-md)}.co-modal__header-text{display:flex;flex-direction:column;gap:var(--co-spacing-sm);flex:1}.co-modal__heading{margin:0;font-size:var(--co-font-size-20);font-weight:700;color:var(--co-semantic-text-default);line-height:1.3}.co-modal__description{margin:0;font-size:var(--co-font-size-14);color:var(--co-semantic-text-secondary);line-height:1.5}.co-modal__close{display:flex;align-items:center;justify-content:center;padding:var(--co-spacing-xs);margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);border-radius:var(--co-border-radius-sm);flex-shrink:0;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-modal__close:hover{background:var(--co-semantic-surface-hover)}.co-modal__body{padding:var(--co-spacing-lg) var(--co-spacing-xl);overflow-y:auto;overscroll-behavior:contain;font-size:var(--co-font-size-14);color:var(--co-semantic-text-secondary);line-height:1.6;border-top:1px solid var(--co-semantic-border-default)}.co-modal__body:empty{display:none}.co-modal__footer{display:flex;justify-content:flex-end;gap:var(--co-spacing-md);padding:var(--co-spacing-lg) var(--co-spacing-xl) var(--co-spacing-xl);border-top:1px solid var(--co-semantic-border-default);--co-button-radius:var(--co-border-radius-xs)}.co-modal__footer--empty{display:none}.co-modal--no-dividers .co-modal__footer{border-top:none}.co-modal--no-header-divider .co-modal__body{border-top:none;padding-top:0}.co-modal--xs{width:var(--co-modal-width, 369px);max-width:var(--co-modal-width, 369px)}.co-modal--panel{border-radius:var(--co-border-radius-sm);border:1px solid var(--co-semantic-border-subtle);box-shadow:var(--co-shadow-lg)}.co-modal--panel .co-modal__header{padding:16px 20px 16px 24px;align-items:center;border-bottom:1px solid var(--co-semantic-border-subtle)}.co-modal--panel .co-modal__heading{font-size:var(--co-font-size-20);font-weight:500;line-height:1.25;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--panel .co-modal__close{width:32px;height:32px;padding:0;border-radius:var(--co-border-radius-full);color:var(--co-semantic-text-default)}.co-modal--panel .co-modal__body{padding:24px;border-top:none}.co-modal--panel .co-modal__footer{padding:12px 24px;gap:12px;border-top:1px solid var(--co-semantic-border-subtle)}.co-modal__frame--standalone{position:fixed;inset:0;z-index:var(--co-modal-z-index, 1000);display:flex;align-items:center;justify-content:center;pointer-events:none}.co-modal__frame--standalone .co-modal--open{pointer-events:auto}.co-modal__frame--standalone .co-modal:not(.co-modal--open){visibility:hidden;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-in), opacity var(--co-motion-duration-fast) var(--co-motion-ease-in), visibility 0s linear var(--co-motion-duration-fast)}.co-modal--dialog{border-radius:var(--co-border-radius-lg)}.co-modal--dialog .co-modal__header{padding:var(--co-spacing-3xl) var(--co-spacing-3xl) 0;align-items:flex-start;gap:var(--co-spacing-lg)}.co-modal--dialog .co-modal__header-text{gap:var(--co-spacing-lg)}.co-modal--dialog .co-modal__heading{font-size:var(--co-font-size-22);font-weight:500;line-height:1.25;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog .co-modal__description{font-size:var(--co-font-size-16);line-height:1.5;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog .co-modal__close{width:32px;height:32px;padding:0;margin:-3px -6px 0 0;border-radius:var(--co-border-radius-full);color:var(--co-semantic-text-default)}.co-modal--dialog .co-modal__body{padding:var(--co-spacing-lg) var(--co-spacing-3xl) var(--co-spacing-3xl);border-top:none;font-size:var(--co-font-size-16);line-height:1.5;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog.co-modal--full .co-modal__body{padding:0}.co-modal--dialog .co-modal__footer{padding:var(--co-spacing-lg) var(--co-spacing-2xl);gap:var(--co-spacing-md);border-top-color:var(--co-semantic-border-subtle);--co-button-radius:var(--co-border-radius-sm)}.co-modal--movable{translate:var(--co-modal-translate, none)}.co-modal__header--movable{cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}.co-modal__header--movable .co-modal__close{cursor:pointer}.co-modal__header--dragging{cursor:grabbing}'}},[257,"co-modal",{open:[1540],heading:[1],description:[1],closable:[4],closeOnOverlay:[4,"close-on-overlay"],closeOnEscape:[4,"close-on-escape"],size:[513],noDividers:[516,"no-dividers"],headerDivider:[4,"header-divider"],appearance:[513],backdrop:[513],inline:[516],movable:[516],hasFooter:[32],dragging:[32]},[[4,"keydown","handleKeydown"]],{open:[{resetPositionOnOpen:0}]}]);function h(){"undefined"!=typeof customElements&&["co-modal","co-icon","co-overlay"].forEach((a=>{switch(a){case"co-modal":customElements.get(o(a))||customElements.define(o(a),l);break;case"co-icon":customElements.get(o(a))||c();break;case"co-overlay":customElements.get(o(a))||r()}}))}h();const p=l,m=h;export{p as CoModal,m as defineCustomElement}
1
+ import{t as o,p as a,H as t,c as e,h as i}from"./index.js";import{d as r,a as s}from"./p-wUXcJGdy.js";import{s as n}from"./p-CBX_oabB.js";import{d as c}from"./p-KK2vAKs-.js";function d(o,a,t){const e=Math.min(a,0),i=Math.max(t,0);return Math.min(Math.max(o,e),i)}const l=a(class extends t{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.coClose=e(this,"coClose",7),this.coAfterClose=e(this,"coAfterClose",3),this.coAfterOpen=e(this,"coAfterOpen",3),this.open=!1,this.heading="",this.closable=!0,this.closeOnOverlay=!0,this.closeOnEscape=!1,this.size="md",this.noDividers=!1,this.headerDivider=!0,this.appearance="default",this.backdrop="default",this.inline=!1,this.movable=!1,this.trapFocus=!1,this.hasFooter=!1,this.handleFooterSlotChange=o=>{this.hasFooter=n(o)},this.handleOverlayClick=()=>{this.closeOnOverlay&&this.coClose.emit()},this.handleCloseClick=()=>{this.coClose.emit()},this.stopPropagation=o=>{o.stopPropagation()},this.handleTransitionEnd=o=>{if(o.target!==this.modalEl)return;const a=s(o.propertyName,this.open,"transform");"after-open"===a?this.coAfterOpen.emit():"after-close"===a&&this.coAfterClose.emit()},this.dragging=!1,this.committedOffset={x:0,y:0},this.liveOffset={x:0,y:0},this.handleDragDown=o=>{var a;if(!this.movable||this.dragging||0!==o.button)return;if(function(o,a){const t="function"==typeof o.composedPath?o.composedPath():[o.target];for(const o of t){if(a&&o===a)return!1;if(o&&"function"==typeof o.matches&&o.matches('button, a[href], input, select, textarea, [role="button"], [role="checkbox"], [role="radio"], [role="switch"], [role="combobox"], [role="option"], [role="menuitem"], [role="slider"], [role="tab"], [role="separator"], [data-no-drag]'))return!0}return!1}(o,this.headerEl))return;const t=null===(a=this.modalEl)||void 0===a?void 0:a.getBoundingClientRect();t&&(o.preventDefault(),this.dragging=!0,this.dragPointerId=o.pointerId,this.dragStart={x:o.clientX,y:o.clientY},this.dragRect={left:t.left-this.committedOffset.x,top:t.top-this.committedOffset.y,width:t.width,height:t.height},this.dragViewport={width:window.innerWidth,height:window.innerHeight},this.capturePointer(o),window.addEventListener("blur",this.handleWindowBlur))},this.handleDragMove=o=>{if(!this.isActiveDragPointer(o))return;if(!this.dragStart||!this.dragRect||!this.dragViewport)return;const a=function(o,a,t){return{x:o.x+t.x-a.x,y:o.y+t.y-a.y}}(this.committedOffset,this.dragStart,{x:o.clientX,y:o.clientY});this.writeOffset(function(o,a,t,e=48){const i=Math.min(e,a.width),r=Math.min(e,a.height);return{x:d(o.x,i-a.left-a.width,t.width-i-a.left),y:d(o.y,-a.top,t.height-r-a.top)}}(a,this.dragRect,this.dragViewport))},this.handleDragUp=o=>{this.isActiveDragPointer(o)&&(this.committedOffset=this.liveOffset,this.releasePointer(o),this.endDrag())},this.handleDragCancel=o=>{this.isActiveDragPointer(o)&&(this.releasePointer(o),this.writeOffset(this.committedOffset),this.endDrag())},this.handleWindowBlur=()=>{this.dragging&&(this.writeOffset(this.committedOffset),this.endDrag())}}get usesOverlay(){return"none"!==this.backdrop&&!this.inline}handleKeydown(o){this.open&&this.closeOnEscape&&"Escape"===o.key&&this.coClose.emit()}async bringToFront(){var o,a,t;await(null===(t=null===(a=null===(o=this.el.shadowRoot)||void 0===o?void 0:o.querySelector("co-overlay"))||void 0===a?void 0:a.bringToFront)||void 0===t?void 0:t.call(a))}resetPositionOnOpen(o){this.endDrag(),o&&(this.committedOffset={x:0,y:0},this.writeOffset({x:0,y:0}))}disconnectedCallback(){window.removeEventListener("blur",this.handleWindowBlur)}endDrag(){window.removeEventListener("blur",this.handleWindowBlur),this.dragging=!1,this.dragPointerId=void 0,this.dragStart=void 0,this.dragRect=void 0,this.dragViewport=void 0}isActiveDragPointer(o){return this.dragging&&o.pointerId==this.dragPointerId}capturePointer(o){const a=this.headerEl;if(a&&"function"==typeof a.setPointerCapture&&null!=o.pointerId)try{a.setPointerCapture(o.pointerId)}catch(o){}}releasePointer(o){const a=this.headerEl;if(a&&"function"==typeof a.releasePointerCapture&&null!=o.pointerId)try{a.releasePointerCapture(o.pointerId)}catch(o){}}writeOffset(o){this.liveOffset=o;const a=this.modalEl;a&&(0===o.x&&0===o.y?a.style.removeProperty("--co-modal-translate"):a.style.setProperty("--co-modal-translate",`${o.x}px ${o.y}px`))}render(){const o="panel"!==this.appearance&&"dialog"!==this.appearance,a=o?20:18,t=i("div",{class:{"co-modal__frame":!0,"co-sq-elevation-fallback":o,"co-modal__frame--standalone":!this.usesOverlay}},i("div",{class:{"co-modal":!0,"co-sq-clip":o,"co-sq-elevation":o,"co-modal--open":this.open,"co-modal--xs":"xs"===this.size,"co-modal--sm":"sm"===this.size,"co-modal--lg":"lg"===this.size,"co-modal--full":"full"===this.size,"co-modal--no-dividers":this.noDividers,"co-modal--no-header-divider":!this.headerDivider,"co-modal--panel":"panel"===this.appearance,"co-modal--dialog":"dialog"===this.appearance,"co-modal--movable":this.movable},part:"modal",ref:o=>this.modalEl=o,role:"dialog","aria-modal":"true","aria-labelledby":this.heading?"modal-heading":void 0,onClick:this.usesOverlay?this.stopPropagation:void 0,onTransitionEnd:this.handleTransitionEnd},i("div",{class:{"co-modal__header":!0,"co-modal__header--movable":this.movable,"co-modal__header--dragging":this.dragging},part:"header",ref:o=>this.headerEl=o,onPointerDown:this.movable?this.handleDragDown:void 0,onPointerMove:this.movable?this.handleDragMove:void 0,onPointerUp:this.movable?this.handleDragUp:void 0,onPointerCancel:this.movable?this.handleDragCancel:void 0},i("slot",{name:"header-leading"}),i("div",{class:"co-modal__header-text",part:"header-text"},i("h2",{class:"co-modal__heading",part:"heading",id:"modal-heading"},this.heading),this.description&&i("p",{class:"co-modal__description",part:"description"},this.description)),i("slot",{name:"header-actions"}),this.closable&&i("button",{class:"co-modal__close",type:"button","aria-label":"Close",onClick:this.handleCloseClick},i("co-icon",{name:"x",size:a}))),!this.noDividers&&i("div",{class:"co-modal__body",part:"body"},i("slot",null)),i("div",{class:{"co-modal__footer":!0,"co-modal__footer--empty":!this.hasFooter},part:"footer"},i("slot",{name:"footer",onSlotchange:this.handleFooterSlotChange}))));return this.usesOverlay?i("co-overlay",{open:this.open,trapFocus:this.trapFocus,onCoClose:this.handleOverlayClick},t):t}get el(){return this}static get watchers(){return{open:[{resetPositionOnOpen:0}]}}static get style(){return'.co-sq-elevation{border-radius:var(--co-sq-r);corner-shape:squircle;box-shadow:var(--co-sq-shadow)}.co-sq-clip{overflow:hidden;border-radius:var(--co-sq-r);corner-shape:squircle}@supports not (corner-shape: squircle){.co-sq-elevation{box-shadow:none}.co-sq-elevation-fallback{filter:var(--co-sq-drop-shadow)}.co-sq-clip{border-radius:0;--co-sq-tl:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M100 0L97.5 0L95 0L92.5 0L90 0L87.5 0.01L85 0.01L82.5 0.02L80 0.04L77.5 0.06L75 0.1L72.5 0.14L70 0.2L67.5 0.28L65 0.38L62.5 0.5L60 0.65L57.5 0.83L55 1.04L52.5 1.3L50 1.6L47.5 1.96L45 2.37L42.5 2.85L40 3.41L37.5 4.05L35 4.8L32.5 5.65L30 6.63L27.5 7.77L25 9.07L22.5 10.58L20 12.34L17.5 14.41L15 16.85L12.5 19.79L10 23.42L7.5 28.06L5 34.37L2.5 44.29L0 100L100 100Z%27 fill=%27%23fff%27/></svg>");--co-sq-tr:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M0 0L2.5 0L5 0L7.5 0L10 0L12.5 0.01L15 0.01L17.5 0.02L20 0.04L22.5 0.06L25 0.1L27.5 0.14L30 0.2L32.5 0.28L35 0.38L37.5 0.5L40 0.65L42.5 0.83L45 1.04L47.5 1.3L50 1.6L52.5 1.96L55 2.37L57.5 2.85L60 3.41L62.5 4.05L65 4.8L67.5 5.65L70 6.63L72.5 7.77L75 9.07L77.5 10.58L80 12.34L82.5 14.41L85 16.85L87.5 19.79L90 23.42L92.5 28.06L95 34.37L97.5 44.29L100 100L0 100Z%27 fill=%27%23fff%27/></svg>");--co-sq-bl:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M0 0L2.5 55.71L5 65.63L7.5 71.94L10 76.58L12.5 80.21L15 83.15L17.5 85.59L20 87.66L22.5 89.42L25 90.93L27.5 92.23L30 93.37L32.5 94.35L35 95.2L37.5 95.95L40 96.59L42.5 97.15L45 97.63L47.5 98.04L50 98.4L52.5 98.7L55 98.96L57.5 99.17L60 99.35L62.5 99.5L65 99.62L67.5 99.72L70 99.8L72.5 99.86L75 99.9L77.5 99.94L80 99.96L82.5 99.98L85 99.99L87.5 99.99L90 100L92.5 100L95 100L97.5 100L100 100L100 0Z%27 fill=%27%23fff%27/></svg>");--co-sq-br:url("data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 100 100%27 preserveAspectRatio=%27none%27><path d=%27M100 0L97.5 55.71L95 65.63L92.5 71.94L90 76.58L87.5 80.21L85 83.15L82.5 85.59L80 87.66L77.5 89.42L75 90.93L72.5 92.23L70 93.37L67.5 94.35L65 95.2L62.5 95.95L60 96.59L57.5 97.15L55 97.63L52.5 98.04L50 98.4L47.5 98.7L45 98.96L42.5 99.17L40 99.35L37.5 99.5L35 99.62L32.5 99.72L30 99.8L27.5 99.86L25 99.9L22.5 99.94L20 99.96L17.5 99.98L15 99.99L12.5 99.99L10 100L7.5 100L5 100L2.5 100L0 100L0 0Z%27 fill=%27%23fff%27/></svg>");-webkit-mask:var(--co-sq-tl) top left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-tr) top right / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-bl) bottom left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-br) bottom right / var(--co-sq-r) var(--co-sq-r) no-repeat, linear-gradient(#fff 0 0) center / 100% calc(100% - 2 * var(--co-sq-r) + 2px) no-repeat, linear-gradient(#fff 0 0) center / calc(100% - 2 * var(--co-sq-r) + 2px) 100% no-repeat;mask:var(--co-sq-tl) top left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-tr) top right / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-bl) bottom left / var(--co-sq-r) var(--co-sq-r) no-repeat, var(--co-sq-br) bottom right / var(--co-sq-r) var(--co-sq-r) no-repeat, linear-gradient(#fff 0 0) center / 100% calc(100% - 2 * var(--co-sq-r) + 2px) no-repeat, linear-gradient(#fff 0 0) center / calc(100% - 2 * var(--co-sq-r) + 2px) 100% no-repeat}}:host{display:contents;--co-overlay-blur:8px;--co-overlay-bg:rgba(31, 28, 27, 0.35)}.co-modal__frame{display:flex;contain:layout;--co-sq-drop-shadow:drop-shadow(0 1px 2px rgba(31, 28, 27, 0.06)) drop-shadow(0 14px 34px rgba(31, 28, 27, 0.16))}.co-modal{display:flex;flex-direction:column;background:var(--co-semantic-surface-secondary);--co-modal-r:var(--co-border-radius-xl);--co-sq-r:var(--co-modal-r);--co-sq-shadow:0 1px 4px rgba(31, 28, 27, 0.06), 0 14px 68px rgba(31, 28, 27, 0.16);max-width:540px;width:90vw;max-height:80vh;font-family:var(--co-font-family-primary);transform:scale(0.96);opacity:0;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-in), opacity var(--co-motion-duration-fast) var(--co-motion-ease-in)}.co-modal--sm{max-width:400px}.co-modal--lg{max-width:680px}.co-modal--full{max-width:min(1400px, 95vw);width:95vw;height:92vh;max-height:92vh}.co-modal--full .co-modal__body{flex:1;min-height:0;padding:0;overflow:hidden}.co-modal--open{transform:scale(1);opacity:1;transition:transform var(--co-motion-duration-base) var(--co-motion-ease-out), opacity var(--co-motion-duration-base) var(--co-motion-ease-out)}.co-modal__header{display:flex;align-items:flex-start;gap:var(--co-spacing-md);padding:var(--co-spacing-xl) var(--co-spacing-xl) var(--co-spacing-md)}.co-modal__header-text{display:flex;flex-direction:column;gap:var(--co-spacing-sm);flex:1}.co-modal__heading{margin:0;font-size:var(--co-font-size-20);font-weight:700;color:var(--co-semantic-text-default);line-height:1.3}.co-modal__description{margin:0;font-size:var(--co-font-size-14);color:var(--co-semantic-text-secondary);line-height:1.5}.co-modal__close{display:flex;align-items:center;justify-content:center;padding:var(--co-spacing-xs);margin:0;border:none;background:transparent;cursor:pointer;color:var(--co-semantic-text-muted);border-radius:var(--co-border-radius-sm);flex-shrink:0;transition:background var(--co-motion-duration-fast) var(--co-motion-ease-out)}.co-modal__close:hover{background:var(--co-semantic-surface-hover)}.co-modal__body{padding:var(--co-spacing-lg) var(--co-spacing-xl);overflow-y:auto;overscroll-behavior:contain;font-size:var(--co-font-size-14);color:var(--co-semantic-text-secondary);line-height:1.6;border-top:1px solid var(--co-semantic-border-default)}.co-modal__body:empty{display:none}.co-modal__footer{display:flex;justify-content:flex-end;gap:var(--co-spacing-md);padding:var(--co-spacing-lg) var(--co-spacing-xl) var(--co-spacing-xl);border-top:1px solid var(--co-semantic-border-default);--co-button-radius:var(--co-border-radius-xs)}.co-modal__footer--empty{display:none}.co-modal--no-dividers .co-modal__footer{border-top:none}.co-modal--no-header-divider .co-modal__body{border-top:none;padding-top:0}.co-modal--xs{width:var(--co-modal-width, 369px);max-width:var(--co-modal-width, 369px)}.co-modal--panel{border-radius:var(--co-border-radius-sm);border:1px solid var(--co-semantic-border-subtle);box-shadow:var(--co-shadow-lg)}.co-modal--panel .co-modal__header{padding:16px 20px 16px 24px;align-items:center;border-bottom:1px solid var(--co-semantic-border-subtle)}.co-modal--panel .co-modal__heading{font-size:var(--co-font-size-20);font-weight:500;line-height:1.25;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--panel .co-modal__close{width:32px;height:32px;padding:0;border-radius:var(--co-border-radius-full);color:var(--co-semantic-text-default)}.co-modal--panel .co-modal__body{padding:24px;border-top:none}.co-modal--panel .co-modal__footer{padding:12px 24px;gap:12px;border-top:1px solid var(--co-semantic-border-subtle)}.co-modal__frame--standalone{position:fixed;inset:0;z-index:var(--co-modal-z-index, 1000);display:flex;align-items:center;justify-content:center;pointer-events:none}.co-modal__frame--standalone .co-modal--open{pointer-events:auto}.co-modal__frame--standalone .co-modal:not(.co-modal--open){visibility:hidden;transition:transform var(--co-motion-duration-fast) var(--co-motion-ease-in), opacity var(--co-motion-duration-fast) var(--co-motion-ease-in), visibility 0s linear var(--co-motion-duration-fast)}.co-modal--dialog{border-radius:var(--co-border-radius-lg)}.co-modal--dialog .co-modal__header{padding:var(--co-spacing-3xl) var(--co-spacing-3xl) 0;align-items:flex-start;gap:var(--co-spacing-lg)}.co-modal--dialog .co-modal__header-text{gap:var(--co-spacing-lg)}.co-modal--dialog .co-modal__heading{font-size:var(--co-font-size-22);font-weight:500;line-height:1.25;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog .co-modal__description{font-size:var(--co-font-size-16);line-height:1.5;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog .co-modal__close{width:32px;height:32px;padding:0;margin:-3px -6px 0 0;border-radius:var(--co-border-radius-full);color:var(--co-semantic-text-default)}.co-modal--dialog .co-modal__body{padding:var(--co-spacing-lg) var(--co-spacing-3xl) var(--co-spacing-3xl);border-top:none;font-size:var(--co-font-size-16);line-height:1.5;letter-spacing:var(--co-font-letter-spacing-body)}.co-modal--dialog.co-modal--full .co-modal__body{padding:0}.co-modal--dialog .co-modal__footer{padding:var(--co-spacing-lg) var(--co-spacing-2xl);gap:var(--co-spacing-md);border-top-color:var(--co-semantic-border-subtle);--co-button-radius:var(--co-border-radius-sm)}.co-modal--movable{translate:var(--co-modal-translate, none)}.co-modal__header--movable{cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}.co-modal__header--movable .co-modal__close{cursor:pointer}.co-modal__header--dragging{cursor:grabbing}'}},[257,"co-modal",{open:[1540],heading:[1],description:[1],closable:[4],closeOnOverlay:[4,"close-on-overlay"],closeOnEscape:[4,"close-on-escape"],size:[513],noDividers:[516,"no-dividers"],headerDivider:[4,"header-divider"],appearance:[513],backdrop:[513],inline:[516],movable:[516],trapFocus:[516,"trap-focus"],hasFooter:[32],dragging:[32],bringToFront:[64]},[[4,"keydown","handleKeydown"]],{open:[{resetPositionOnOpen:0}]}]);function h(){"undefined"!=typeof customElements&&["co-modal","co-icon","co-overlay"].forEach((a=>{switch(a){case"co-modal":customElements.get(o(a))||customElements.define(o(a),l);break;case"co-icon":customElements.get(o(a))||c();break;case"co-overlay":customElements.get(o(a))||r()}}))}h();const p=l,m=h;export{p as CoModal,m as defineCustomElement}
@@ -1 +1 @@
1
- import{C as o,d as r}from"./p-nrwDl_gx.js";const s=o,p=r;export{s as CoOverlay,p as defineCustomElement}
1
+ import{C as o,d as s}from"./p-wUXcJGdy.js";const p=o,r=s;export{p as CoOverlay,r as defineCustomElement}