@streamline-pulse/formkrafter-wc 0.4.0 → 0.5.1

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 (66) hide show
  1. package/README.md +14 -2
  2. package/dist/components/fk-brick-actions.js +1 -1
  3. package/dist/components/fk-brick-list.js +1 -1
  4. package/dist/components/fk-brick-mold-item.js +1 -1
  5. package/dist/components/fk-brick-render.js +1 -1
  6. package/dist/components/fk-code-editor.js +1 -1
  7. package/dist/components/fk-data-grid.js +1 -1
  8. package/dist/components/fk-drop-area.js +1 -1
  9. package/dist/components/fk-empty-form.js +1 -1
  10. package/dist/components/fk-file-input.js +1 -1
  11. package/dist/components/fk-form-builder.js +1 -1
  12. package/dist/components/fk-form-render.js +1 -1
  13. package/dist/components/fk-property-panel.js +1 -1
  14. package/dist/components/fk-rules-editor.js +1 -1
  15. package/dist/components/fk-select-input.js +1 -1
  16. package/dist/components/fk-signature-input.js +1 -1
  17. package/dist/components/fk-stepper.js +1 -1
  18. package/dist/components/fk-tabs.js +1 -1
  19. package/dist/components/index.js +1 -1
  20. package/dist/components/{p-C0Y8qh8R.js → p-BJ7u_t3N.js} +1 -1
  21. package/dist/components/p-BKT368_B.js +1 -0
  22. package/dist/components/p-BQIUKz-H.js +1 -0
  23. package/dist/components/p-BYhtwUM4.js +12 -0
  24. package/dist/components/{p-BInUBjyw.js → p-BerMKKKo.js} +1 -1
  25. package/dist/components/{p-CqVSd56Z.js → p-BnxDCFjv.js} +1 -1
  26. package/dist/components/{p-CKs1CWVz.js → p-C3SjLyf4.js} +1 -1
  27. package/dist/{formkrafter-wc/p-BietHxaT.js → components/p-CAilSzZp.js} +1 -1
  28. package/dist/components/{p-tTJg_I4V.js → p-CKAZ15-B.js} +1 -1
  29. package/dist/components/p-COkZvRcY.js +1 -0
  30. package/dist/components/{p-CZHykCYD.js → p-CV2J_nG8.js} +1 -1
  31. package/dist/components/{p-Dh5Z49YD.js → p-C_8wUoZ4.js} +1 -1
  32. package/dist/components/p-CfLRuUU4.js +1 -0
  33. package/dist/components/p-Cg-VvkW4.js +1 -0
  34. package/dist/components/{p-DshUS8Zm.js → p-CsHWN99R.js} +1 -1
  35. package/dist/{formkrafter-wc/p-DlqnIm46.js → components/p-DOTbu58d.js} +1 -1
  36. package/dist/components/{p-BGxmFcpL.js → p-DQKpUpzo.js} +1 -1
  37. package/dist/components/{p-D4HhZxQ-.js → p-DtO4LFLi.js} +1 -1
  38. package/dist/components/{p-kYG3E0GQ.js → p-DyI9tTC9.js} +1 -1
  39. package/dist/{formkrafter-wc/p-CehxuHtl.js → components/p-_JpQ28sq.js} +1 -1
  40. package/dist/components/p-bZPtT8wr.js +1 -0
  41. package/dist/components/{p-BpkKcCCr.js → p-dFTWRHWl.js} +1 -1
  42. package/dist/components/{p-BnzSarwW.js → p-hELMtJ9v.js} +1 -1
  43. package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
  44. package/dist/formkrafter-wc/index.esm.js +1 -1
  45. package/dist/formkrafter-wc/{p-8b0ff66e.entry.js → p-954e842c.entry.js} +1 -1
  46. package/dist/formkrafter-wc/{p-C0Y8qh8R.js → p-BJ7u_t3N.js} +1 -1
  47. package/dist/formkrafter-wc/{p-WWmY5Z05.js → p-BjBiz89q.js} +1 -1
  48. package/dist/{components/p-BietHxaT.js → formkrafter-wc/p-CAilSzZp.js} +1 -1
  49. package/dist/formkrafter-wc/p-CfLRuUU4.js +1 -0
  50. package/dist/{components/p-DlqnIm46.js → formkrafter-wc/p-DOTbu58d.js} +1 -1
  51. package/dist/formkrafter-wc/p-DYsf28oe.js +1 -0
  52. package/dist/formkrafter-wc/p-DvzB4zo1.js +12 -0
  53. package/dist/{components/p-CehxuHtl.js → formkrafter-wc/p-_JpQ28sq.js} +1 -1
  54. package/dist/formkrafter-wc/{p-3579150a.entry.js → p-ca200eec.entry.js} +1 -1
  55. package/dist/types/components/fk-select-input/fk-select-input.d.ts +5 -1
  56. package/package.json +8 -6
  57. package/dist/components/p-28GBFlUX.js +0 -12
  58. package/dist/components/p-C5OWoRhO.js +0 -1
  59. package/dist/components/p-DC6Wxbnz.js +0 -1
  60. package/dist/components/p-DRNycSdI.js +0 -1
  61. package/dist/components/p-DiOstAi9.js +0 -1
  62. package/dist/components/p-RzeBwfwG.js +0 -1
  63. package/dist/components/p-ajy8ZcBX.js +0 -1
  64. package/dist/formkrafter-wc/p-BHZMDq2e.js +0 -1
  65. package/dist/formkrafter-wc/p-RzeBwfwG.js +0 -1
  66. package/dist/formkrafter-wc/p-hcT25XX4.js +0 -12
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @streamline-pulse/formkrafter-wc
2
2
 
3
- The FormKrafter UI as **Stencil Web Components**: a drag & drop builder, a form renderer, and 27 built-in bricks. Framework wrappers ([React](../react/README.md), [Vue](../vue/README.md)) are generated from this package.
3
+ The FormKrafter UI as **Stencil Web Components**: a drag & drop builder, a form renderer, and 30 built-in bricks. Framework wrappers ([React](../react/README.md), [Vue](../vue/README.md)) are generated from this package.
4
4
 
5
5
  ```html
6
6
  <script type="module" src=".../formkrafter-wc.esm.js"></script>
@@ -59,7 +59,7 @@ Underscore-prefixed keys injected via the `data` prop (e.g. `_authToken`) are av
59
59
 
60
60
  Notable behaviors:
61
61
 
62
- - **select / multi-select** — searchable combobox (full WAI-ARIA pattern, keyboard navigation); options from `static`, `dataMap`, `remote` (URL + headers with `{key}` interpolation, optional server-side search param, cached) or `js` (sandboxed); `labelKey`/`valueKey` accept dotted paths (`name.common`).
62
+ - **select / multi-select** — searchable combobox (full WAI-ARIA pattern, keyboard navigation); options from `static`, `dataMap`, `remote` (URL + headers with `{key}` interpolation, optional server-side search param, cached), `js` (sandboxed) or `catalog` (`optionsRef` resolved through `services.optionSourceService` — store a big list once, reference it everywhere); `labelKey`/`valueKey` accept dotted paths (`name.common`). Static options accept a plain newline string when label = value.
63
63
  - **data-grid** — the row template is edited like any panel; at render time each row scopes its own data; `minItems`/`maxItems` validate row counts; rows reorder with accessible up/down buttons; `validate()` reports `contacts[0].email` style keys.
64
64
  - **stepper** — per-step validation gate, optional step-click jumping, optional Submit button emitting `formSubmit`. **tabs** — optional "validate tab before leaving", arrow-key navigation.
65
65
  - **text / phone** — optional `prefix`/`suffix` adornments and a `mask` config (`9` digit, `a` letter, `A` uppercase, `*` alphanumeric; literals auto-inserted).
@@ -90,6 +90,18 @@ registerBrick(createBrick({
90
90
 
91
91
  > The brick registry, the chrome translations, and core `services` are **page-wide singletons** (shared through `globalThis`, see the [core README](../core/README.md#shared-singleton-state)) — register bricks or override services once at app startup and every FormKrafter instance sees them, regardless of bundling.
92
92
 
93
+ ## Bundle size
94
+
95
+ Measured on v0.5.0 — bundled from `dist/components` with `bun build --minify`, sizes before/after gzip:
96
+
97
+ | What you ship | Minified | Gzipped |
98
+ |---|---|---|
99
+ | Builder — includes the renderer and all 30 bricks | ~675 KB | **~215 KB** |
100
+ | Renderer only | ~632 KB | **~205 KB** |
101
+ | `styles.css` (the only stylesheet — and it's optional) | 6 KB | ~1 KB |
102
+
103
+ The code editor (CodeMirror, ~243 KB minified) is **lazy-loaded**: it never ships in the initial bundle, only when a code or rules editor actually opens. No CSS framework is required — no Bootstrap, no reset, nothing global.
104
+
93
105
  ## Theming
94
106
 
95
107
  All styling flows through CSS custom properties — override them anywhere in the cascade:
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-BInUBjyw.js";const p=o,r=s;export{p as FkBrickActions,r as defineCustomElement}
1
+ import{F as o,d as r}from"./p-BerMKKKo.js";const s=o,p=r;export{s as FkBrickActions,p as defineCustomElement}
@@ -1 +1 @@
1
- import{F as s,d as o}from"./p-DshUS8Zm.js";const m=s,p=o;export{m as FkBrickList,p as defineCustomElement}
1
+ import{F as s,d as o}from"./p-CsHWN99R.js";const p=s,r=o;export{p as FkBrickList,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-Dh5Z49YD.js";const p=o,r=s;export{p as FkBrickMoldItem,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-C_8wUoZ4.js";const p=o,r=s;export{p as FkBrickMoldItem,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-ajy8ZcBX.js";const a=o,p=s;export{a as FkBrickRender,p as defineCustomElement}
1
+ import{F as o,d as s}from"./p-Cg-VvkW4.js";const p=o,r=s;export{p as FkBrickRender,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-tTJg_I4V.js";const t=o,p=s;export{t as FkCodeEditor,p as defineCustomElement}
1
+ import{F as o,d as s}from"./p-CKAZ15-B.js";const p=o,r=s;export{p as FkCodeEditor,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-kYG3E0GQ.js";const p=o,r=s;export{p as FkDataGrid,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-DyI9tTC9.js";const t=o,p=s;export{t as FkDataGrid,p as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-CqVSd56Z.js";const p=o,r=s;export{p as FkDropArea,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-BnxDCFjv.js";const p=o,r=s;export{p as FkDropArea,r as defineCustomElement}
@@ -1 +1 @@
1
- import{t as e,p as t,H as a,h as r,a as s}from"./p-BB4Llg42.js";import{a as c}from"./p-C5OWoRhO.js";const f=t(class extends a{constructor(e){super(),!1!==e&&this.__registerHost()}render(){return r(s,{key:"a4d0825c084d261dfb8dc99a366a1e3f6e0c862d"},r("div",{key:"3e012165aec178ac8ea8e1211d891aa4d1d42d55",class:"fk-empty"},r("p",{key:"8c99ad57686aadd9d68a52767743ab907ec8e692",class:"fk-empty__title"},c("empty.title")),r("p",{key:"585262991b3497a3fcf430e26d53adc66ae9f74d",class:"fk-empty__hint"},c("empty.hint"))))}static get style(){return".fk-empty.sc-fk-empty-form{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:calc(var(--fk-spacing) / 2);min-height:160px;border:2px dashed var(--fk-color-border);border-radius:var(--fk-radius);color:var(--fk-color-muted);text-align:center}.fk-empty__title.sc-fk-empty-form{margin:0;font-weight:600}.fk-empty__hint.sc-fk-empty-form{margin:0;font-size:0.875rem}"}},[2,"fk-empty-form"]);function m(){"undefined"!=typeof customElements&&["fk-empty-form"].forEach((t=>{"fk-empty-form"===t&&(customElements.get(e(t))||customElements.define(e(t),f))}))}m();const o=f,n=m;export{o as FkEmptyForm,n as defineCustomElement}
1
+ import{t as e,p as t,H as r,h as a,a as s}from"./p-BB4Llg42.js";import{a as c}from"./p-bZPtT8wr.js";const f=t(class extends r{constructor(e){super(),!1!==e&&this.__registerHost()}render(){return a(s,{key:"a4d0825c084d261dfb8dc99a366a1e3f6e0c862d"},a("div",{key:"3e012165aec178ac8ea8e1211d891aa4d1d42d55",class:"fk-empty"},a("p",{key:"8c99ad57686aadd9d68a52767743ab907ec8e692",class:"fk-empty__title"},c("empty.title")),a("p",{key:"585262991b3497a3fcf430e26d53adc66ae9f74d",class:"fk-empty__hint"},c("empty.hint"))))}static get style(){return".fk-empty.sc-fk-empty-form{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:calc(var(--fk-spacing) / 2);min-height:160px;border:2px dashed var(--fk-color-border);border-radius:var(--fk-radius);color:var(--fk-color-muted);text-align:center}.fk-empty__title.sc-fk-empty-form{margin:0;font-weight:600}.fk-empty__hint.sc-fk-empty-form{margin:0;font-size:0.875rem}"}},[2,"fk-empty-form"]);function m(){"undefined"!=typeof customElements&&["fk-empty-form"].forEach((t=>{"fk-empty-form"===t&&(customElements.get(e(t))||customElements.define(e(t),f))}))}m();const o=f,n=m;export{o as FkEmptyForm,n as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as p}from"./p-BGxmFcpL.js";const s=o,m=p;export{s as FkFileInput,m as defineCustomElement}
1
+ import{F as o,d as p}from"./p-DQKpUpzo.js";const s=o,r=p;export{s as FkFileInput,r as defineCustomElement}
@@ -1 +1 @@
1
- import{t as e,p as i,H as s,c as t,h as r}from"./p-BB4Llg42.js";import{S as a,c as o,d as c,m as d,f as l,j as n,u as f,k,l as b,n as h,i as p}from"./p-28GBFlUX.js";import{g as u,n as m}from"./p-gPc0o8Jb.js";import{registerDefaultBricks as v}from"./index.js";import{a as _}from"./p-C5OWoRhO.js";import{d as g}from"./p-BInUBjyw.js";import{d as y}from"./p-DshUS8Zm.js";import{d as C}from"./p-Dh5Z49YD.js";import{d as j}from"./p-NDbmiiYk.js";import{d as x}from"./p-ajy8ZcBX.js";import{d as E}from"./p-tTJg_I4V.js";import{d as w}from"./p-kYG3E0GQ.js";import{d as S}from"./p-CqVSd56Z.js";import{d as D}from"./p-BGxmFcpL.js";import{d as B}from"./p-DRNycSdI.js";import{d as R}from"./p-DC6Wxbnz.js";import{d as O}from"./p-CZHykCYD.js";import{d as U}from"./p-DiOstAi9.js";import{d as J}from"./p-BnzSarwW.js";import{d as z}from"./p-D4HhZxQ-.js";import{d as I}from"./p-CKs1CWVz.js";const L=i(class extends s{constructor(e){super(),!1!==e&&this.__registerHost(),this.specChange=t(this,"specChange"),this.locales=[],this.currentData={},this.copied=!1,this.history=new a,this.importFromClipboard=async()=>{try{const e=await navigator.clipboard.readText();this.importSpec(e,!1)}catch(e){this.flashImportError(_("builder.pasteHint"))}},this.copySpec=async()=>{this.currentSpec&&(await navigator.clipboard.writeText(this.specJson()),this.copied=!0,setTimeout((()=>this.copied=!1),1500))},this.downloadSpec=()=>{if(!this.currentSpec)return;const e=new Blob([this.specJson()],{type:"application/json"}),i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download="form-spec.json",s.click(),URL.revokeObjectURL(i)},this.undo=()=>{if(!this.currentSpec)return;const e=this.history.undo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))},this.redo=()=>{if(!this.currentSpec)return;const e=this.history.redo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))}}componentWillLoad(){0===u().length&&v(),this.editLocale=this.locales[0],this.currentSpec=this.spec,this.currentData=Object.assign({},this.data)}syncSpec(e){this.currentSpec=e,this.history.clear()}handleBrickDrop(e){var i,s;e.stopPropagation();const{source:t,mold:r,from:a,parentPath:l,index:n}=e.detail;if("new"===t&&r){const e=m(r.type,r.id);if(!e)return;return this.currentSpec?void this.applyUpdate(o(this.currentSpec,e,l,n)):void this.setRootSpec("panel"===e.type?e:this.wrapInRootGroup(e))}if("move"===t&&a&&this.currentSpec){if(l===a||l.startsWith(a+"."))return;const e=c(this.currentSpec,l);if(!e)return;const t=null!==(s=null===(i=e.children)||void 0===i?void 0:i.length)&&void 0!==s?s:0,r=a.split("."),o=r.slice(0,-1).join("."),f=Number(r[r.length-1]),k=null!=n?n:t;if(o===l&&(k===f||k===f+1))return;this.applyUpdate(d(this.currentSpec,a,`${l}.${k}`))}}handleBrickRemove(e){e.stopPropagation(),this.currentSpec&&("0"!==e.detail.path?this.applyUpdate(l(this.currentSpec,e.detail.path)):this.setRootSpec(void 0))}handleBrickDuplicate(e){e.stopPropagation(),this.currentSpec&&this.applyUpdate(n(this.currentSpec,e.detail.path))}handleConfigsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(f(this.currentSpec,e.detail.uid,e.detail.configs))}handleStylesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(k(this.currentSpec,e.detail.uid,e.detail.styles))}handleValidationsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(b(this.currentSpec,e.detail.uid,e.detail.validations))}handleRulesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(h(this.currentSpec,e.detail.uid,e.detail.rules))}handleDataChange(e){this.currentData=e.detail.data}handlePaste(e){var i;const s=e.target;(null==s?void 0:s.closest("input, textarea, select, [contenteditable]"))||this.importSpec(null===(i=e.clipboardData)||void 0===i?void 0:i.getData("text/plain"),!0)}importSpec(e,i){if(e)try{const i=JSON.parse(e);if("object"!=typeof i||null===i||"string"!=typeof i.type||"string"!=typeof i.id)throw Error("not a brick spec");this.selectedUid=void 0,this.importError=void 0,this.setRootSpec(this.ensureUids(i))}catch(e){i||this.flashImportError(_("builder.importInvalid"))}else i||this.flashImportError(_("builder.importInvalid"))}ensureUids(e){var i;const s=structuredClone(e);for(const{brick:e}of p(s))(null===(i=e.configs)||void 0===i?void 0:i.uid)||(e.configs=Object.assign(Object.assign({},e.configs),{uid:crypto.randomUUID()}));return s}flashImportError(e){this.importError=e,setTimeout((()=>this.importError=void 0),4e3)}handleBrickSelect(e){var i,s;e.stopPropagation(),this.currentSpec&&(this.selectedUid=null===(s=null===(i=c(this.currentSpec,e.detail.path))||void 0===i?void 0:i.configs)||void 0===s?void 0:s.uid)}findSelected(){var e;if(this.currentSpec&&this.selectedUid)for(const{brick:i,path:s}of p(this.currentSpec))if((null===(e=i.configs)||void 0===e?void 0:e.uid)===this.selectedUid)return{brick:i,path:s}}inputFieldKeys(){var e;const i=[];for(const{brick:s}of p(this.currentSpec)){const t=null===(e=s.configs)||void 0===e?void 0:e.key;"input"===s.type&&t&&i.push(t)}return i}wrapInRootGroup(e){const i=m("panel","column");return i?Object.assign(Object.assign({},i),{name:"Form",children:[e]}):e}setRootSpec(e){this.currentSpec=e,this.history.clear(),this.specChange.emit({spec:e,patches:[],inverse:[]})}applyUpdate(e){this.history.record(e),this.currentSpec=e.spec,this.specChange.emit({spec:e.spec,patches:e.patches,inverse:e.inverse})}specJson(){return JSON.stringify(this.currentSpec,null,2)}render(){return r("div",{key:"0cd1cc1b49cee6b080acefda1b8a822f803ea6db",class:"fk-builder"},r("aside",{key:"b3cf8969f135cd058529e680ce742a53bea07829",class:"fk-builder__palette"},r("fk-brick-list",{key:"ef26831fed5f7e0a0272ad9f98b9d9b58dc7b2d8"})),r("main",{key:"91e989a6b7166b27509bd31aeed04e2f1d304208",class:"fk-builder__main"},r("div",{key:"b5948becfc073f2c5ce3f26b97c97de3ac00aaf4",class:"fk-builder__toolbar"},r("button",{key:"45536cab82889da8a990e537373fbdfea16c01b8",type:"button",class:"fk-builder__tool",disabled:!this.history.canUndo,onClick:this.undo},"↩ ",_("builder.undo")),r("button",{key:"0ac1b8ded7ee584211ede2dde9bb9597d65b7787",type:"button",class:"fk-builder__tool",disabled:!this.history.canRedo,onClick:this.redo},"↪ ",_("builder.redo")),r("span",{key:"48d81bb2eaf8d691ce6e4638a49524e5c9723948",class:"fk-builder__spacer"}),this.locales.length>1?r("select",{class:"fk-builder__tool",onChange:e=>this.editLocale=e.target.value},this.locales.map((e=>r("option",{value:e,selected:e===this.editLocale},e.toUpperCase())))):null,this.importError?r("span",{class:"fk-builder__import-error"},this.importError):null,r("button",{key:"501752b1b9735454fa09a7045b6e7b430da3ab65",type:"button",class:"fk-builder__tool",onClick:this.importFromClipboard},"⤓ ",_("builder.importJson")),r("button",{key:"1866329eff26dbd2b210146d1085ec3a0d1c1df5",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.copySpec},"⧉ ",_(this.copied?"builder.copied":"builder.copyJson")),r("button",{key:"9d7b6f460797d4e081d60191d72efcfeb0a9e4ed",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.downloadSpec},"⬇ ",_("builder.downloadJson"))),r("div",{key:"a484ea5a55d23abeb37e9d361e4da6a5c98e74f6",class:"fk-builder__canvas"},this.currentSpec?r("fk-form-render",{spec:this.currentSpec,data:this.currentData,editable:!0,selectedUid:this.selectedUid,locale:this.editLocale}):r("fk-drop-area",{path:"0",empty:!0}))),r("aside",{key:"63039141a4de82fb2c1afc25b32433d27afe2967",class:"fk-builder__inspector"},(()=>{const e=this.findSelected();return e?r("fk-property-panel",{brick:e.brick,fields:this.inputFieldKeys(),locales:this.locales,editLocale:this.editLocale}):r("p",{class:"fk-builder__hint"},_("builder.hint"))})()))}static get watchers(){return{spec:[{syncSpec:0}]}}static get style(){return".sc-fk-form-builder-h{display:block;container-type:inline-size}.fk-builder.sc-fk-form-builder{display:flex;gap:calc(var(--fk-spacing) * 2);align-items:flex-start;font-family:var(--fk-font);color:var(--fk-color-text)}@container (max-width: 820px){.fk-builder{flex-wrap:wrap}.fk-builder__palette,.fk-builder__inspector{width:100%}.fk-builder__main{order:2;flex-basis:100%}.fk-builder__palette{order:1}.fk-builder__inspector{order:3}}.fk-builder__palette.sc-fk-form-builder{width:220px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__main.sc-fk-form-builder{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-builder__toolbar.sc-fk-form-builder{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2)}.fk-builder__spacer.sc-fk-form-builder{flex:1}.fk-builder__import-error.sc-fk-form-builder{font-size:0.75rem;color:var(--fk-color-danger)}.fk-builder__tool.sc-fk-form-builder{padding:calc(var(--fk-spacing) / 2) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);font-size:0.8rem;cursor:pointer}.fk-builder__tool.sc-fk-form-builder:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-builder__tool.sc-fk-form-builder:disabled{opacity:0.4;cursor:default}.fk-builder__canvas.sc-fk-form-builder{min-height:320px;padding:calc(var(--fk-spacing) * 2);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);overflow-x:auto}.fk-builder__inspector.sc-fk-form-builder{width:260px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__hint.sc-fk-form-builder{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}"}},[2,"fk-form-builder",{spec:[16],data:[16],locales:[16],currentSpec:[32],currentData:[32],selectedUid:[32],copied:[32],importError:[32],editLocale:[32]},[[0,"brickDrop","handleBrickDrop"],[0,"brickRemove","handleBrickRemove"],[0,"brickDuplicate","handleBrickDuplicate"],[0,"brickConfigsChange","handleConfigsChange"],[0,"brickStylesChange","handleStylesChange"],[0,"brickValidationsChange","handleValidationsChange"],[0,"brickRulesChange","handleRulesChange"],[0,"formDataChange","handleDataChange"],[4,"paste","handlePaste"],[0,"brickSelect","handleBrickSelect"]],{spec:[{syncSpec:0}]}]);function V(){"undefined"!=typeof customElements&&["fk-form-builder","fk-brick-actions","fk-brick-list","fk-brick-mold-item","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-file-input","fk-form-render","fk-property-panel","fk-rules-editor","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((i=>{switch(i){case"fk-form-builder":customElements.get(e(i))||customElements.define(e(i),L);break;case"fk-brick-actions":customElements.get(e(i))||g();break;case"fk-brick-list":customElements.get(e(i))||y();break;case"fk-brick-mold-item":customElements.get(e(i))||C();break;case"fk-brick-not-found":customElements.get(e(i))||j();break;case"fk-brick-render":customElements.get(e(i))||x();break;case"fk-code-editor":customElements.get(e(i))||E();break;case"fk-data-grid":customElements.get(e(i))||w();break;case"fk-drop-area":customElements.get(e(i))||S();break;case"fk-file-input":customElements.get(e(i))||D();break;case"fk-form-render":customElements.get(e(i))||B();break;case"fk-property-panel":customElements.get(e(i))||R();break;case"fk-rules-editor":customElements.get(e(i))||O();break;case"fk-select-input":customElements.get(e(i))||U();break;case"fk-signature-input":customElements.get(e(i))||J();break;case"fk-stepper":customElements.get(e(i))||z();break;case"fk-tabs":customElements.get(e(i))||I()}}))}V();const Z=L,G=V;export{Z as FkFormBuilder,G as defineCustomElement}
1
+ import{t as e,p as t,H as i,c as r,h as s}from"./p-BB4Llg42.js";import{S as a,c as o,d as c,m as d,f as l,j as n,u as f,k,l as b,n as p,i as h}from"./p-BYhtwUM4.js";import{g as u,n as m}from"./p-gPc0o8Jb.js";import{registerDefaultBricks as v}from"./index.js";import{a as _}from"./p-bZPtT8wr.js";import{d as g}from"./p-BerMKKKo.js";import{d as y}from"./p-CsHWN99R.js";import{d as C}from"./p-C_8wUoZ4.js";import{d as j}from"./p-NDbmiiYk.js";import{d as x}from"./p-Cg-VvkW4.js";import{d as E}from"./p-CKAZ15-B.js";import{d as w}from"./p-DyI9tTC9.js";import{d as B}from"./p-BnxDCFjv.js";import{d as S}from"./p-DQKpUpzo.js";import{d as D}from"./p-BKT368_B.js";import{d as R}from"./p-COkZvRcY.js";import{d as L}from"./p-CV2J_nG8.js";import{d as U}from"./p-BQIUKz-H.js";import{d as J}from"./p-hELMtJ9v.js";import{d as O}from"./p-DtO4LFLi.js";import{d as K}from"./p-C3SjLyf4.js";const z=t(class extends i{constructor(e){super(),!1!==e&&this.__registerHost(),this.specChange=r(this,"specChange"),this.locales=[],this.currentData={},this.copied=!1,this.history=new a,this.importFromClipboard=async()=>{try{const e=await navigator.clipboard.readText();this.importSpec(e,!1)}catch(e){this.flashImportError(_("builder.pasteHint"))}},this.copySpec=async()=>{this.currentSpec&&(await navigator.clipboard.writeText(this.specJson()),this.copied=!0,setTimeout((()=>this.copied=!1),1500))},this.downloadSpec=()=>{if(!this.currentSpec)return;const e=new Blob([this.specJson()],{type:"application/json"}),t=URL.createObjectURL(e),i=document.createElement("a");i.href=t,i.download="form-spec.json",i.click(),URL.revokeObjectURL(t)},this.undo=()=>{if(!this.currentSpec)return;const e=this.history.undo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))},this.redo=()=>{if(!this.currentSpec)return;const e=this.history.redo(this.currentSpec);void 0!==e&&(this.currentSpec=e,this.specChange.emit({spec:e,patches:[],inverse:[]}))}}componentWillLoad(){0===u().length&&v(),this.editLocale=this.locales[0],this.currentSpec=this.spec,this.currentData=Object.assign({},this.data)}syncSpec(e){this.currentSpec=e,this.history.clear()}handleBrickDrop(e){var t,i;e.stopPropagation();const{source:r,mold:s,from:a,parentPath:l,index:n}=e.detail;if("new"===r&&s){const e=m(s.type,s.id);if(!e)return;return this.currentSpec?void this.applyUpdate(o(this.currentSpec,e,l,n)):void this.setRootSpec("panel"===e.type?e:this.wrapInRootGroup(e))}if("move"===r&&a&&this.currentSpec){if(l===a||l.startsWith(a+"."))return;const e=c(this.currentSpec,l);if(!e)return;const r=null!==(i=null===(t=e.children)||void 0===t?void 0:t.length)&&void 0!==i?i:0,s=a.split("."),o=s.slice(0,-1).join("."),f=Number(s[s.length-1]),k=null!=n?n:r;if(o===l&&(k===f||k===f+1))return;this.applyUpdate(d(this.currentSpec,a,`${l}.${k}`))}}handleBrickRemove(e){e.stopPropagation(),this.currentSpec&&("0"!==e.detail.path?this.applyUpdate(l(this.currentSpec,e.detail.path)):this.setRootSpec(void 0))}handleBrickDuplicate(e){e.stopPropagation(),this.currentSpec&&this.applyUpdate(n(this.currentSpec,e.detail.path))}handleConfigsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(f(this.currentSpec,e.detail.uid,e.detail.configs))}handleStylesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(k(this.currentSpec,e.detail.uid,e.detail.styles))}handleValidationsChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(b(this.currentSpec,e.detail.uid,e.detail.validations))}handleRulesChange(e){e.stopPropagation(),this.currentSpec&&e.detail.uid&&this.applyUpdate(p(this.currentSpec,e.detail.uid,e.detail.rules))}handleDataChange(e){this.currentData=e.detail.data}handlePaste(e){var t;const i=e.target;(null==i?void 0:i.closest("input, textarea, select, [contenteditable]"))||this.importSpec(null===(t=e.clipboardData)||void 0===t?void 0:t.getData("text/plain"),!0)}importSpec(e,t){if(e)try{const t=JSON.parse(e);if("object"!=typeof t||null===t||"string"!=typeof t.type||"string"!=typeof t.id)throw Error("not a brick spec");this.selectedUid=void 0,this.importError=void 0,this.setRootSpec(this.ensureUids(t))}catch(e){t||this.flashImportError(_("builder.importInvalid"))}else t||this.flashImportError(_("builder.importInvalid"))}ensureUids(e){var t;const i=structuredClone(e);for(const{brick:e}of h(i))(null===(t=e.configs)||void 0===t?void 0:t.uid)||(e.configs=Object.assign(Object.assign({},e.configs),{uid:crypto.randomUUID()}));return i}flashImportError(e){this.importError=e,setTimeout((()=>this.importError=void 0),4e3)}handleBrickSelect(e){var t,i;e.stopPropagation(),this.currentSpec&&(this.selectedUid=null===(i=null===(t=c(this.currentSpec,e.detail.path))||void 0===t?void 0:t.configs)||void 0===i?void 0:i.uid)}findSelected(){var e;if(this.currentSpec&&this.selectedUid)for(const{brick:t,path:i}of h(this.currentSpec))if((null===(e=t.configs)||void 0===e?void 0:e.uid)===this.selectedUid)return{brick:t,path:i}}inputFieldKeys(){var e;const t=[];for(const{brick:i}of h(this.currentSpec)){const r=null===(e=i.configs)||void 0===e?void 0:e.key;"input"===i.type&&r&&t.push(r)}return t}wrapInRootGroup(e){const t=m("panel","column");return t?Object.assign(Object.assign({},t),{name:"Form",children:[e]}):e}setRootSpec(e){this.currentSpec=e,this.history.clear(),this.specChange.emit({spec:e,patches:[],inverse:[]})}applyUpdate(e){this.history.record(e),this.currentSpec=e.spec,this.specChange.emit({spec:e.spec,patches:e.patches,inverse:e.inverse})}specJson(){return JSON.stringify(this.currentSpec,null,2)}render(){return s("div",{key:"0cd1cc1b49cee6b080acefda1b8a822f803ea6db",class:"fk-builder"},s("aside",{key:"b3cf8969f135cd058529e680ce742a53bea07829",class:"fk-builder__palette"},s("fk-brick-list",{key:"ef26831fed5f7e0a0272ad9f98b9d9b58dc7b2d8"})),s("main",{key:"91e989a6b7166b27509bd31aeed04e2f1d304208",class:"fk-builder__main"},s("div",{key:"b5948becfc073f2c5ce3f26b97c97de3ac00aaf4",class:"fk-builder__toolbar"},s("button",{key:"45536cab82889da8a990e537373fbdfea16c01b8",type:"button",class:"fk-builder__tool",disabled:!this.history.canUndo,onClick:this.undo},"↩ ",_("builder.undo")),s("button",{key:"0ac1b8ded7ee584211ede2dde9bb9597d65b7787",type:"button",class:"fk-builder__tool",disabled:!this.history.canRedo,onClick:this.redo},"↪ ",_("builder.redo")),s("span",{key:"48d81bb2eaf8d691ce6e4638a49524e5c9723948",class:"fk-builder__spacer"}),this.locales.length>1?s("select",{class:"fk-builder__tool",onChange:e=>this.editLocale=e.target.value},this.locales.map((e=>s("option",{value:e,selected:e===this.editLocale},e.toUpperCase())))):null,this.importError?s("span",{class:"fk-builder__import-error"},this.importError):null,s("button",{key:"501752b1b9735454fa09a7045b6e7b430da3ab65",type:"button",class:"fk-builder__tool",onClick:this.importFromClipboard},"⤓ ",_("builder.importJson")),s("button",{key:"1866329eff26dbd2b210146d1085ec3a0d1c1df5",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.copySpec},"⧉ ",_(this.copied?"builder.copied":"builder.copyJson")),s("button",{key:"9d7b6f460797d4e081d60191d72efcfeb0a9e4ed",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.downloadSpec},"⬇ ",_("builder.downloadJson"))),s("div",{key:"a484ea5a55d23abeb37e9d361e4da6a5c98e74f6",class:"fk-builder__canvas"},this.currentSpec?s("fk-form-render",{spec:this.currentSpec,data:this.currentData,editable:!0,selectedUid:this.selectedUid,locale:this.editLocale}):s("fk-drop-area",{path:"0",empty:!0}))),s("aside",{key:"63039141a4de82fb2c1afc25b32433d27afe2967",class:"fk-builder__inspector"},(()=>{const e=this.findSelected();return e?s("fk-property-panel",{brick:e.brick,fields:this.inputFieldKeys(),locales:this.locales,editLocale:this.editLocale}):s("p",{class:"fk-builder__hint"},_("builder.hint"))})()))}static get watchers(){return{spec:[{syncSpec:0}]}}static get style(){return".sc-fk-form-builder-h{display:block;container-type:inline-size}.fk-builder.sc-fk-form-builder{display:flex;gap:calc(var(--fk-spacing) * 2);align-items:flex-start;font-family:var(--fk-font);color:var(--fk-color-text)}@container (max-width: 820px){.fk-builder{flex-wrap:wrap}.fk-builder__palette,.fk-builder__inspector{width:100%}.fk-builder__main{order:2;flex-basis:100%}.fk-builder__palette{order:1}.fk-builder__inspector{order:3}}.fk-builder__palette.sc-fk-form-builder{width:220px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__main.sc-fk-form-builder{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-builder__toolbar.sc-fk-form-builder{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2)}.fk-builder__spacer.sc-fk-form-builder{flex:1}.fk-builder__import-error.sc-fk-form-builder{font-size:0.75rem;color:var(--fk-color-danger)}.fk-builder__tool.sc-fk-form-builder{padding:calc(var(--fk-spacing) / 2) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);font-size:0.8rem;cursor:pointer}.fk-builder__tool.sc-fk-form-builder:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-builder__tool.sc-fk-form-builder:disabled{opacity:0.4;cursor:default}.fk-builder__canvas.sc-fk-form-builder{min-height:320px;padding:calc(var(--fk-spacing) * 2);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);overflow-x:auto}.fk-builder__inspector.sc-fk-form-builder{width:260px;flex-shrink:0;padding:calc(var(--fk-spacing) * 1.5);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-builder__hint.sc-fk-form-builder{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}"}},[2,"fk-form-builder",{spec:[16],data:[16],locales:[16],currentSpec:[32],currentData:[32],selectedUid:[32],copied:[32],importError:[32],editLocale:[32]},[[0,"brickDrop","handleBrickDrop"],[0,"brickRemove","handleBrickRemove"],[0,"brickDuplicate","handleBrickDuplicate"],[0,"brickConfigsChange","handleConfigsChange"],[0,"brickStylesChange","handleStylesChange"],[0,"brickValidationsChange","handleValidationsChange"],[0,"brickRulesChange","handleRulesChange"],[0,"formDataChange","handleDataChange"],[4,"paste","handlePaste"],[0,"brickSelect","handleBrickSelect"]],{spec:[{syncSpec:0}]}]);function I(){"undefined"!=typeof customElements&&["fk-form-builder","fk-brick-actions","fk-brick-list","fk-brick-mold-item","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-file-input","fk-form-render","fk-property-panel","fk-rules-editor","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((t=>{switch(t){case"fk-form-builder":customElements.get(e(t))||customElements.define(e(t),z);break;case"fk-brick-actions":customElements.get(e(t))||g();break;case"fk-brick-list":customElements.get(e(t))||y();break;case"fk-brick-mold-item":customElements.get(e(t))||C();break;case"fk-brick-not-found":customElements.get(e(t))||j();break;case"fk-brick-render":customElements.get(e(t))||x();break;case"fk-code-editor":customElements.get(e(t))||E();break;case"fk-data-grid":customElements.get(e(t))||w();break;case"fk-drop-area":customElements.get(e(t))||B();break;case"fk-file-input":customElements.get(e(t))||S();break;case"fk-form-render":customElements.get(e(t))||D();break;case"fk-property-panel":customElements.get(e(t))||R();break;case"fk-rules-editor":customElements.get(e(t))||L();break;case"fk-select-input":customElements.get(e(t))||U();break;case"fk-signature-input":customElements.get(e(t))||J();break;case"fk-stepper":customElements.get(e(t))||O();break;case"fk-tabs":customElements.get(e(t))||K()}}))}I();const N=z,P=I;export{N as FkFormBuilder,P as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-DRNycSdI.js";const p=o,r=s;export{p as FkFormRender,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-BKT368_B.js";const p=o,r=s;export{p as FkFormRender,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-DC6Wxbnz.js";const p=o,r=s;export{p as FkPropertyPanel,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-COkZvRcY.js";const p=o,r=s;export{p as FkPropertyPanel,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-CZHykCYD.js";const p=o,r=s;export{p as FkRulesEditor,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-CV2J_nG8.js";const p=o,r=s;export{p as FkRulesEditor,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as s,d as o}from"./p-DiOstAi9.js";const t=s,i=o;export{t as FkSelectInput,i as defineCustomElement}
1
+ import{F as o,d as s}from"./p-BQIUKz-H.js";const p=o,r=s;export{p as FkSelectInput,r as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as r}from"./p-BnzSarwW.js";const s=o,a=r;export{s as FkSignatureInput,a as defineCustomElement}
1
+ import{F as o,d as s}from"./p-hELMtJ9v.js";const t=o,p=s;export{t as FkSignatureInput,p as defineCustomElement}
@@ -1 +1 @@
1
- import{F as o,d as s}from"./p-D4HhZxQ-.js";const p=o,r=s;export{p as FkStepper,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-DtO4LFLi.js";const t=o,p=s;export{t as FkStepper,p as defineCustomElement}
@@ -1 +1 @@
1
- import{F as s,d as o}from"./p-CKs1CWVz.js";const p=s,r=o;export{p as FkTabs,r as defineCustomElement}
1
+ import{F as o,d as s}from"./p-C3SjLyf4.js";const p=o,r=s;export{p as FkTabs,r as defineCustomElement}
@@ -1 +1 @@
1
- import{h as e}from"./p-BB4Llg42.js";export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions}from"./p-BB4Llg42.js";import{r as t}from"./p-gPc0o8Jb.js";export{b as getBrick,g as getBrickMolds,a as getBrickMoldsGroupedByCategory,n as newBrickSpec,c as registerBrick}from"./p-gPc0o8Jb.js";import{B as l,p as i,g as o}from"./p-28GBFlUX.js";import{n as u}from"./p-CyZA17qf.js";import{a as p,f}from"./p-C5OWoRhO.js";export{b as frFkTranslations,s as setFkTranslations}from"./p-C5OWoRhO.js";function v(e){return new class extends l{constructor(){var t;super({type:e.type,dataType:e.dataType,id:e.id,name:e.name,category:e.category,configsForm:e.configsForm,styles:null!==(t=e.styles)&&void 0!==t?t:{},validators:e.validators,unWrapData:e.unWrapData,isPrivate:e.isPrivate,defaultConfigs:e.defaultConfigs})}render(t){return e.render(t)}renderBuilder(t){var a;return(null!==(a=e.renderBuilder)&&void 0!==a?a:e.render)(t)}getComponent(e){return this.render(e)}getComponentWithActions(e){return this.renderBuilder(e)}}}const y=e=>e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));function k(e){const t=Object.entries(null!=e?e:{}).filter((([,e])=>null!=e&&""!==e));if(0===t.length)return;const a={};for(const[e,l]of t)a[y(e)]=l+"";return a}const m=(e,t)=>"9"===e?/\d/.test(t):"a"===e||"A"===e?/[a-zA-Z]/.test(t):/[0-9a-zA-Z]/.test(t),_=e=>"9"===e||"a"===e||"A"===e||"*"===e,h=(e,t)=>{var a,l,n,i;return null!==(i=null!==(l=null===(a=e.configs)||void 0===a?void 0:a.label)&&void 0!==l?l:null===(n=e.configs)||void 0===n?void 0:n.key)&&void 0!==i?i:t},C=(t,a)=>{var l,n;const i=null===(l=t.configs)||void 0===l?void 0:l.prefix,o=null===(n=t.configs)||void 0===n?void 0:n.suffix;return i||o?e("div",{class:"fk-adorned"},i?e("span",{class:"fk-adorned__affix"},i):null,a,o?e("span",{class:"fk-adorned__affix"},o):null):a},T=t=>t.error?e("span",{class:"fk-field__error",role:"alert"},t.error):null,x=e=>e.error?{"aria-invalid":"true"}:{},O=(t,a,l)=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,a)),l,T(t)),j=(t,a,l)=>e("label",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,a)),l,T(t)),S=t=>v({type:"input",dataType:"string",id:t.id,name:t.name,category:"Inputs",defaultConfigs:t.maskable?{label:t.name,mask:""}:{label:t.name},render:a=>{var l,n;return j(a,t.name,C(a,e("input",Object.assign({},x(a),{class:"fk-field__input fk-adorned__input",type:t.inputType,value:null!==(l=a.data)&&void 0!==l?l:"",placeholder:null===(n=a.configs)||void 0===n?void 0:n.placeholder,disabled:a.editable||a.disabled,onInput:e=>{var t,l;const n=e.target,i=null===(t=a.configs)||void 0===t?void 0:t.mask,o=i?((e,t)=>{if(!t)return e;let a="",l=0;for(let n=0;n<t.length&&l<e.length;n++){const i=t[n];if(_(i))for(;l<e.length;){const t=e[l++];if(m(i,t)){a+="A"===i?t.toUpperCase():t;break}}else a+=i,e[l]===i&&l++}return a})(n.value,i):n.value;o!==n.value&&(n.value=o),null===(l=a.onDataChange)||void 0===l||l.call(a,o)}}))))}}),A=S({id:"text",name:"Text",inputType:"text",maskable:!0}),I=S({id:"email",name:"Email",inputType:"email"}),w=S({id:"password",name:"Password",inputType:"password"}),B=S({id:"url",name:"URL",inputType:"url"}),L=S({id:"phone",name:"Phone",inputType:"tel",maskable:!0}),R=v({type:"input",dataType:"string",id:"textarea",name:"Text area",category:"Inputs",defaultConfigs:{label:"Text area"},render:t=>{var a,l;return j(t,"Text area",e("textarea",Object.assign({},x(t),{class:"fk-field__input fk-field__input--textarea",value:null!==(a=t.data)&&void 0!==a?a:"",placeholder:null===(l=t.configs)||void 0===l?void 0:l.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.value)}})))}}),D=v({type:"input",dataType:"number",id:"number",name:"Number",category:"Inputs",defaultConfigs:{label:"Number"},render:t=>{var a;return j(t,"Number",C(t,e("input",Object.assign({},x(t),{class:"fk-field__input fk-adorned__input",type:"number",value:null==t.data?"":t.data+"",placeholder:null===(a=t.configs)||void 0===a?void 0:a.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:Number(l))}}))))}}),N=v({type:"input",dataType:"string",id:"date",name:"Date",category:"Inputs",defaultConfigs:{label:"Date"},render:t=>{var a;return j(t,"Date",e("input",Object.assign({},x(t),{class:"fk-field__input",type:"date",value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:l)}})))}}),F=v({type:"input",dataType:"string",id:"select",name:"Select",category:"Inputs",defaultConfigs:{label:"Select",optionsSource:"static",options:"Option 1\nOption 2"},render:t=>{var a;return O(t,"Select",e("fk-select-input",{configs:t.configs,value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),M=v({type:"input",dataType:"array",id:"multi-select",name:"Multi select",category:"Inputs",defaultConfigs:{label:"Multi select",optionsSource:"static",options:"Option 1\nOption 2\nOption 3"},render:t=>O(t,"Multi select",e("fk-select-input",{configs:t.configs,value:Array.isArray(t.data)?t.data:[],multiple:!0,disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),P=S({id:"time",name:"Time",inputType:"time"}),z=S({id:"datetime",name:"Date / Time",inputType:"datetime-local"}),G=e=>{var t,a,l;return u(null===(t=e.configs)||void 0===t?void 0:t.options,"string"==typeof(null===(a=e.configs)||void 0===a?void 0:a.labelKey)?e.configs.labelKey:"label","string"==typeof(null===(l=e.configs)||void 0===l?void 0:l.valueKey)?e.configs.valueKey:"value")},U=v({type:"input",dataType:"array",id:"select-boxes",name:"Select boxes",category:"Inputs",defaultConfigs:{label:"Select boxes",options:"Option 1\nOption 2\nOption 3"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Select boxes")),e("div",{class:"fk-radio-group"},G(t).map((l=>e("label",{class:"fk-radio",key:l.value},e("input",{type:"checkbox",checked:a.includes(l.value),disabled:t.editable||t.disabled,onChange:e=>{var n;const i=e.target.checked?[...a,l.value]:a.filter((e=>e!==l.value));null===(n=t.onDataChange)||void 0===n||n.call(t,i.length?i:void 0)}}),e("span",null,l.label))))),t.error?e("span",{class:"fk-field__error"},t.error):null)}}),V=v({type:"input",dataType:"array",id:"tags",name:"Tags",category:"Inputs",defaultConfigs:{label:"Tags"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return j(t,"Tags",e("div",{class:"fk-tags"},a.map((l=>e("span",{class:"fk-tags__chip",key:l},l,e("button",{type:"button",class:"fk-tags__remove",disabled:t.editable||t.disabled,onClick:()=>{var e;const n=a.filter((e=>e!==l));null===(e=t.onDataChange)||void 0===e||e.call(t,n.length?n:void 0)}},"✕")))),e("input",{class:"fk-tags__input",type:"text",placeholder:"Add a tag…",disabled:t.editable||t.disabled,onKeyDown:e=>{var l;if("Enter"!==e.key)return;e.preventDefault();const n=e.target,i=n.value.trim();i&&!a.includes(i)&&(null===(l=t.onDataChange)||void 0===l||l.call(t,[...a,i]),n.value="")}})))}}),W=v({type:"input",dataType:"string",id:"signature",name:"Signature",category:"Inputs",defaultConfigs:{label:"Signature"},render:t=>{var a;return j(t,"Signature",e("fk-signature-input",{value:null!==(a=t.data)&&void 0!==a?a:void 0,disabled:t.editable||t.disabled,onSignatureChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),E=v({type:"panel",dataType:"void",id:"tabs",name:"Tabs",category:"Layout",defaultConfigs:{validateTabs:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Tab "+(a+1)}));return e("fk-tabs",{tabLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),Z=v({type:"input",dataType:"string",id:"radio",name:"Radio",category:"Inputs",defaultConfigs:{label:"Radio",options:"Option 1\nOption 2"},render:t=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Radio")),e("div",Object.assign({class:"fk-radio-group",role:"radiogroup"},x(t)),G(t).map((a=>{var l,n;return e("label",{class:"fk-radio",key:a.value},e("input",{type:"radio",name:null!==(n=null===(l=t.configs)||void 0===l?void 0:l.key)&&void 0!==n?n:t.path,checked:t.data===a.value,disabled:t.editable||t.disabled,onChange:()=>{var e;return null===(e=t.onDataChange)||void 0===e?void 0:e.call(t,a.value)}}),e("span",null,a.label))}))),t.error?e("span",{class:"fk-field__error"},t.error):null)}),J=[{key:"street",label:()=>p("address.street"),full:!0},{key:"city",label:()=>p("address.city"),full:!1},{key:"zip",label:()=>p("address.zip"),full:!1},{key:"country",label:()=>p("address.country"),full:!1}],$=v({type:"input",dataType:"object",id:"address",name:"Address",category:"Inputs",defaultConfigs:{label:"Address"},render:t=>{var a;const l=null!==(a=t.data)&&void 0!==a?a:{};return O(t,"Address",e("div",{class:"fk-address"},J.map((a=>{var n;return e("label",{class:{"fk-address__part":!0,"fk-address__part--full":a.full},key:a.key},e("span",{class:"fk-address__label"},a.label()),e("input",{class:"fk-field__input",type:"text",value:null!==(n=l[a.key])&&void 0!==n?n:"",disabled:t.editable||t.disabled,onInput:e=>{var n;const i=e.target.value,o=Object.assign(Object.assign({},l),{[a.key]:i||void 0}),r=Object.fromEntries(Object.entries(o).filter((([,e])=>void 0!==e)));null===(n=t.onDataChange)||void 0===n||n.call(t,Object.keys(r).length?r:void 0)}}))}))))}}),q=v({type:"input",dataType:"object",id:"file",name:"File",category:"Data",defaultConfigs:{label:"File",accept:"",uploadUrl:"",multiple:!1},render:t=>{var a,l,n;return O(t,"File",e("fk-file-input",{value:t.data,accept:null===(a=t.configs)||void 0===a?void 0:a.accept,uploadUrl:null===(l=t.configs)||void 0===l?void 0:l.uploadUrl,multiple:!0===(null===(n=t.configs)||void 0===n?void 0:n.multiple),disabled:t.editable||t.disabled,onFileValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),H=v({type:"collection",dataType:"array",id:"data-grid",name:"Data grid",category:"Data",defaultConfigs:{label:"Data grid"},render:t=>O(t,"Data grid",t.editable||!t.brickSpec?e("div",{class:"fk-grid-template"},e("span",{class:"fk-grid-template__hint"},p("grid.columns")),t.children):e("fk-data-grid",{spec:t.brickSpec,value:t.data,disabled:t.disabled,locale:t.locale,utils:t.utils,onGridValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),K=v({type:"input",dataType:"string",id:"hidden",name:"Hidden",category:"Data",defaultConfigs:{},render:t=>{var a,l;return t.editable?e("div",{class:"fk-hidden-chip"},"hidden: ",null===(a=t.configs)||void 0===a?void 0:a.key):e("input",{type:"hidden",value:null!==(l=t.data)&&void 0!==l?l:""})}}),X=v({type:"output",dataType:"void",id:"content",name:"Content",category:"Layout",defaultConfigs:{content:"Some text…"},render:t=>{var a,l;return e("div",{class:"fk-content",style:k(t.styles)},((null!==(l=null===(a=t.configs)||void 0===a?void 0:a.content)&&void 0!==l?l:"")+"").split("\n").map((t=>e("p",{class:"fk-content__line"},t))))}}),Y=v({type:"panel",dataType:"void",id:"stepper",name:"Stepper",category:"Layout",defaultConfigs:{validateSteps:!1,allowStepClick:!0,showSubmit:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Step "+(a+1)}));return e("fk-stepper",{stepLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),Q=v({type:"input",dataType:"boolean",id:"checkbox",name:"Checkbox",category:"Inputs",defaultConfigs:{label:"Checkbox"},render:t=>e("label",{class:"fk-field fk-field--inline",style:k(t.styles)},e("input",{class:"fk-field__checkbox",type:"checkbox",checked:!0===t.data,disabled:t.editable||t.disabled,onChange:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.checked)}}),e("span",{class:"fk-field__label"},h(t,"Checkbox")),t.error?e("span",{class:"fk-field__error"},t.error):null)}),ee=v({type:"panel",dataType:"void",id:"group",name:"Group",category:"Layout",render:t=>{var a;return e("fieldset",{class:"fk-group",style:k(t.styles)},(null===(a=t.configs)||void 0===a?void 0:a.label)?e("legend",{class:"fk-group__legend"},t.configs.label):null,t.children)}}),te=v({type:"panel",dataType:"void",id:"row",name:"Row",category:"Layout",render:t=>e("div",{class:"fk-row",style:k(t.styles)},t.children)}),ae=v({type:"panel",dataType:"void",id:"column",name:"Column",category:"Layout",render:t=>e("div",{class:"fk-column",style:k(t.styles)},t.children)}),le=(e,t)=>{var a;if(Array.isArray(t))return t.map((t=>le(e,t))).filter(Boolean).join(", ");if(!0===t)return f("recap.yes","Yes");if(!1===t)return f("recap.no","No");if(t&&"object"==typeof t)return"string"==typeof t.name&&"url"in t?t.name:Object.values(t).filter((e=>"string"==typeof e&&e)).join(" ");const l=(null!=t?t:"")+"";if(null!=(null===(a=e.configs)||void 0===a?void 0:a.options)){const t=u(e.configs.options,"string"==typeof e.configs.labelKey?e.configs.labelKey:"label","string"==typeof e.configs.valueKey?e.configs.valueKey:"value").find((e=>e.value===l));if(t)return t.label}return l},ne=e=>null==e||""===e||Array.isArray(e)&&0===e.length,ie=(e,t)=>{var a,l,n,o,r;return(null!==(r=null!==(n=null!==(l=i(null===(a=e.configs)||void 0===a?void 0:a.label,t))&&void 0!==l?l:e.name)&&void 0!==n?n:null===(o=e.configs)||void 0===o?void 0:o.key)&&void 0!==r?r:"")+""},oe=e=>{var t,a;const l=[];for(const n of null!==(t=e.children)&&void 0!==t?t:[]){const e=null===(a=n.configs)||void 0===a?void 0:a.key;"input"===n.type&&e&&!e.startsWith("_")?l.push(n):"panel"===n.type&&l.push(...oe(n))}return l},re=(e,t,a,l,n=!1)=>{var r,d,s;if(!e)return[];const u=[];for(const p of null!==(r=e.children)&&void 0!==r?r:[]){if("recap"===p.id||"action"===p.type)continue;if(!0===o(p.rules,t).hidden)continue;const e=null===(d=p.configs)||void 0===d?void 0:d.key,r=ie(p,a);if("collection"===p.type){const n=e&&Array.isArray(null==t?void 0:t[e])?t[e]:[];if(!n.length&&!l)continue;const i=oe(p);u.push({kind:"collection",label:r,columns:i.map((e=>ie(e,a))),rows:n.map((e=>i.map((t=>{const a=null==e?void 0:e[t.configs.key];return ne(a)?"—":le(t,a)}))))});continue}if("panel"===p.type){const e=i(null===(s=p.configs)||void 0===s?void 0:s.label,a);if(n&&"string"==typeof e&&e.trim()){const n=re(p,t,a,l);n.length&&(u.push({kind:"section",label:e}),u.push(...n));continue}u.push(...re(p,t,a,l,n));continue}if("input"!==p.type||!e||e.startsWith("_"))continue;const c=null==t?void 0:t[e];ne(c)&&!l||u.push({kind:"field",label:r,value:ne(c)?"—":le(p,c)})}return u},de=v({type:"output",dataType:"void",id:"recap",name:"Recap",category:"Layout",defaultConfigs:{label:"Recap",showEmpty:!1,groupBySections:!1},render:t=>{var a,l;const n=re(t.rootSpec,t.dataMap,t.locale,!0===(null===(a=t.configs)||void 0===a?void 0:a.showEmpty),!0===(null===(l=t.configs)||void 0===l?void 0:l.groupBySections)),i=[];let o=[];const r=()=>{o.length&&(i.push(e("dl",{class:"fk-recap__list"},o.map((t=>e("div",{class:"fk-recap__row",key:t.label},e("dt",{class:"fk-recap__term"},t.label),e("dd",{class:"fk-recap__value"},t.value)))))),o=[])};for(const t of n)"field"!==t.kind?(r(),i.push("section"!==t.kind?e("section",{class:"fk-recap__section",key:t.label},e("span",{class:"fk-recap__section-title"},t.label),t.rows.length?e("div",{class:"fk-recap__table-wrap"},e("table",{class:"fk-recap__table"},e("thead",null,e("tr",null,e("th",{class:"fk-recap__index-cell"},"#"),t.columns.map((t=>e("th",{key:t},t))))),e("tbody",null,t.rows.map(((t,a)=>e("tr",{key:a},e("td",{class:"fk-recap__index-cell"},a+1),t.map(((t,a)=>e("td",{key:a},t))))))))):e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet."))):e("span",{class:"fk-recap__group-title",key:"section:"+t.label},t.label))):o.push(t);return r(),e("div",{class:"fk-field fk-recap",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Recap")),i.length?i:e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet.")))}}),se=e=>{if(!e)return[];const t=[],a=e=>{var l,n;const i=null===(l=e.configs)||void 0===l?void 0:l.key;"input"===e.type&&i&&!i.startsWith("_")&&t.push(i);for(const t of null!==(n=e.children)&&void 0!==n?n:[])a(t)};return a(e),t},ue=v({type:"input",dataType:"string",id:"code",name:"Code",category:"Inputs",defaultConfigs:{label:"Code",placeholder:"return value;"},render:t=>{var a,l,n,i;return O(t,"Code",t.editable||t.disabled?e("pre",{class:"fk-code-preview"},t.data||(null!==(l=null===(a=t.configs)||void 0===a?void 0:a.placeholder)&&void 0!==l?l:"")+""):e("fk-code-editor",{value:null!==(n=t.data)&&void 0!==n?n:"",completions:se(t.rootSpec),placeholder:null===(i=t.configs)||void 0===i?void 0:i.placeholder,onCodeChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail||void 0)}}))}}),pe=v({type:"panel",dataType:"void",id:"nested-form",name:"Nested form",category:"Layout",defaultConfigs:{label:"Nested form",specRef:""},render:t=>{var a;const l=(null===(a=t.configs)||void 0===a?void 0:a.specRef)||"";return e("div",{class:"fk-nested-form",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Nested form")),e("p",{class:"fk-nested-form__hint"},l?`${f("nestedForm.ref","Referenced form")}: ${l}`:f("nestedForm.missing","Set the specRef config to reference a form.")))}});function ce(){t([A,I,w,B,L,R,D,N,P,z,F,M,Z,U,Q,V,W,$,ue,q,H,K,X,de,pe,ee,te,ae,Y,E])}export{$ as addressBrick,Q as checkboxBrick,ue as codeBrick,ae as columnBrick,X as contentBrick,v as createBrick,H as dataGridBrick,N as dateBrick,z as datetimeBrick,I as emailBrick,q as fileBrick,p as fkT,f as fkTOr,ee as groupBrick,e as h,K as hiddenBrick,M as multiSelectBrick,pe as nestedFormBrick,D as numberBrick,w as passwordBrick,L as phoneBrick,Z as radioBrick,de as recapBrick,t as registerBricks,ce as registerDefaultBricks,te as rowBrick,U as selectBoxesBrick,F as selectBrick,W as signatureBrick,Y as stepperBrick,E as tabsBrick,V as tagsBrick,A as textInputBrick,R as textareaBrick,P as timeBrick,B as urlBrick}
1
+ import{h as e}from"./p-BB4Llg42.js";export{g as getAssetPath,r as render,s as setAssetPath,b as setNonce,d as setPlatformOptions}from"./p-BB4Llg42.js";import{r as t}from"./p-gPc0o8Jb.js";export{b as getBrick,g as getBrickMolds,a as getBrickMoldsGroupedByCategory,n as newBrickSpec,c as registerBrick}from"./p-gPc0o8Jb.js";import{B as l,p as i,g as o}from"./p-BYhtwUM4.js";import{n as u}from"./p-CyZA17qf.js";import{a as p,f}from"./p-bZPtT8wr.js";export{b as frFkTranslations,s as setFkTranslations}from"./p-bZPtT8wr.js";function v(e){return new class extends l{constructor(){var t;super({type:e.type,dataType:e.dataType,id:e.id,name:e.name,category:e.category,configsForm:e.configsForm,styles:null!==(t=e.styles)&&void 0!==t?t:{},validators:e.validators,unWrapData:e.unWrapData,isPrivate:e.isPrivate,defaultConfigs:e.defaultConfigs})}render(t){return e.render(t)}renderBuilder(t){var a;return(null!==(a=e.renderBuilder)&&void 0!==a?a:e.render)(t)}getComponent(e){return this.render(e)}getComponentWithActions(e){return this.renderBuilder(e)}}}const y=e=>e.replace(/-([a-z])/g,((e,t)=>t.toUpperCase()));function k(e){const t=Object.entries(null!=e?e:{}).filter((([,e])=>null!=e&&""!==e));if(0===t.length)return;const a={};for(const[e,l]of t)a[y(e)]=l+"";return a}const m=(e,t)=>"9"===e?/\d/.test(t):"a"===e||"A"===e?/[a-zA-Z]/.test(t):/[0-9a-zA-Z]/.test(t),_=e=>"9"===e||"a"===e||"A"===e||"*"===e,h=(e,t)=>{var a,l,n,i;return null!==(i=null!==(l=null===(a=e.configs)||void 0===a?void 0:a.label)&&void 0!==l?l:null===(n=e.configs)||void 0===n?void 0:n.key)&&void 0!==i?i:t},T=(t,a)=>{var l,n;const i=null===(l=t.configs)||void 0===l?void 0:l.prefix,o=null===(n=t.configs)||void 0===n?void 0:n.suffix;return i||o?e("div",{class:"fk-adorned"},i?e("span",{class:"fk-adorned__affix"},i):null,a,o?e("span",{class:"fk-adorned__affix"},o):null):a},C=t=>t.error?e("span",{class:"fk-field__error",role:"alert"},t.error):null,x=e=>e.error?{"aria-invalid":"true"}:{},j=(t,a,l)=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,a)),l,C(t)),O=(t,a,l)=>e("label",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,a)),l,C(t)),S=t=>v({type:"input",dataType:"string",id:t.id,name:t.name,category:"Inputs",defaultConfigs:t.maskable?{label:t.name,mask:""}:{label:t.name},render:a=>{var l,n;return O(a,t.name,T(a,e("input",Object.assign({},x(a),{class:"fk-field__input fk-adorned__input",type:t.inputType,value:null!==(l=a.data)&&void 0!==l?l:"",placeholder:null===(n=a.configs)||void 0===n?void 0:n.placeholder,disabled:a.editable||a.disabled,onInput:e=>{var t,l;const n=e.target,i=null===(t=a.configs)||void 0===t?void 0:t.mask,o=i?((e,t)=>{if(!t)return e;let a="",l=0;for(let n=0;n<t.length&&l<e.length;n++){const i=t[n];if(_(i))for(;l<e.length;){const t=e[l++];if(m(i,t)){a+="A"===i?t.toUpperCase():t;break}}else a+=i,e[l]===i&&l++}return a})(n.value,i):n.value;o!==n.value&&(n.value=o),null===(l=a.onDataChange)||void 0===l||l.call(a,o)}}))))}}),w=S({id:"text",name:"Text",inputType:"text",maskable:!0}),A=S({id:"email",name:"Email",inputType:"email"}),I=S({id:"password",name:"Password",inputType:"password"}),B=S({id:"url",name:"URL",inputType:"url"}),L=S({id:"phone",name:"Phone",inputType:"tel",maskable:!0}),D=v({type:"input",dataType:"string",id:"textarea",name:"Text area",category:"Inputs",defaultConfigs:{label:"Text area"},render:t=>{var a,l;return O(t,"Text area",e("textarea",Object.assign({},x(t),{class:"fk-field__input fk-field__input--textarea",value:null!==(a=t.data)&&void 0!==a?a:"",placeholder:null===(l=t.configs)||void 0===l?void 0:l.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.value)}})))}}),N=v({type:"input",dataType:"number",id:"number",name:"Number",category:"Inputs",defaultConfigs:{label:"Number"},render:t=>{var a;return O(t,"Number",T(t,e("input",Object.assign({},x(t),{class:"fk-field__input fk-adorned__input",type:"number",value:null==t.data?"":t.data+"",placeholder:null===(a=t.configs)||void 0===a?void 0:a.placeholder,disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:Number(l))}}))))}}),R=v({type:"input",dataType:"string",id:"date",name:"Date",category:"Inputs",defaultConfigs:{label:"Date"},render:t=>{var a;return O(t,"Date",e("input",Object.assign({},x(t),{class:"fk-field__input",type:"date",value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,onInput:e=>{var a;const l=e.target.value;null===(a=t.onDataChange)||void 0===a||a.call(t,""===l?void 0:l)}})))}}),M=v({type:"input",dataType:"string",id:"select",name:"Select",category:"Inputs",defaultConfigs:{label:"Select",optionsSource:"static",options:"Option 1\nOption 2"},render:t=>{var a;return j(t,"Select",e("fk-select-input",{configs:t.configs,value:null!==(a=t.data)&&void 0!==a?a:"",disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),P=v({type:"input",dataType:"array",id:"multi-select",name:"Multi select",category:"Inputs",defaultConfigs:{label:"Multi select",optionsSource:"static",options:"Option 1\nOption 2\nOption 3"},render:t=>j(t,"Multi select",e("fk-select-input",{configs:t.configs,value:Array.isArray(t.data)?t.data:[],multiple:!0,disabled:t.editable||t.disabled,invalid:!!t.error,dataMap:t.dataMap,onSelectValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),F=S({id:"time",name:"Time",inputType:"time"}),z=S({id:"datetime",name:"Date / Time",inputType:"datetime-local"}),Z=e=>{var t,a,l;return u(null===(t=e.configs)||void 0===t?void 0:t.options,"string"==typeof(null===(a=e.configs)||void 0===a?void 0:a.labelKey)?e.configs.labelKey:"label","string"==typeof(null===(l=e.configs)||void 0===l?void 0:l.valueKey)?e.configs.valueKey:"value")},U=v({type:"input",dataType:"array",id:"select-boxes",name:"Select boxes",category:"Inputs",defaultConfigs:{label:"Select boxes",options:"Option 1\nOption 2\nOption 3"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Select boxes")),e("div",{class:"fk-radio-group"},Z(t).map((l=>e("label",{class:"fk-radio",key:l.value},e("input",{type:"checkbox",checked:a.includes(l.value),disabled:t.editable||t.disabled,onChange:e=>{var n;const i=e.target.checked?[...a,l.value]:a.filter((e=>e!==l.value));null===(n=t.onDataChange)||void 0===n||n.call(t,i.length?i:void 0)}}),e("span",null,l.label))))),t.error?e("span",{class:"fk-field__error"},t.error):null)}}),V=v({type:"input",dataType:"array",id:"tags",name:"Tags",category:"Inputs",defaultConfigs:{label:"Tags"},render:t=>{const a=Array.isArray(t.data)?t.data:[];return O(t,"Tags",e("div",{class:"fk-tags"},a.map((l=>e("span",{class:"fk-tags__chip",key:l},l,e("button",{type:"button",class:"fk-tags__remove",disabled:t.editable||t.disabled,onClick:()=>{var e;const n=a.filter((e=>e!==l));null===(e=t.onDataChange)||void 0===e||e.call(t,n.length?n:void 0)}},"✕")))),e("input",{class:"fk-tags__input",type:"text",placeholder:"Add a tag…",disabled:t.editable||t.disabled,onKeyDown:e=>{var l;if("Enter"!==e.key)return;e.preventDefault();const n=e.target,i=n.value.trim();i&&!a.includes(i)&&(null===(l=t.onDataChange)||void 0===l||l.call(t,[...a,i]),n.value="")}})))}}),E=v({type:"input",dataType:"string",id:"signature",name:"Signature",category:"Inputs",defaultConfigs:{label:"Signature"},render:t=>{var a;return O(t,"Signature",e("fk-signature-input",{value:null!==(a=t.data)&&void 0!==a?a:void 0,disabled:t.editable||t.disabled,onSignatureChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),G=v({type:"panel",dataType:"void",id:"tabs",name:"Tabs",category:"Layout",defaultConfigs:{validateTabs:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Tab "+(a+1)}));return e("fk-tabs",{tabLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),J=v({type:"input",dataType:"string",id:"radio",name:"Radio",category:"Inputs",defaultConfigs:{label:"Radio",options:"Option 1\nOption 2"},render:t=>e("div",{class:"fk-field",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Radio")),e("div",Object.assign({class:"fk-radio-group",role:"radiogroup"},x(t)),Z(t).map((a=>{var l,n;return e("label",{class:"fk-radio",key:a.value},e("input",{type:"radio",name:null!==(n=null===(l=t.configs)||void 0===l?void 0:l.key)&&void 0!==n?n:t.path,checked:t.data===a.value,disabled:t.editable||t.disabled,onChange:()=>{var e;return null===(e=t.onDataChange)||void 0===e?void 0:e.call(t,a.value)}}),e("span",null,a.label))}))),t.error?e("span",{class:"fk-field__error"},t.error):null)}),W=[{key:"street",label:()=>p("address.street"),full:!0},{key:"city",label:()=>p("address.city"),full:!1},{key:"zip",label:()=>p("address.zip"),full:!1},{key:"country",label:()=>p("address.country"),full:!1}],Y=v({type:"input",dataType:"object",id:"address",name:"Address",category:"Inputs",defaultConfigs:{label:"Address"},render:t=>{var a;const l=null!==(a=t.data)&&void 0!==a?a:{};return j(t,"Address",e("div",{class:"fk-address"},W.map((a=>{var n;return e("label",{class:{"fk-address__part":!0,"fk-address__part--full":a.full},key:a.key},e("span",{class:"fk-address__label"},a.label()),e("input",{class:"fk-field__input",type:"text",value:null!==(n=l[a.key])&&void 0!==n?n:"",disabled:t.editable||t.disabled,onInput:e=>{var n;const i=e.target.value,o=Object.assign(Object.assign({},l),{[a.key]:i||void 0}),r=Object.fromEntries(Object.entries(o).filter((([,e])=>void 0!==e)));null===(n=t.onDataChange)||void 0===n||n.call(t,Object.keys(r).length?r:void 0)}}))}))))}}),$=v({type:"input",dataType:"object",id:"file",name:"File",category:"Data",defaultConfigs:{label:"File",accept:"",uploadUrl:"",multiple:!1},render:t=>{var a,l,n;return j(t,"File",e("fk-file-input",{value:t.data,accept:null===(a=t.configs)||void 0===a?void 0:a.accept,uploadUrl:null===(l=t.configs)||void 0===l?void 0:l.uploadUrl,multiple:!0===(null===(n=t.configs)||void 0===n?void 0:n.multiple),disabled:t.editable||t.disabled,onFileValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}}),q=v({type:"collection",dataType:"array",id:"data-grid",name:"Data grid",category:"Data",defaultConfigs:{label:"Data grid"},render:t=>j(t,"Data grid",t.editable||!t.brickSpec?e("div",{class:"fk-grid-template"},e("span",{class:"fk-grid-template__hint"},p("grid.columns")),t.children):e("fk-data-grid",{spec:t.brickSpec,value:t.data,disabled:t.disabled,locale:t.locale,utils:t.utils,onGridValueChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail)}}))}),H=v({type:"input",dataType:"string",id:"hidden",name:"Hidden",category:"Data",defaultConfigs:{},render:t=>{var a,l;return t.editable?e("div",{class:"fk-hidden-chip"},"hidden: ",null===(a=t.configs)||void 0===a?void 0:a.key):e("input",{type:"hidden",value:null!==(l=t.data)&&void 0!==l?l:""})}}),K=v({type:"output",dataType:"void",id:"content",name:"Content",category:"Layout",defaultConfigs:{content:"Some text…"},render:t=>{var a,l;return e("div",{class:"fk-content",style:k(t.styles)},((null!==(l=null===(a=t.configs)||void 0===a?void 0:a.content)&&void 0!==l?l:"")+"").split("\n").map((t=>e("p",{class:"fk-content__line"},t))))}}),Q=v({type:"panel",dataType:"void",id:"stepper",name:"Stepper",category:"Layout",defaultConfigs:{validateSteps:!1,allowStepClick:!0,showSubmit:!1},render:t=>{var a,l;const n=(null!==(l=null===(a=t.brickSpec)||void 0===a?void 0:a.children)&&void 0!==l?l:[]).map(((e,a)=>{var l,n;const o=i(null===(l=e.configs)||void 0===l?void 0:l.label,t.locale);return"string"==typeof o?o:null!==(n=e.name)&&void 0!==n?n:"Step "+(a+1)}));return e("fk-stepper",{stepLabels:n,editable:t.editable,spec:t.brickSpec,dataMap:t.dataMap,locale:t.locale,style:k(t.styles)},t.children)}}),X=v({type:"input",dataType:"boolean",id:"checkbox",name:"Checkbox",category:"Inputs",defaultConfigs:{label:"Checkbox"},render:t=>e("label",{class:"fk-field fk-field--inline",style:k(t.styles)},e("input",{class:"fk-field__checkbox",type:"checkbox",checked:!0===t.data,disabled:t.editable||t.disabled,onChange:e=>{var a;return null===(a=t.onDataChange)||void 0===a?void 0:a.call(t,e.target.checked)}}),e("span",{class:"fk-field__label"},h(t,"Checkbox")),t.error?e("span",{class:"fk-field__error"},t.error):null)}),ee=v({type:"panel",dataType:"void",id:"group",name:"Group",category:"Layout",render:t=>{var a;return e("fieldset",{class:"fk-group",style:k(t.styles)},(null===(a=t.configs)||void 0===a?void 0:a.label)?e("legend",{class:"fk-group__legend"},t.configs.label):null,t.children)}}),te=v({type:"panel",dataType:"void",id:"row",name:"Row",category:"Layout",render:t=>e("div",{class:"fk-row",style:k(t.styles)},t.children)}),ae=v({type:"panel",dataType:"void",id:"column",name:"Column",category:"Layout",render:t=>e("div",{class:"fk-column",style:k(t.styles)},t.children)}),le=(e,t)=>{var a;if(Array.isArray(t))return t.map((t=>le(e,t))).filter(Boolean).join(", ");if(!0===t)return f("recap.yes","Yes");if(!1===t)return f("recap.no","No");if(t&&"object"==typeof t)return"string"==typeof t.name&&"url"in t?t.name:Object.values(t).filter((e=>"string"==typeof e&&e)).join(" ");const l=(null!=t?t:"")+"";if(null!=(null===(a=e.configs)||void 0===a?void 0:a.options)){const t=u(e.configs.options,"string"==typeof e.configs.labelKey?e.configs.labelKey:"label","string"==typeof e.configs.valueKey?e.configs.valueKey:"value").find((e=>e.value===l));if(t)return t.label}return l},ne=e=>null==e||""===e||Array.isArray(e)&&0===e.length,ie=(e,t)=>{var a,l,n,o,r;return(null!==(r=null!==(n=null!==(l=i(null===(a=e.configs)||void 0===a?void 0:a.label,t))&&void 0!==l?l:e.name)&&void 0!==n?n:null===(o=e.configs)||void 0===o?void 0:o.key)&&void 0!==r?r:"")+""},oe=e=>{var t,a;const l=[];for(const n of null!==(t=e.children)&&void 0!==t?t:[]){const e=null===(a=n.configs)||void 0===a?void 0:a.key;"input"===n.type&&e&&!e.startsWith("_")?l.push(n):"panel"===n.type&&l.push(...oe(n))}return l},re=(e,t,a,l,n=!1)=>{var r,d,s;if(!e)return[];const u=[];for(const p of null!==(r=e.children)&&void 0!==r?r:[]){if("recap"===p.id||"action"===p.type)continue;if(!0===o(p.rules,t).hidden)continue;const e=null===(d=p.configs)||void 0===d?void 0:d.key,r=ie(p,a);if("collection"===p.type){const n=e&&Array.isArray(null==t?void 0:t[e])?t[e]:[];if(!n.length&&!l)continue;const i=oe(p);u.push({kind:"collection",label:r,columns:i.map((e=>ie(e,a))),rows:n.map((e=>i.map((t=>{const a=null==e?void 0:e[t.configs.key];return ne(a)?"—":le(t,a)}))))});continue}if("panel"===p.type){const e=i(null===(s=p.configs)||void 0===s?void 0:s.label,a);if(n&&"string"==typeof e&&e.trim()){const n=re(p,t,a,l);n.length&&(u.push({kind:"section",label:e}),u.push(...n));continue}u.push(...re(p,t,a,l,n));continue}if("input"!==p.type||!e||e.startsWith("_"))continue;const c=null==t?void 0:t[e];ne(c)&&!l||u.push({kind:"field",label:r,value:ne(c)?"—":le(p,c)})}return u},de=v({type:"output",dataType:"void",id:"recap",name:"Recap",category:"Layout",defaultConfigs:{label:"Recap",showEmpty:!1,groupBySections:!1},render:t=>{var a,l;const n=re(t.rootSpec,t.dataMap,t.locale,!0===(null===(a=t.configs)||void 0===a?void 0:a.showEmpty),!0===(null===(l=t.configs)||void 0===l?void 0:l.groupBySections)),i=[];let o=[];const r=()=>{o.length&&(i.push(e("dl",{class:"fk-recap__list"},o.map((t=>e("div",{class:"fk-recap__row",key:t.label},e("dt",{class:"fk-recap__term"},t.label),e("dd",{class:"fk-recap__value"},t.value)))))),o=[])};for(const t of n)"field"!==t.kind?(r(),i.push("section"!==t.kind?e("section",{class:"fk-recap__section",key:t.label},e("span",{class:"fk-recap__section-title"},t.label),t.rows.length?e("div",{class:"fk-recap__table-wrap"},e("table",{class:"fk-recap__table"},e("thead",null,e("tr",null,e("th",{class:"fk-recap__index-cell"},"#"),t.columns.map((t=>e("th",{key:t},t))))),e("tbody",null,t.rows.map(((t,a)=>e("tr",{key:a},e("td",{class:"fk-recap__index-cell"},a+1),t.map(((t,a)=>e("td",{key:a},t))))))))):e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet."))):e("span",{class:"fk-recap__group-title",key:"section:"+t.label},t.label))):o.push(t);return r(),e("div",{class:"fk-field fk-recap",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Recap")),i.length?i:e("p",{class:"fk-recap__empty"},f("recap.empty","Nothing to summarize yet.")))}}),se=e=>{if(!e)return[];const t=[],a=e=>{var l,n;const i=null===(l=e.configs)||void 0===l?void 0:l.key;"input"===e.type&&i&&!i.startsWith("_")&&t.push(i);for(const t of null!==(n=e.children)&&void 0!==n?n:[])a(t)};return a(e),t},ue=v({type:"input",dataType:"string",id:"code",name:"Code",category:"Inputs",defaultConfigs:{label:"Code",placeholder:"return value;"},render:t=>{var a,l,n,i;return j(t,"Code",t.editable||t.disabled?e("pre",{class:"fk-code-preview"},t.data||(null!==(l=null===(a=t.configs)||void 0===a?void 0:a.placeholder)&&void 0!==l?l:"")+""):e("fk-code-editor",{value:null!==(n=t.data)&&void 0!==n?n:"",completions:se(t.rootSpec),placeholder:null===(i=t.configs)||void 0===i?void 0:i.placeholder,onCodeChange:e=>{var a;e.stopPropagation(),null===(a=t.onDataChange)||void 0===a||a.call(t,e.detail||void 0)}}))}}),pe=v({type:"panel",dataType:"void",id:"nested-form",name:"Nested form",category:"Layout",defaultConfigs:{label:"Nested form",specRef:""},render:t=>{var a;const l=(null===(a=t.configs)||void 0===a?void 0:a.specRef)||"";return e("div",{class:"fk-nested-form",style:k(t.styles)},e("span",{class:"fk-field__label"},h(t,"Nested form")),e("p",{class:"fk-nested-form__hint"},l?`${f("nestedForm.ref","Referenced form")}: ${l}`:f("nestedForm.missing","Set the specRef config to reference a form.")))}});function ce(){t([w,A,I,B,L,D,N,R,F,z,M,P,J,U,X,V,E,Y,ue,$,q,H,K,de,pe,ee,te,ae,Q,G])}export{Y as addressBrick,X as checkboxBrick,ue as codeBrick,ae as columnBrick,K as contentBrick,v as createBrick,q as dataGridBrick,R as dateBrick,z as datetimeBrick,A as emailBrick,$ as fileBrick,p as fkT,f as fkTOr,ee as groupBrick,e as h,H as hiddenBrick,P as multiSelectBrick,pe as nestedFormBrick,N as numberBrick,I as passwordBrick,L as phoneBrick,J as radioBrick,de as recapBrick,t as registerBricks,ce as registerDefaultBricks,te as rowBrick,U as selectBoxesBrick,M as selectBrick,E as signatureBrick,Q as stepperBrick,G as tabsBrick,V as tagsBrick,w as textInputBrick,D as textareaBrick,F as timeBrick,B as urlBrick}
@@ -1 +1 @@
1
- import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-RzeBwfwG.js";import{s as O,b as $}from"./p-CehxuHtl.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function S(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function C(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class L{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function j(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const B=t.define();function F(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class H{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const U=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:_,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>K(t(i),e(i)),optionClass:(t,e)=>i=>K(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function K(t,e){return t?e?t+" "+e:t:e}function _(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const q=o.define();function G(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class N{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(U);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=G(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:q.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(U).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=G(o.length,r,t.state.facet(U).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=G(e.options.length,e.selected,this.view.state.facet(U).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(U).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Q(t,e){return i=>new N(i,t,e)}function X(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class J{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new J(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(U);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new L(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new H(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new L(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):X(t.completion)>X(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(U).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new J(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new J(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new J(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(U),n=(i.override||e.languageDataAt("autocomplete",j(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=J.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(q)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(B);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(j(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=j(t.state);if(s>r||!n||2&e&&(j(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:j(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...F(t.state,i,n.from,n.to),annotations:B.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=Q(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(U).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:q.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(U).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(U);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(U).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=j(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(U).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(U),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=j(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(U).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[B.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function St(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const Ct=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),Lt=St(1),jt=St(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Bt(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Ft=[{key:"Tab",run:Lt,shift:jt},{key:"Escape",run:Ct}],Rt=e.define({combine:t=>t.length?t[0]:Ft}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ht=Object.create(null);function Ut(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function Kt(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of Kt(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ut(s,i,l,c,o-r);r+=s.length+1}}else Ut(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const _t=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=Kt(t.state.doc,function(t){return Ht[t]||(Ht[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},qt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gt=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Nt=new class extends d{};Nt.startSide=1,Nt.endSide=-1;const Qt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(Gt)&&(t=t.update({add:[Nt.range(i.value,i.value+1)]}));return t}});function Xt(){return[ee,Qt]}const Jt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Jt.charCodeAt(e)==t)return Jt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||qt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||qt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||qt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||qt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Qt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:Gt.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:Gt.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||qt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:Gt.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:Gt.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,U.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([U],(t=>t.facet(U).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return q.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,Ct as clearSnippet,Xt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,_t as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Bt as hasPrevSnippetField,S as ifIn,C as ifNotIn,oe as insertBracket,F as insertCompletionText,ht as moveCompletionSelection,Lt as nextSnippetField,B as pickedCompletion,jt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}
1
+ import{Annotation as t,Facet as e,StateField as i,Prec as n,StateEffect as o,codePointAt as r,EditorSelection as s,Transaction as l,Text as c,combineConfig as u,codePointSize as h,RangeSet as f,fromCodePoint as a,CharCategory as p,MapMode as m,RangeValue as d}from"./p-DtcM1yw5.js";import{V as g,E as w,g as b,s as y,l as v,k as x,a as I,W as k,D as M}from"./p-CfLRuUU4.js";import{s as O,b as $}from"./p-_JpQ28sq.js";class T{constructor(t,e,i,n){this.state=t,this.pos=e,this.explicit=i,this.view=n,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=O(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),i=Math.max(e.from,this.pos-250),n=e.text.slice(i-e.from,this.pos-e.from),o=n.search(A(t,!1));return o<0?null:{from:i+o,to:this.pos,text:n.slice(o)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,i){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function E(t){let e=Object.keys(t).join(""),i=/\w/.test(e);return i&&(e=e.replace(/\w/g,"")),`[${i?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function D(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[i,n]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),i=Object.create(null);for(let{label:n}of t){e[n[0]]=!0;for(let t=1;t<n.length;t++)i[n[t]]=!0}let n=E(e)+E(i)+"*$";return[new RegExp("^"+n),new RegExp(n)]}(e);return t=>{let o=t.matchBefore(n);return o||t.explicit?{from:o?o.from:t.pos,options:e,validFor:i}:null}}function L(t,e){return i=>{for(let n=O(i.state).resolveInner(i.pos,-1);n;n=n.parent){if(t.indexOf(n.name)>-1)return e(i);if(n.type.isTop)break}return null}}function S(t,e){return i=>{for(let e=O(i.state).resolveInner(i.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(i)}}class C{constructor(t,e,i,n){this.completion=t,this.source=e,this.match=i,this.score=n}}function j(t){return t.selection.main.from}function A(t,e){var i;let{source:n}=t,o=e&&"^"!=n[0],r="$"!=n[n.length-1];return o||r?new RegExp(`${o?"^":""}(?:${n})${r?"$":""}`,null!==(i=t.flags)&&void 0!==i?i:t.ignoreCase?"i":""):t}const B=t.define();function F(t,e,i,n){let{main:o}=t.selection,r=i-o.from,l=n-o.from;return{...t.changeByRange((c=>{if(c!=o&&i!=n&&t.sliceDoc(c.from+r,c.from+l)!=t.sliceDoc(i,n))return{range:c};let u=t.toText(e);return{changes:{from:c.from+r,to:n==o.from?c.to:c.from+l,insert:u},range:s.cursor(c.from+r+u.length)}})),scrollIntoView:!0,userEvent:"input.complete"}}const R=new WeakMap;function W(t){if(!Array.isArray(t))return t;let e=R.get(t);return e||R.set(t,e=D(t)),e}const V=o.define(),P=o.define();class z{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let i=r(t,e),n=h(i);this.chars.push(i);let o=t.slice(e,e+n),s=o.toUpperCase();this.folded.push(r(s==o?o.toLowerCase():s,0)),e+=n}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:i,any:n,precise:o,byWord:s}=this;if(1==e.length){let n=r(t,0),o=h(n),s=o==t.length?0:-100;if(n==e[0]);else{if(n!=i[0])return null;s+=-200}return this.ret(s,[0,o])}let l=t.indexOf(this.pattern);if(0==l)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let c=e.length,u=0;if(l<0){for(let o=0,s=Math.min(t.length,200);o<s&&u<c;){let s=r(t,o);s!=e[u]&&s!=i[u]||(n[u++]=o),o+=h(s)}if(u<c)return null}let f=0,p=0,m=!1,d=0,g=-1,w=-1,b=/[a-z]/.test(t),y=!0;for(let n=0,u=Math.min(t.length,200),v=0;n<u&&p<c;){let u=r(t,n);l<0&&(f<c&&u==e[f]&&(o[f++]=n),d<c&&(u==e[d]||u==i[d]?(0==d&&(g=n),w=n+1,d++):d=0));let x,I=u<255?u>=48&&u<=57||u>=97&&u<=122?2:u>=65&&u<=90?1:0:(x=a(u))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!n||1==I&&b||0==v&&0!=I)&&(e[p]==u||i[p]==u&&(m=!0)?s[p++]=n:s.length&&(y=!1)),v=I,n+=h(u)}return p==c&&0==s[0]&&y?this.result((m?-200:0)-100,s,t):d==c&&0==g?this.ret(-200-t.length+(w==t.length?0:-100),[0,w]):l>-1?this.ret(-700-t.length,[l,l+this.pattern.length]):d==c?this.ret(-900-t.length,[g,w]):p==c?this.result((m?-200:0)-100-700+(y?0:-1100),s,t):2==e.length?null:this.result((n[0]?-700:0)-200-1100,n,t)}result(t,e,i){let n=[],o=0;for(let t of e){let e=t+(this.astral?h(r(i,t)):1);o&&n[o-1]==t?n[o-1]=e:(n[o++]=t,n[o++]=e)}return this.ret(t-i.length,n)}}class U{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),i=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==i?null:(this.matched=[0,e.length],this.score=i+(t.length==this.pattern.length?0:-100),this)}}const H=e.define({combine:t=>u(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:q,filterStrict:!1,compareCompletions:(t,e)=>(t.sortText||t.label).localeCompare(e.sortText||e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>i=>_(t(i),e(i)),optionClass:(t,e)=>i=>_(t(i),e(i)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function _(t,e){return t?e?t+" "+e:t:e}function q(t,e,i,n,o,r){let s,l,c=t.textDirection==M.RTL,u=c,h=!1,f="top",a=e.left-o.left,p=o.right-e.right,m=n.right-n.left,d=n.bottom-n.top;if(u&&a<Math.min(m,p)?u=!1:!u&&p<Math.min(m,a)&&(u=!0),m<=(u?a:p))s=Math.max(o.top,Math.min(i.top,o.bottom-d))-e.top,l=Math.min(400,u?a:p);else{h=!0,l=Math.min(400,(c?e.right:o.right-e.left)-30);let t=o.bottom-e.bottom;t>=d||t>e.top?s=i.bottom-e.top:(f="bottom",s=e.bottom-i.top)}return{style:`${f}: ${s/((e.bottom-e.top)/r.offsetHeight)}px; max-width: ${l/((e.right-e.left)/r.offsetWidth)}px`,class:"cm-completionInfo-"+(h?c?"left-narrow":"right-narrow":u?"left":"right")}}const K=o.define();function Q(t,e,i){if(t<=i)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/i);return{from:t*i,to:(t+1)*i}}let n=Math.ceil((t-e)/i);return{from:t-n*i,to:t-(n-1)*i}}class J{constructor(t,e,i){this.view=t,this.stateField=e,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let n=t.state.field(e),{options:o,selected:r}=n.open,s=t.state.facet(H);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,i,n){let o=document.createElement("span");o.className="cm-completionLabel";let r=t.displayLabel||t.label,s=0;for(let t=0;t<n.length;){let e=n[t++],i=n[t++];e>s&&o.appendChild(document.createTextNode(r.slice(s,e)));let l=o.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(r.slice(e,i))),l.className="cm-completionMatchedText",s=i}return s<r.length&&o.appendChild(document.createTextNode(r.slice(s))),o},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=Q(o.length,r,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(i=>{let{options:n}=t.state.field(e).open;for(let e,o=i.target;o&&o!=this.dom;o=o.parentNode)if("LI"==o.nodeName&&(e=/-(\d+)$/.exec(o.id))&&+e[1]<n.length)return this.applyCompletion(t,n[+e[1]]),void i.preventDefault();if(i.target==this.list){let e=this.list.classList.contains("cm-completionListIncompleteTop")&&i.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&i.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;null!=e&&(t.dispatch({effects:K.of(e)}),i.preventDefault())}})),this.dom.addEventListener("focusout",(e=>{let i=t.state.field(this.stateField,!1);i&&i.tooltip&&t.state.facet(H).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:P.of(null)})})),this.showOptions(o,n.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let i=t.state.field(this.stateField),n=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),i!=n){let{options:o,selected:r,disabled:s}=i.open;n.open&&n.open.options==o||(this.range=Q(o.length,r,t.state.facet(H).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),s!=(null===(e=n.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;(e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Q(e.options.length,e.selected,this.view.state.facet(H).maxRenderedOptions),this.showOptions(e.options,t.id));let i=this.updateSelectedOption(e.selected);if(i){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:o}=n;if(!o)return;let r="string"==typeof o?document.createTextNode(o):o(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>v(this.view.state,t,"completion info"))):(this.addInfoPane(r,n),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(t,e){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(65535*Math.random()).toString(16),null!=t.nodeType)i.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:n}=t;i.appendChild(e),this.infoDestroy=n||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let i=this.list.firstChild,n=this.range.from;i;i=i.nextSibling,n++)"LI"==i.nodeName&&i.id?n==t?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),e=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby")):n--;return e&&function(t,e){let i=t.getBoundingClientRect(),n=e.getBoundingClientRect(),o=i.height/t.offsetHeight;n.top<i.top?t.scrollTop-=(i.top-n.top)/o:n.bottom>i.bottom&&(t.scrollTop+=(n.bottom-i.bottom)/o)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),n=t.getBoundingClientRect(),o=this.space;if(!o){let t=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:t.clientWidth,bottom:t.clientHeight}}return n.top>Math.min(o.bottom,e.bottom)-10||n.bottom<Math.max(o.top,e.top)+10?null:this.view.state.facet(H).positionInfo(this.view,e,n,i,o,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,i){const n=document.createElement("ul");n.id=e,n.setAttribute("role","listbox"),n.setAttribute("aria-expanded","true"),n.setAttribute("aria-label",this.view.state.phrase("Completions")),n.addEventListener("mousedown",(t=>{t.target==n&&t.preventDefault()}));let o=null;for(let r=i.from;r<i.to;r++){let{completion:s,match:l}=t[r],{section:c}=s;if(c){let t="string"==typeof c?c:c.name;t!=o&&(r>i.from||0==i.from)&&(o=t,"string"!=typeof c&&c.header?n.appendChild(c.header(c)):n.appendChild(document.createElement("completion-section")).textContent=t)}const u=n.appendChild(document.createElement("li"));u.id=e+"-"+r,u.setAttribute("role","option");let h=this.optionClass(s);h&&(u.className=h);for(let t of this.optionContent){let e=t(s,this.view.state,this.view,l);e&&u.appendChild(e)}}return i.from&&n.classList.add("cm-completionListIncompleteTop"),i.to<t.length&&n.classList.add("cm-completionListIncompleteBottom"),n}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function N(t,e){return i=>new J(i,t,e)}function X(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class G{constructor(t,e,i,n,o,r){this.options=t,this.attrs=e,this.tooltip=i,this.timestamp=n,this.selected=o,this.disabled=r}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new G(this.options,et(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,i,n,o,r){if(n&&!r&&t.some((t=>t.isPending)))return n.setDisabled();let s=function(t,e){let i=[],n=null,o=null,r=t=>{i.push(t);let{section:e}=t.completion;if(e){n||(n=[]);let t="string"==typeof e?e:e.name;n.some((e=>e.name==t))||n.push("string"==typeof e?{name:t}:e)}},s=e.facet(H);for(let n of t)if(n.hasResult()){let t=n.result.getMatch;if(!1===n.result.filter)for(let e of n.result.options)r(new C(e,n.source,t?t(e):[],1e9-i.length));else{let i,l=e.sliceDoc(n.from,n.to),c=s.filterStrict?new U(l):new z(l);for(let e of n.result.options)if(i=c.match(e.label)){let s=e.displayLabel?t?t(e,i.matched):[]:i.matched,l=i.score+(e.boost||0);if(r(new C(e,n.source,s,l)),"object"==typeof e.section&&"dynamic"===e.section.rank){let{name:t}=e.section;o||(o=Object.create(null)),o[t]=Math.max(l,o[t]||-1e9)}}}}if(n){let t=Object.create(null),e=0,r=(t,e)=>("dynamic"===t.rank&&"dynamic"===e.rank?o[e.name]-o[t.name]:0)||("number"==typeof t.rank?t.rank:1e9)-("number"==typeof e.rank?e.rank:1e9)||(t.name<e.name?-1:1);for(let i of n.sort(r))e-=1e5,t[i.name]=e;for(let e of i){let{section:i}=e.completion;i&&(e.score+=t["string"==typeof i?i:i.name])}}let l=[],c=null,u=s.compareCompletions;for(let t of i.sort(((t,e)=>e.score-t.score||u(t.completion,e.completion)))){let e=t.completion;!c||c.label!=e.label||c.detail!=e.detail||null!=c.type&&null!=e.type&&c.type!=e.type||c.apply!=e.apply||c.boost!=e.boost?l.push(t):X(t.completion)>X(c)&&(l[l.length-1]=t),c=t.completion}return l}(t,e);if(!s.length)return n&&t.some((t=>t.isPending))?n.setDisabled():null;let l=e.facet(H).selectOnOpen?0:-1;if(n&&n.selected!=l&&-1!=n.selected){let t=n.options[n.selected].completion;for(let e=0;e<s.length;e++)if(s[e].completion==t){l=e;break}}return new G(s,et(i,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ut,above:o.aboveCursor},n?n.timestamp:Date.now(),l,!1)}map(t){return new G(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new G(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Y{constructor(t,e,i){this.active=t,this.id=e,this.open=i}static start(){return new Y(it,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,i=e.facet(H),n=(i.override||e.languageDataAt("autocomplete",j(e)).map(W)).map((e=>(this.active.find((t=>t.source==e))||new ot(e,this.active.some((t=>0!=t.state))?1:0)).update(t,i)));n.length==this.active.length&&n.every(((t,e)=>t==this.active[e]))&&(n=this.active);let o=this.open,r=t.effects.some((t=>t.is(st)));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||n.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let i=0,n=0;;){for(;i<t.length&&!t[i].hasResult();)i++;for(;n<e.length&&!e[n].hasResult();)n++;let o=i==t.length,r=n==e.length;if(o||r)return o==r;if(t[i++].result!=e[n++].result)return!1}}(n,this.active)||r?o=G.build(n,e,this.id,o,i,r):o&&o.disabled&&!n.some((t=>t.isPending))&&(o=null),!o&&n.every((t=>!t.isPending))&&n.some((t=>t.hasResult()))&&(n=n.map((t=>t.hasResult()?new ot(t.source,0):t)));for(let e of t.effects)e.is(K)&&(o=o&&o.setSelected(e.value,this.id));return n==this.active&&o==this.open?this:new Y(n,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Z:tt}}const Z={"aria-autocomplete":"list"},tt={};function et(t,e){let i={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(i["aria-activedescendant"]=t+"-"+e),i}const it=[];function nt(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(B);if(i&&e.activateOnCompletion(i))return 12}let i=t.isUserEvent("input.type");return i&&e.activateOnTyping?5:i?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ot{constructor(t,e,i=!1){this.source=t,this.state=e,this.explicit=i}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let i=nt(t,e),n=this;(8&i||16&i&&this.touches(t))&&(n=new ot(n.source,0)),4&i&&0==n.state&&(n=new ot(this.source,1)),n=n.updateFor(t,i);for(let e of t.effects)if(e.is(V))n=new ot(n.source,1,e.value);else if(e.is(P))n=new ot(n.source,0);else if(e.is(st))for(let t of e.value)t.source==n.source&&(n=t);return n}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(j(t.state))}}class rt extends ot{constructor(t,e,i,n,o,r){super(t,3,e),this.limit=i,this.result=n,this.from=o,this.to=r}hasResult(){return!0}updateFor(t,e){var i;if(!(3&e))return this.map(t.changes);let n=this.result;n.map&&!t.changes.empty&&(n=n.map(n,t.changes));let o=t.changes.mapPos(this.from),r=t.changes.mapPos(this.to,1),s=j(t.state);if(s>r||!n||2&e&&(j(t.startState)==this.from||s<this.limit))return new ot(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,i,n){if(!t)return!1;let o=e.sliceDoc(i,n);return"function"==typeof t?t(o,i,n,e):A(t,!0).test(o)}(n.validFor,t.state,o,r)?new rt(this.source,this.explicit,l,n,o,r):n.update&&(n=n.update(n,o,r,new T(t.state,s,!1)))?new rt(this.source,this.explicit,l,n,n.from,null!==(i=n.to)&&void 0!==i?i:j(t.state)):new ot(this.source,1,this.explicit)}map(t){if(t.empty)return this;let e=this.result.map?this.result.map(this.result,t):this.result;return e?new rt(this.source,this.explicit,t.mapPos(this.limit),e,t.mapPos(this.from),t.mapPos(this.to,1)):new ot(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const st=o.define({map:(t,e)=>t.map((t=>t.map(e)))}),lt=i.define({create:()=>Y.start(),update:(t,e)=>t.update(e),provide:t=>[y.from(t,(t=>t.tooltip)),w.contentAttributes.from(t,(t=>t.attrs))]});function ct(t,e){const i=e.completion.apply||e.completion.label;let n=t.state.field(lt).active.find((t=>t.source==e.source));return n instanceof rt&&("string"==typeof i?t.dispatch({...F(t.state,i,n.from,n.to),annotations:B.of(e.completion)}):i(t,e.completion,n.from,n.to),!0)}const ut=N(lt,ct);function ht(t,e="option"){return i=>{let n=i.state.field(lt,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<i.state.facet(H).interactionDelay)return!1;let o,r=1;"page"==e&&(o=b(i,n.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+r*(t?1:-1):t?0:s-1;return l<0?l="page"==e?0:s-1:l>=s&&(l="page"==e?s-1:0),i.dispatch({effects:K.of(l)}),!0}}const ft=t=>{let e=t.state.field(lt,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(H).interactionDelay)&&ct(t,e.open.options[e.open.selected])},at=t=>!!t.state.field(lt,!1)&&(t.dispatch({effects:V.of(!0)}),!0),pt=t=>{let e=t.state.field(lt,!1);return!(!e||!e.active.some((t=>0!=t.state))||(t.dispatch({effects:P.of(null)}),0))};class mt{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const dt=g.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(lt).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(lt),i=t.state.facet(H);if(!t.selectionSet&&!t.docChanged&&t.startState.field(lt)==e)return;let n=t.transactions.some((t=>{let e=nt(t,i);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let i=this.running[e];if(n||i.context.abortOnDocChange&&t.docChanged||i.updates.length+t.transactions.length>50&&Date.now()-i.time>1e3){for(let t of i.context.abortListeners)try{t()}catch(t){v(this.view.state,t)}i.context.abortListeners=null,this.running.splice(e--,1)}else i.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(V)))))&&(this.pendingStart=!0);let o=this.pendingStart?50:i.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),o):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(lt);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}startQuery(t){let{state:e}=this.view,i=j(e),n=new T(e,i,t.explicit,this.view),o=new mt(t,n);this.running.push(o),Promise.resolve(t.source(n)).then((t=>{o.context.aborted||(o.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:P.of(null)}),v(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(H).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],i=this.view.state.facet(H),n=this.view.state.field(lt);for(let o=0;o<this.running.length;o++){let r=this.running[o];if(void 0===r.done)continue;if(this.running.splice(o--,1),r.done){let n=j(r.updates.length?r.updates[0].startState:this.view.state),o=Math.min(n,r.done.from+(r.active.explicit?0:1)),s=new rt(r.active.source,r.active.explicit,o,r.done,r.done.from,null!==(t=r.done.to)&&void 0!==t?t:n);for(let t of r.updates)s=s.update(t,i);if(s.hasResult()){e.push(s);continue}}let s=n.active.find((t=>t.source==r.active.source));if(s&&s.isPending)if(null==r.done){let t=new ot(r.active.source,0);for(let e of r.updates)t=t.update(e,i);t.isPending||e.push(t)}else this.startQuery(s)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:st.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(lt,!1);if(e&&e.tooltip&&this.view.state.facet(H).closeOnBlur){let i=e.open&&b(this.view,e.open.tooltip);i&&i.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:P.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:V.of(!1)})),20),this.composing=0}}}),gt="object"==typeof navigator&&/Win/.test(navigator.platform),wt=n.highest(w.domEventHandlers({keydown(t,e){let i=e.state.field(lt,!1);if(!i||!i.open||i.open.disabled||i.open.selected<0||t.key.length>1||t.ctrlKey&&(!gt||!t.altKey)||t.metaKey)return!1;let n=i.open.options[i.open.selected],o=i.active.find((t=>t.source==n.source)),r=n.completion.commitCharacters||o.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&ct(e,n),!1}})),bt=w.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yt{constructor(t,e,i,n){this.field=t,this.line=e,this.from=i,this.to=n}}class vt{constructor(t,e,i){this.field=t,this.from=e,this.to=i}map(t){let e=t.mapPos(this.from,-1,m.TrackDel),i=t.mapPos(this.to,1,m.TrackDel);return null==e||null==i?null:new vt(this.field,e,i)}}class xt{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let i=[],n=[e],o=t.doc.lineAt(e),r=/^\s*/.exec(o.text)[0];for(let o of this.lines){if(i.length){let i=r,s=/^\t*/.exec(o)[0].length;for(let e=0;e<s;e++)i+=t.facet($);n.push(e+i.length-s),o=i+o.slice(s)}i.push(o),e+=o.length+1}let s=this.fieldPositions.map((t=>new vt(t.field,n[t.line]+t.from,n[t.line]+t.to)));return{text:i,ranges:s}}static parse(t){let e,i=[],n=[],o=[];for(let r of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(r);){let t=e[1]?+e[1]:null,s=e[2]||e[3]||"",l=-1;0===t&&(t=1e9);let c=s.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<i.length;e++)(null!=t?i[e].seq==t:c&&i[e].name==c)&&(l=e);if(l<0){let e=0;for(;e<i.length&&(null==t||null!=i[e].seq&&i[e].seq<t);)e++;i.splice(e,0,{seq:t,name:c}),l=e;for(let t of o)t.field>=l&&t.field++}for(let t of o)if(t.line==n.length&&t.from>e.index){let i=e[2]?3+(e[1]||"").length:2;t.from-=i,t.to-=i}o.push(new yt(l,n.length,e.index,e.index+c.length)),r=r.slice(0,e.index)+s+r.slice(e.index+e[0].length)}r=r.replace(/\\([{}])/g,((t,e,i)=>{for(let t of o)t.line==n.length&&t.from>i&&(t.from--,t.to--);return e})),n.push(r)}return new xt(n,o)}}let It=I.widget({widget:new class extends k{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),kt=I.mark({class:"cm-snippetField"});class Mt{constructor(t,e){this.ranges=t,this.active=e,this.deco=I.set(t.map((t=>(t.from==t.to?It:kt).range(t.from,t.to))),!0)}map(t){let e=[];for(let i of this.ranges){let n=i.map(t);if(!n)return null;e.push(n)}return new Mt(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ot=o.define({map:(t,e)=>t&&t.map(e)}),$t=o.define(),Tt=i.define({create:()=>null,update(t,e){for(let i of e.effects){if(i.is(Ot))return i.value;if(i.is($t)&&t)return new Mt(t.ranges,i.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:t=>w.decorations.from(t,(t=>t?t.deco:I.none))});function Et(t,e){return s.create(t.filter((t=>t.field==e)).map((t=>s.range(t.from,t.to))))}function Dt(t){let e=xt.parse(t);return(t,i,n,r)=>{let{text:s,ranges:u}=e.instantiate(t.state,n),{main:h}=t.state.selection,f={changes:{from:n,to:r==h.from?h.to:r,insert:c.of(s)},scrollIntoView:!0,annotations:i?[B.of(i),l.userEvent.of("input.complete")]:void 0};if(u.length&&(f.selection=Et(u,0)),u.some((t=>t.field>0))){let e=new Mt(u,0),i=f.effects=[Ot.of(e)];void 0===t.state.field(Tt,!1)&&i.push(o.appendConfig.of([Tt,Wt,Pt,bt]))}t.dispatch(t.state.update(f))}}function Lt(t){return({state:e,dispatch:i})=>{let n=e.field(Tt,!1);if(!n||t<0&&0==n.active)return!1;let o=n.active+t,r=t>0&&!n.ranges.some((e=>e.field==o+t));return i(e.update({selection:Et(n.ranges,o),effects:Ot.of(r?null:new Mt(n.ranges,o)),scrollIntoView:!0})),!0}}const St=({state:t,dispatch:e})=>!!t.field(Tt,!1)&&(e(t.update({effects:Ot.of(null)})),!0),Ct=Lt(1),jt=Lt(-1);function At(t){let e=t.field(Tt,!1);return!(!e||!e.ranges.some((t=>t.field==e.active+1)))}function Bt(t){let e=t.field(Tt,!1);return!!(e&&e.active>0)}const Ft=[{key:"Tab",run:Ct,shift:jt},{key:"Escape",run:St}],Rt=e.define({combine:t=>t.length?t[0]:Ft}),Wt=n.highest(x.compute([Rt],(t=>t.facet(Rt))));function Vt(t,e){return{...e,apply:Dt(t)}}const Pt=w.domEventHandlers({mousedown(t,e){let i,n=e.state.field(Tt,!1);if(!n||null==(i=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let o=n.ranges.find((t=>t.from<=i&&t.to>=i));return!(!o||o.field==n.active||(e.dispatch({selection:Et(n.ranges,o.field),effects:Ot.of(n.ranges.some((t=>t.field>o.field))?new Mt(n.ranges,o.field):null),scrollIntoView:!0}),0))}});function zt(t,e){return new RegExp(e(t.source),t.unicode?"u":"")}const Ut=Object.create(null);function Ht(t,e,i,n,o){for(let r=t.iterLines(),s=0;!r.next().done;){let t,{value:l}=r;for(e.lastIndex=0;t=e.exec(l);)if(!n[t[0]]&&s+t.index!=o&&(i.push({type:"text",label:t[0]}),n[t[0]]=!0,i.length>=2e3))return;s+=l.length+1}}function _t(t,e,i,n,o){let r=t.length>=1e3,s=r&&e.get(t);if(s)return s;let l=[],c=Object.create(null);if(t.children){let r=0;for(let s of t.children){if(s.length>=1e3)for(let t of _t(s,e,i,n-r,o-r))c[t.label]||(c[t.label]=!0,l.push(t));else Ht(s,i,l,c,o-r);r+=s.length+1}}else Ht(t,i,l,c,o);return r&&l.length<2e3&&e.set(t,l),l}const qt=t=>{var e;let i=null!==(e=t.state.languageDataAt("wordChars",t.pos)[0])&&void 0!==e?e:"",n=function(t){let e=t.replace(/[\]\-\\]/g,"\\$&");try{return new RegExp(`[\\p{Alphabetic}\\p{Number}_${e}]+`,"ug")}catch(t){return new RegExp(`[w${e}]`,"g")}}(i),o=t.matchBefore(zt(n,(t=>t+"$")));if(!o&&!t.explicit)return null;let r=o?o.from:t.pos,s=_t(t.state.doc,function(t){return Ut[t]||(Ut[t]=new WeakMap)}(i),n,5e4,r);return{from:r,options:s,validFor:zt(n,(t=>"^"+t))}},Kt={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Qt=o.define({map(t,e){let i=e.mapPos(t,-1,m.TrackAfter);return null==i?void 0:i}}),Jt=new class extends d{};Jt.startSide=1,Jt.endSide=-1;const Nt=i.define({create:()=>f.empty,update(t,e){if(t=t.map(e.changes),e.selection){let i=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=i.from&&t<=i.to})}for(let i of e.effects)i.is(Qt)&&(t=t.update({add:[Jt.range(i.value,i.value+1)]}));return t}});function Xt(){return[ee,Nt]}const Gt="()[]{}<>«»»«[]{}";function Yt(t){for(let e=0;e<16;e+=2)if(Gt.charCodeAt(e)==t)return Gt.charAt(e+1);return a(t<128?t:t+1)}function Zt(t,e){return t.languageDataAt("closeBrackets",e)[0]||Kt}const te="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),ee=w.inputHandler.of(((t,e,i,n)=>{if((te?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let o=t.state.selection.main;if(n.length>2||2==n.length&&1==h(r(n,0))||e!=o.from||i!=o.to)return!1;let s=oe(t.state,n);return!!s&&(t.dispatch(s),!0)})),ie=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Zt(t,t.selection.main.head).brackets||Kt.brackets,n=null,o=t.changeByRange((e=>{if(e.empty){let n=function(t,e){let i=t.sliceString(e-2,e);return h(r(i,0))==i.length?i:i.slice(1)}(t.doc,e.head);for(let o of i)if(o==n&&se(t.doc,e.head)==Yt(r(o,0)))return{changes:{from:e.head-o.length,to:e.head+o.length},range:s.cursor(e.head-o.length)}}return{range:n=e}}));return n||e(t.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!n},ne=[{key:"Backspace",run:ie}];function oe(t,e){let i=Zt(t,t.selection.main.head),n=i.brackets||Kt.brackets;for(let o of n){let s=Yt(r(o,0));if(e==o)return s==o?ue(t,o,n.indexOf(o+o+o)>-1,i):le(t,o,s,i.before||Kt.before);if(e==s&&re(t,t.selection.main.from))return ce(t,0,s)}return null}function re(t,e){let i=!1;return t.field(Nt).between(0,t.doc.length,(t=>{t==e&&(i=!0)})),i}function se(t,e){let i=t.sliceString(e,e+2);return i.slice(0,h(r(i,0)))}function le(t,e,i,n){let o=null,r=t.changeByRange((r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:i,from:r.to}],effects:Qt.of(r.to+e.length),range:s.range(r.anchor+e.length,r.head+e.length)};let l=se(t.doc,r.head);return!l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+i,from:r.head},effects:Qt.of(r.head+e.length),range:s.cursor(r.head+e.length)}:{range:o=r}}));return o?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function ce(t,e,i){let n=null,o=t.changeByRange((e=>e.empty&&se(t.doc,e.head)==i?{changes:{from:e.head,to:e.head+i.length,insert:i},range:s.cursor(e.head+i.length)}:n={range:e}));return n?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function ue(t,e,i,n){let o=n.stringPrefixes||Kt.stringPrefixes,r=null,l=t.changeByRange((n=>{if(!n.empty)return{changes:[{insert:e,from:n.from},{insert:e,from:n.to}],effects:Qt.of(n.to+e.length),range:s.range(n.anchor+e.length,n.head+e.length)};let l,c=n.head,u=se(t.doc,c);if(u==e){if(he(t,c))return{changes:{insert:e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)};if(re(t,c)){let n=i&&t.sliceDoc(c,c+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+n.length,insert:n},range:s.cursor(c+n.length)}}}else{if(i&&t.sliceDoc(c-2*e.length,c)==e+e&&(l=fe(t,c-2*e.length,o))>-1&&he(t,l))return{changes:{insert:e+e+e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)};if(t.charCategorizer(c)(u)!=p.Word&&fe(t,c,o)>-1&&!function(t,e,i,n){let o=O(t).resolveInner(e,-1),r=n.reduce(((t,e)=>Math.max(t,e.length)),0);for(let s=0;s<5;s++){let s=t.sliceDoc(o.from,Math.min(o.to,o.from+i.length+r)),l=s.indexOf(i);if(!l||l>-1&&n.indexOf(s.slice(0,l))>-1){let e=o.firstChild;for(;e&&e.from==o.from&&e.to-e.from>i.length+l;){if(t.sliceDoc(e.to-i.length,e.to)==i)return!1;e=e.firstChild}return!0}let c=o.to==e&&o.parent;if(!c)break;o=c}return!1}(t,c,e,o))return{changes:{insert:e+e,from:c},effects:Qt.of(c+e.length),range:s.cursor(c+e.length)}}return{range:r=n}}));return r?null:t.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function he(t,e){let i=O(t).resolveInner(e+1);return i.parent&&i.from==e}function fe(t,e,i){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=p.Word)return e;for(let o of i){let i=e-o.length;if(t.sliceDoc(i,e)==o&&n(t.sliceDoc(i-1,i))!=p.Word)return i}return-1}function ae(t={}){return[wt,lt,H.of(t),dt,me,bt]}const pe=[{key:"Ctrl-Space",run:at},{mac:"Alt-`",run:at},{mac:"Alt-i",run:at},{key:"Escape",run:pt},{key:"ArrowDown",run:ht(!0)},{key:"ArrowUp",run:ht(!1)},{key:"PageDown",run:ht(!0,"page")},{key:"PageUp",run:ht(!1,"page")},{key:"Enter",run:ft}],me=n.highest(x.computeN([H],(t=>t.facet(H).defaultKeymap?[pe]:[])));function de(t){let e=t.field(lt,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}const ge=new WeakMap;function we(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;if(!i||i.disabled)return[];let n=ge.get(i.options);return n||ge.set(i.options,n=i.options.map((t=>t.completion))),n}function be(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.options[i.selected].completion:null}function ye(t){var e;let i=null===(e=t.field(lt,!1))||void 0===e?void 0:e.open;return i&&!i.disabled&&i.selected>=0?i.selected:null}function ve(t){return K.of(t)}export{T as CompletionContext,ft as acceptCompletion,ae as autocompletion,St as clearSnippet,Xt as closeBrackets,ne as closeBracketsKeymap,pt as closeCompletion,qt as completeAnyWord,D as completeFromList,pe as completionKeymap,de as completionStatus,we as currentCompletions,ie as deleteBracketPair,At as hasNextSnippetField,Bt as hasPrevSnippetField,L as ifIn,S as ifNotIn,oe as insertBracket,F as insertCompletionText,ht as moveCompletionSelection,Ct as nextSnippetField,B as pickedCompletion,jt as prevSnippetField,be as selectedCompletion,ye as selectedCompletionIndex,ve as setSelectedCompletion,Dt as snippet,Vt as snippetCompletion,Rt as snippetKeymap,at as startCompletion}
@@ -0,0 +1 @@
1
+ import{t,p as s,H as e,c as i,h as r}from"./p-BB4Llg42.js";import{h as a,e as o,i as n,g as c,v as h}from"./p-BYhtwUM4.js";import{a as f}from"./p-bZPtT8wr.js";import{g as d}from"./p-gPc0o8Jb.js";import{registerDefaultBricks as l}from"./index.js";import{d as p}from"./p-BerMKKKo.js";import{d as m}from"./p-NDbmiiYk.js";import{d as u}from"./p-Cg-VvkW4.js";import{d as k}from"./p-CKAZ15-B.js";import{d as b}from"./p-DyI9tTC9.js";import{d as j}from"./p-BnxDCFjv.js";import{d as v}from"./p-DQKpUpzo.js";import{d as g}from"./p-BQIUKz-H.js";import{d as E}from"./p-hELMtJ9v.js";import{d as S}from"./p-DtO4LFLi.js";import{d as O}from"./p-C3SjLyf4.js";const y=s(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.formDataChange=i(this,"formDataChange"),this.formSubmit=i(this,"formSubmit"),this.editable=!1,this.currentData={},this.touched={},this.expanding=!1,this.utils={validateForm:()=>({isValid:this.runValidation().valid})}}componentWillLoad(){return 0===d().length&&l(),this.currentData=Object.assign({},this.data),this.runExpansion()}syncData(t){this.currentData=Object.assign({},t)}onSpecChange(){this.runExpansion()}effectiveSpec(){var t;return null!==(t=this.expandedSpec)&&void 0!==t?t:this.spec}async runExpansion(){if(this.expandError=void 0,this.editable||!a(this.spec))return void(this.expandedSpec=void 0);const t=this.spec;this.expanding=!0;try{const s=await o(t);this.spec===t&&(this.expandedSpec=s)}catch(s){this.spec===t&&(this.expandedSpec=void 0,this.expandError=s instanceof Error?s.message:String(s))}finally{this.spec===t&&(this.expanding=!1)}}publicData(){return Object.fromEntries(Object.entries(this.currentData).filter((([t])=>!t.startsWith("_"))))}handleBrickDataChange(t){t.stopPropagation(),this.currentData=this.applyValueEffects(Object.assign(Object.assign({},this.currentData),t.detail));const s=Object.assign({},this.touched);for(const e of Object.keys(t.detail))s[e]=!0;this.touched=s;const{valid:e,errors:i}=this.runValidation();this.formDataChange.emit({data:this.publicData(),isValid:e,errors:i})}applyValueEffects(t){var s,e;let i=t;for(const{brick:t}of n(this.effectiveSpec())){const r=null===(s=t.configs)||void 0===s?void 0:s.key;if(!r||!(null===(e=t.rules)||void 0===e?void 0:e.length))continue;const a=c(t.rules,i);void 0!==a.value&&i[r]!==a.value&&(i=Object.assign(Object.assign({},i),{[r]:a.value}))}return i}async validate(){var t;const s={};for(const{brick:e}of n(this.effectiveSpec())){const i=null===(t=e.configs)||void 0===t?void 0:t.key;i&&(s[i]=!0)}this.touched=s;const e=this.runValidation(),i=Object.assign({},e.errors);let r=e.valid;const a=Array.from(this.host.querySelectorAll("fk-data-grid"));for(const t of a){const s=await t.validateRows();r=r&&s.valid,Object.assign(i,s.errors)}const o={valid:r,errors:i};return this.formDataChange.emit({data:this.publicData(),isValid:o.valid,errors:o.errors}),o}handleStepTouch(t){t.stopPropagation();const s=Object.assign({},this.touched);for(const e of t.detail.keys)s[e]=!0;this.touched=s}async handleStepperSubmit(t){t.stopPropagation();const s=await this.validate();this.formSubmit.emit({data:this.publicData(),isValid:s.valid,errors:s.errors})}runValidation(){const t=Object.fromEntries(Object.entries(this.currentData).filter((([,t])=>""!==t&&null!=t)));return h(this.effectiveSpec(),t,this.locale)}visibleErrors(){if(this.editable)return{};const t={};for(const[s,e]of Object.entries(this.runValidation().errors))this.touched[s]&&(t[s]=e);return t}render(){return this.spec?this.expanding?r("p",{class:"fk-form__expanding"},f("nestedForm.loading")):r("form",{class:"fk-form",onSubmit:t=>t.preventDefault()},this.expandError?r("span",{class:"fk-field__error",role:"alert"},this.expandError):null,r("fk-brick-render",{brickSpec:this.effectiveSpec(),rootSpec:this.effectiveSpec(),data:this.currentData,dataMap:this.currentData,errors:this.visibleErrors(),locale:this.locale,path:"0",editable:this.editable,selectedUid:this.selectedUid,utils:this.utils})):null}get host(){return this}static get watchers(){return{data:[{syncData:0}],spec:[{onSpecChange:0}]}}static get style(){return".fk-form.sc-fk-form-render{display:flex;flex-direction:column;gap:var(--fk-spacing);font-family:var(--fk-font);color:var(--fk-color-text)}"}},[2,"fk-form-render",{spec:[16],data:[16],editable:[4],selectedUid:[1,"selected-uid"],locale:[1],currentData:[32],touched:[32],expandedSpec:[32],expanding:[32],expandError:[32],validate:[64]},[[0,"brickDataChange","handleBrickDataChange"],[0,"stepTouch","handleStepTouch"],[0,"stepperSubmit","handleStepperSubmit"]],{data:[{syncData:0}],spec:[{onSpecChange:0}]}]);function D(){"undefined"!=typeof customElements&&["fk-form-render","fk-brick-actions","fk-brick-not-found","fk-brick-render","fk-code-editor","fk-data-grid","fk-drop-area","fk-file-input","fk-select-input","fk-signature-input","fk-stepper","fk-tabs"].forEach((s=>{switch(s){case"fk-form-render":customElements.get(t(s))||customElements.define(t(s),y);break;case"fk-brick-actions":customElements.get(t(s))||p();break;case"fk-brick-not-found":customElements.get(t(s))||m();break;case"fk-brick-render":customElements.get(t(s))||u();break;case"fk-code-editor":customElements.get(t(s))||k();break;case"fk-data-grid":customElements.get(t(s))||b();break;case"fk-drop-area":customElements.get(t(s))||j();break;case"fk-file-input":customElements.get(t(s))||v();break;case"fk-select-input":customElements.get(t(s))||g();break;case"fk-signature-input":customElements.get(t(s))||E();break;case"fk-stepper":customElements.get(t(s))||S();break;case"fk-tabs":customElements.get(t(s))||O()}}))}D();export{y as F,D as d}
@@ -0,0 +1 @@
1
+ import{t,p as e,H as s,c as i,h as o}from"./p-BB4Llg42.js";import{s as r,o as c}from"./p-BYhtwUM4.js";import{n}from"./p-CyZA17qf.js";import{a}from"./p-bZPtT8wr.js";function l(t,e){return t.replace(/\{(\w+)\}/g,((t,s)=>{const i=null==e?void 0:e[s];return null==i?"":String(i)}))}let h=0;const f=e(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.selectValueChange=i(this,"selectValueChange"),this.disabled=!1,this.multiple=!1,this.invalid=!1,this.open=!1,this.query="",this.activeIndex=0,this.instanceId="fk-select-"+ ++h,this.remoteOptions=[],this.catalogOptions=[],this.outsideClick=t=>{this.host.contains(t.target)||this.close()},this.onTriggerKeyDown=t=>{this.disabled||(["Enter"," ","ArrowDown","ArrowUp"].includes(t.key)?(t.preventDefault(),this.openDropdown()):"Escape"===t.key&&this.open&&(t.preventDefault(),this.close()))}}componentWillLoad(){return Promise.all([this.resolveRemote(),this.resolveCatalog()])}disconnectedCallback(){this.unbindOutsideClick()}onConfigsChange(){this.resolveRemote(),this.resolveCatalog()}onDataMapChange(){this.resolveRemote()}searchParam(){var t;return(null===(t=this.configs)||void 0===t?void 0:t.searchParam)||void 0}remoteUrl(){var t;const e=null===(t=this.configs)||void 0===t?void 0:t.optionsUrl;if(!e)return;let s=l(e,this.dataMap);const i=this.searchParam();return i&&(s=function(t,e,s){if(!s)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${encodeURIComponent(e)}=${encodeURIComponent(s)}`}(s,i,this.query.trim())),s}bindOutsideClick(){document.addEventListener("mousedown",this.outsideClick)}unbindOutsideClick(){document.removeEventListener("mousedown",this.outsideClick)}toggleOpen(){this.disabled||(this.open?this.close():this.openDropdown())}openDropdown(){if(this.disabled||this.open)return;this.open=!0,this.query="";const{options:t}=this.resolve(),e=this.selectedValues(),s=t.findIndex((t=>e.includes(t.value)));this.activeIndex=s>=0?s:0,this.bindOutsideClick()}close(t=!1){var e;this.open=!1,this.unbindOutsideClick(),t&&(null===(e=this.triggerEl)||void 0===e||e.focus())}moveActive(t,e){e&&(this.activeIndex=(this.activeIndex+t+e)%e,this.scrollActiveIntoView())}scrollActiveIntoView(){requestAnimationFrame((()=>{var t;const e=this.host.querySelector(`#${this.instanceId}-opt-${this.activeIndex}`);null===(t=null==e?void 0:e.scrollIntoView)||void 0===t||t.call(e,{block:"nearest"})}))}onSearchKeyDown(t,e){var s;switch(t.key){case"ArrowDown":t.preventDefault(),this.moveActive(1,e.length);break;case"ArrowUp":t.preventDefault(),this.moveActive(-1,e.length);break;case"Home":t.preventDefault(),this.activeIndex=0,this.scrollActiveIntoView();break;case"End":t.preventDefault(),this.activeIndex=Math.max(e.length-1,0),this.scrollActiveIntoView();break;case"Enter":{t.preventDefault();const i=null!==(s=e[this.activeIndex])&&void 0!==s?s:e[0];i&&this.pick(i);break}case"Escape":t.preventDefault(),this.close(!0);break;case"Tab":this.close()}}source(){var t,e;return null!==(e=null===(t=this.configs)||void 0===t?void 0:t.optionsSource)&&void 0!==e?e:"static"}async resolveRemote(t=!1){var e;if("remote"!==this.source())return;const s=this.remoteUrl();if(!s)return void(this.remoteOptions=[]);const i=function(t,e){if("string"!=typeof t||!t.trim())return;const s={};for(const i of t.split("\n")){const t=i.indexOf(":");if(t<=0)continue;const o=i.slice(0,t).trim(),r=l(i.slice(t+1).trim(),e);o&&(s[o]=r)}return Object.keys(s).length?s:void 0}(null===(e=this.configs)||void 0===e?void 0:e.optionsHeaders,this.dataMap),o=`${s}|${JSON.stringify(null!=i?i:{})}`;if(t||o!==this.lastRemoteSignature){this.lastRemoteSignature=o;try{this.remoteError=void 0,this.remoteOptions=await r.dataSourceService.fetchOptions(s,i?{headers:i}:void 0)}catch(t){this.remoteOptions=[],this.remoteError=t instanceof Error?t.message:String(t)}}}async resolveCatalog(t=!1){var e;if("catalog"!==this.source())return;const s=(null===(e=this.configs)||void 0===e?void 0:e.optionsRef)||"";if(s){if(t||s!==this.lastCatalogRef){this.lastCatalogRef=s;try{this.catalogError=void 0,this.catalogOptions=await r.optionSourceService.fetchOptions(s)}catch(t){this.catalogOptions=[],this.catalogError=t instanceof Error?t.message:String(t)}}}else this.catalogOptions=[]}onSearchInput(t){this.query=t,"remote"===this.source()&&this.searchParam()&&(this.searchTimer&&clearTimeout(this.searchTimer),this.searchTimer=setTimeout((()=>this.resolveRemote()),250))}resolve(){var t,e,s,i,o,r;const a=(null===(t=this.configs)||void 0===t?void 0:t.labelKey)||void 0,l=(null===(e=this.configs)||void 0===e?void 0:e.valueKey)||void 0;switch(this.source()){case"remote":return{options:n(this.remoteOptions,a,l),error:this.remoteError};case"catalog":return{options:n(this.catalogOptions,a,l),error:this.catalogError};case"dataMap":{const t=null===(s=this.configs)||void 0===s?void 0:s.optionsPath;return{options:n(t?null===(i=this.dataMap)||void 0===i?void 0:i[t]:[],a,l)}}case"js":{const t=null===(o=this.configs)||void 0===o?void 0:o.optionsCode;if(!t)return{options:[]};const e=c(t,this.dataMap);return e instanceof Error?{options:[],error:e.message}:{options:n(e,a,l)}}default:return{options:n(null===(r=this.configs)||void 0===r?void 0:r.options,a,l)}}}selectedValues(){return this.multiple?Array.isArray(this.value)?this.value:[]:"string"==typeof this.value&&""!==this.value?[this.value]:[]}labelOf(t,e){var s,i;return null!==(i=null===(s=e.find((e=>e.value===t)))||void 0===s?void 0:s.label)&&void 0!==i?i:t}pick(t){if(this.multiple){const e=this.selectedValues(),s=e.includes(t.value)?e.filter((e=>e!==t.value)):[...e,t.value];this.selectValueChange.emit(s.length?s:void 0)}else this.selectValueChange.emit(t.value),this.close(!0)}unpick(t){const e=this.selectedValues().filter((e=>e!==t));this.selectValueChange.emit(e.length?e:void 0)}filteredOptions(t){if("remote"===this.source()&&this.searchParam())return t;const e=this.query.trim().toLowerCase();return e?t.filter((t=>t.label.toLowerCase().includes(e))):t}render(){var t,e;const{options:s,error:i}=this.resolve(),r=this.selectedValues(),c=this.filteredOptions(s);return o("div",{key:"722b60f2b74f28ea5144caa4583241527713a942",class:{"fk-select":!0,"fk-select--disabled":this.disabled}},o("div",{key:"61729fc2e4132ef77b67e16793885f94a2d8a3d1",class:{"fk-select__trigger":!0,"fk-select__trigger--open":this.open},role:"combobox",tabIndex:this.disabled?void 0:0,"aria-expanded":this.open?"true":"false","aria-haspopup":"listbox","aria-controls":`${this.instanceId}-listbox`,"aria-disabled":this.disabled?"true":void 0,"aria-invalid":this.invalid?"true":void 0,ref:t=>this.triggerEl=t,onKeyDown:this.onTriggerKeyDown,onClick:t=>{t.preventDefault(),this.toggleOpen()}},o("div",{key:"06348e66c55be81bc530ccacc6c27864db65f738",class:"fk-select__values"},0===r.length?o("span",{class:"fk-select__placeholder"},String(null!==(e=null===(t=this.configs)||void 0===t?void 0:t.placeholder)&&void 0!==e?e:"")):this.multiple?r.map((t=>o("span",{class:"fk-select__chip",key:t},this.labelOf(t,s),o("button",{type:"button",class:"fk-select__chip-remove","aria-label":`${a("select.clear")} — ${this.labelOf(t,s)}`,disabled:this.disabled,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.unpick(t)}},"✕")))):o("span",{class:"fk-select__value"},this.labelOf(r[0],s))),!this.multiple&&r.length>0&&!this.disabled?o("button",{type:"button",class:"fk-select__clear",title:a("select.clear"),"aria-label":a("select.clear"),onClick:t=>{t.preventDefault(),t.stopPropagation(),this.selectValueChange.emit(void 0)}},"✕"):null,o("span",{key:"2da7c04d33b677c508d62f14cfcad6896c8babdb",class:"fk-select__caret"},"▾")),this.open?o("div",{class:"fk-select__dropdown"},o("input",{class:"fk-select__search",type:"text",placeholder:a("select.search"),value:this.query,role:"combobox","aria-expanded":"true","aria-autocomplete":"list","aria-controls":`${this.instanceId}-listbox`,"aria-activedescendant":c.length?`${this.instanceId}-opt-${Math.min(this.activeIndex,c.length-1)}`:void 0,ref:t=>setTimeout((()=>null==t?void 0:t.focus()),0),onInput:t=>{this.activeIndex=0,this.onSearchInput(t.target.value)},onKeyDown:t=>this.onSearchKeyDown(t,c)}),o("div",{class:"fk-select__options",role:"listbox",id:`${this.instanceId}-listbox`,"aria-multiselectable":this.multiple?"true":void 0},c.map(((t,e)=>{const s=r.includes(t.value),i=e===Math.min(this.activeIndex,c.length-1);return o("div",{key:t.value,id:`${this.instanceId}-opt-${e}`,role:"option","aria-selected":s?"true":"false",class:{"fk-select__option":!0,"fk-select__option--selected":s,"fk-select__option--active":i},onMouseEnter:()=>this.activeIndex=e,onClick:e=>{e.preventDefault(),this.pick(t)}},o("span",{class:"fk-select__option-label"},t.label),s?o("span",{class:"fk-select__check"},"✓"):null)})),0===c.length?o("p",{class:"fk-select__empty"},a("select.empty")):null)):null,i?o("span",{class:"fk-field__error"},i):null)}get host(){return this}static get watchers(){return{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}}static get style(){return".sc-fk-select-input-h{display:block}.fk-select.sc-fk-select-input{position:relative;font-family:var(--fk-font)}.fk-select__trigger.sc-fk-select-input{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);min-height:38px;padding:calc(var(--fk-spacing) / 2) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);color:var(--fk-color-text);cursor:pointer}.fk-select--disabled.sc-fk-select-input .fk-select__trigger.sc-fk-select-input{cursor:not-allowed;opacity:0.6}.fk-select__trigger--open.sc-fk-select-input{border-color:var(--fk-color-primary)}.fk-select__values.sc-fk-select-input{display:flex;flex:1;flex-wrap:wrap;align-items:center;gap:4px;min-width:0;font-size:0.9rem}.fk-select__placeholder.sc-fk-select-input{color:var(--fk-color-muted)}.fk-select__chip.sc-fk-select-input{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:color-mix(in srgb, var(--fk-color-primary) 14%, transparent);color:var(--fk-color-primary);font-size:0.8rem;font-weight:600}.fk-select__chip-remove.sc-fk-select-input,.fk-select__clear.sc-fk-select-input{border:none;background:transparent;color:inherit;font-size:0.7rem;cursor:pointer;padding:0 2px}.fk-select__clear.sc-fk-select-input{color:var(--fk-color-muted)}.fk-select__clear.sc-fk-select-input:hover{color:var(--fk-color-danger)}.fk-select__caret.sc-fk-select-input{color:var(--fk-color-muted);font-size:0.8rem}.fk-select__dropdown.sc-fk-select-input{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:20;display:flex;flex-direction:column;border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);box-shadow:0 8px 24px var(--fk-color-shadow);overflow:hidden}.fk-select__search.sc-fk-select-input{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:none;border-bottom:1px solid var(--fk-color-border);background:transparent;color:var(--fk-color-text)}.fk-select__search.sc-fk-select-input:focus{outline:none}.fk-select__options.sc-fk-select-input{max-height:220px;overflow-y:auto}.fk-select__option.sc-fk-select-input{display:flex;align-items:center;justify-content:space-between;gap:var(--fk-spacing);padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);font-size:0.9rem;color:var(--fk-color-text);cursor:pointer}.fk-select__option.sc-fk-select-input:hover{background:color-mix(in srgb, var(--fk-color-primary) 8%, transparent)}.fk-select__option--selected.sc-fk-select-input{color:var(--fk-color-primary);font-weight:600}.fk-select__check.sc-fk-select-input{font-size:0.8rem}.fk-select__empty.sc-fk-select-input{margin:0;padding:var(--fk-spacing);font-size:0.85rem;color:var(--fk-color-muted)}.fk-select__trigger.sc-fk-select-input:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:1px}.fk-select__option--active.sc-fk-select-input{background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent)}"}},[2,"fk-select-input",{configs:[16],value:[1],disabled:[4],multiple:[4],invalid:[4],dataMap:[16],open:[32],query:[32],activeIndex:[32],remoteOptions:[32],remoteError:[32],catalogOptions:[32],catalogError:[32]},void 0,{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}]);function p(){"undefined"!=typeof customElements&&["fk-select-input"].forEach((e=>{"fk-select-input"===e&&(customElements.get(t(e))||customElements.define(t(e),f))}))}p();export{f as F,p as d}