@streamline-pulse/formkrafter-wc 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/fk-brick-actions.js +1 -1
- package/dist/components/fk-brick-list.js +1 -1
- package/dist/components/fk-brick-mold-item.js +1 -1
- package/dist/components/fk-brick-render.js +1 -1
- package/dist/components/fk-data-grid.js +1 -1
- package/dist/components/fk-drop-area.js +1 -1
- package/dist/components/fk-empty-form.js +1 -1
- package/dist/components/fk-file-input.js +1 -1
- package/dist/components/fk-form-builder.js +1 -1
- package/dist/components/fk-form-render.js +1 -1
- package/dist/components/fk-property-panel.js +1 -1
- package/dist/components/fk-rules-editor.js +1 -1
- package/dist/components/fk-select-input.js +1 -1
- package/dist/components/fk-signature-input.js +1 -1
- package/dist/components/fk-stepper.js +1 -1
- package/dist/components/fk-tabs.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-JT4AVM1_.js → p-0UQyDytv.js} +1 -1
- package/dist/components/{p-D0G27_qv.js → p-BkcBLAy2.js} +1 -1
- package/dist/components/{p-3k7nsf8K.js → p-C27Ugg5w.js} +1 -1
- package/dist/components/{p-CFawKWTg.js → p-CXcUBluz.js} +1 -1
- package/dist/components/{p-Dwn3-r7C.js → p-Cbo49FkV.js} +1 -1
- package/dist/components/{p-BCAjsZWJ.js → p-CklRGLi-.js} +1 -1
- package/dist/components/p-CmDfUtL0.js +1 -0
- package/dist/components/{p-CWR2Oy6I.js → p-Cpoa9o41.js} +1 -1
- package/dist/{formkrafter-wc/p-Dl2ITHd-.js → components/p-D-OAiqMz.js} +1 -1
- package/dist/components/{p-BvH65vdN.js → p-DQOj2f1u.js} +1 -1
- package/dist/components/{p-BTrNR16V.js → p-DQze3kH7.js} +1 -1
- package/dist/components/{p-DoO04Bl8.js → p-Dlcu0-Vy.js} +1 -1
- package/dist/components/{p-oK0mdxPy.js → p-DuLXKZfv.js} +1 -1
- package/dist/components/{p-BdU0U-qf.js → p-iAHgMGIP.js} +1 -1
- package/dist/components/{p-CNAEYR22.js → p-jixbXQf3.js} +1 -1
- package/dist/formkrafter-wc/formkrafter-wc.esm.js +1 -1
- package/dist/formkrafter-wc/index.esm.js +1 -1
- package/dist/formkrafter-wc/{p-5bf42ca0.entry.js → p-358987e3.entry.js} +1 -1
- package/dist/{components/p-BMsyIQcd.js → formkrafter-wc/p-BrSkjQut.js} +1 -1
- package/dist/formkrafter-wc/p-a512a9f1.entry.js +1 -0
- package/dist/types/components/fk-brick-list/fk-brick-list.d.ts +1 -0
- package/dist/types/components/fk-form-builder/fk-form-builder.d.ts +1 -0
- package/dist/types/components/fk-property-panel/fk-property-panel.d.ts +1 -0
- package/dist/types/components.d.ts +15 -2
- package/package.json +2 -2
- package/dist/components/p-CfJnlQZK.js +0 -1
- package/dist/formkrafter-wc/p-113e0e29.entry.js +0 -1
|
@@ -9,4 +9,4 @@ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"de
|
|
|
9
9
|
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
10
10
|
* (c) 2017-2021 Joachim Wester
|
|
11
11
|
* MIT license
|
|
12
|
-
*/function ws(t,e){e.unobserve()}function bs(t,e){var i,r=function(t){return ys.get(t)}(t);if(r){var n=function(t,e){return t.observers.get(e)}(r,e);i=n&&n.observer}else r=new gs(t),ys.set(t,r);if(i)return i;if(i={},r.value=Xn(t),e){i.callback=e,i.next=null;var s=function(){_s(i)},o=function(){clearTimeout(i.next),i.next=setTimeout(s)};"undefined"!=typeof window&&(window.addEventListener("mouseup",o),window.addEventListener("keyup",o),window.addEventListener("mousedown",o),window.addEventListener("keydown",o),window.addEventListener("change",o))}return i.patches=[],i.object=t,i.unobserve=function(){_s(i),clearTimeout(i.next),function(t,e){t.observers.delete(e.callback)}(r,i),"undefined"!=typeof window&&(window.removeEventListener("mouseup",o),window.removeEventListener("keyup",o),window.removeEventListener("mousedown",o),window.removeEventListener("keydown",o),window.removeEventListener("change",o))},r.observers.set(e,new $s(e,i)),i}function _s(t,e){void 0===e&&(e=!1);var i=ys.get(t.object);Es(i.value,t.object,t.patches,"",e),t.patches.length&&fs(i.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Es(t,e,i,r,n){if(e!==t){"function"==typeof e.toJSON&&(e=e.toJSON());for(var s=Qn(e),o=Qn(t),a=!1,h=o.length-1;h>=0;h--){var u=t[f=o[h]];if(!Yn(e,f)||void 0===e[f]&&void 0!==u&&!1===Array.isArray(e))Array.isArray(t)===Array.isArray(e)?(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"remove",path:r+"/"+es(f)}),a=!0):(n&&i.push({op:"test",path:r,value:t}),i.push({op:"replace",path:r,value:e}));else{var c=e[f];"object"==typeof u&&null!=u&&"object"==typeof c&&null!=c&&Array.isArray(u)===Array.isArray(c)?Es(u,c,i,r+"/"+es(f),n):u!==c&&(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"replace",path:r+"/"+es(f),value:Xn(c)}))}}if(a||s.length!=o.length)for(h=0;h<s.length;h++){var f;Yn(t,f=s[h])||void 0===e[f]||i.push({op:"add",path:r+"/"+es(f),value:Xn(e[f])})}}}function ks(t,e,i){void 0===i&&(i=!1);var r=[];return Es(t,e,r,"",i),r}var Ss=Object.assign({},vs,Object.freeze({__proto__:null,compare:ks,generate:_s,observe:bs,unobserve:ws}),{JsonPatchError:ss,deepClone:Xn,escapePathComponent:es,unescapePathComponent:is}),xs=Object.freeze({__proto__:null,JsonPatchError:ss,_areEquals:ms,applyOperation:cs,applyPatch:fs,applyReducer:ls,compare:ks,deepClone:Xn,default:Ss,escapePathComponent:es,generate:_s,getValueByPointer:us,observe:bs,unescapePathComponent:is,unobserve:ws,validate:ps,validator:ds});function Os(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&Object.keys(t).length>0&&Object.values(t).every((t=>"string"==typeof t))}function js(t,e){return Os(t)?e&&void 0!==t[e]?t[e]:Object.values(t)[0]:t}function Ps(t,e){if(!t)return t;const i={};for(const[r,n]of Object.entries(t))i[r]=js(n,e);return i}var Is={en:{required:"This field is required",minLength:"Must be at least {value} characters",maxLength:"Must be at most {value} characters",min:"Must be at least {value}",max:"Must be at most {value}",pattern:"Invalid format",minItems:"Select at least {value} item(s)",maxItems:"Select at most {value} item(s)",email:"Invalid email address",url:"Invalid URL",type:"Invalid value",custom:"Invalid value"},fr:{required:"Ce champ est obligatoire",minLength:"Minimum {value} caractères",maxLength:"Maximum {value} caractères",min:"Minimum {value}",max:"Maximum {value}",pattern:"Format invalide",minItems:"Sélectionnez au moins {value} élément(s)",maxItems:"Sélectionnez au plus {value} élément(s)",email:"Adresse email invalide",url:"URL invalide",type:"Valeur invalide",custom:"Valeur invalide"}};function Cs(t,e,i){return((Is[e??"en"]??Is.en)[t]??Is.en[t]??"Invalid value").replace("{value}",String(i??""))}function*As(t,e="0"){if(t){yield{brick:t,path:e};for(const[i,r]of(t.children??[]).entries())yield*As(r,`${e}.${i}`)}}function*Ns(t){if(t&&(yield t,"collection"!==t.type))for(const e of t.children??[])yield*Ns(e)}function Ts(t,e){if(t.configs?.key&&e)return t.unWrapData?e:e[t.configs.key]}function Ms(t,e){if(t.configs?.key)return t.unWrapData?e:{[t.configs.key]:e}}var Rs=(t,e)=>{if(!e.includes("."))return t[e];let i=t;for(const t of e.split(".")){if("object"!=typeof i||null===i)return;i=i[t]}return i};function Ds(t,e="label",i="value"){return Array.isArray(t)?t.map((t=>{if("object"==typeof t&&null!==t){const r=t,n=Rs(r,e)??Rs(r,i),s=Rs(r,i)??Rs(r,e);return{label:String(n??""),value:String(s??"")}}return{label:String(t),value:String(t)}})).filter((t=>""!==t.label)):String(t??"").split("\n").map((t=>t.trim())).filter(Boolean).map((t=>({label:t,value:t})))}var Ls={"palette.search":"Search bricks…","palette.empty":"No brick matches “{query}”","builder.undo":"Undo","builder.redo":"Redo","builder.editLocale":"Editing language","builder.copyJson":"Copy JSON","builder.importJson":"Import JSON","builder.importInvalid":"Invalid form JSON","builder.pasteHint":"Press Ctrl+V to paste a spec","builder.copied":"Copied!","builder.downloadJson":"Download .json","builder.hint":"Select a brick to edit its properties","drop.hint":"Drop a brick here","empty.title":"Your form is empty","empty.hint":"Drag a brick from the palette to get started","actions.move":"Move","actions.duplicate":"Duplicate","actions.delete":"Delete","stepper.back":"← Back","stepper.next":"Next →","stepper.submit":"Submit","panel.cfg.validateSteps":"Validate each step","panel.cfg.allowStepClick":"Allow clicking steps to jump","panel.cfg.showSubmit":"Submit button on last step","panel.cfg.validateTabs":"Validate tab before leaving it","signature.clear":"Clear","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Rules","panel.key":"Key","panel.label":"Label","panel.placeholder":"Placeholder","panel.prefix":"Prefix","panel.suffix":"Suffix","panel.accept":"Accepted file types","panel.mask":"Input mask (9=digit, a=letter, *=any)","panel.uploadUrl":"Upload URL","panel.cfg.multiple":"Allow multiple files","panel.optionsSource":"Options source","panel.options":"Options (one per line)","panel.content":"Content","panel.dataKey":"Data key","panel.url":"URL","panel.headers":"Headers ({token} reads form data)","panel.searchParam":"Server search param","panel.labelKey":"Label key","panel.valueKey":"Value key","panel.errorMessage":"Error message","panel.required":"Required","panel.minLength":"Min length","panel.maxLength":"Max length","panel.min":"Min","panel.max":"Max","panel.pattern":"Pattern (regex)","panel.minItems":"Min items","panel.maxItems":"Max items","panel.emailFormat":"Email format","panel.urlFormat":"URL format","panel.custom":"Custom (JavaScript)","panel.fallbackMessage":"Fallback message","panel.styleProperty":"property","panel.styleValue":"value","file.choose":"Choose a file…","file.uploading":"Uploading…","file.remove":"Remove file","file.addAnother":"+ Add a file","address.street":"Street","address.city":"City","address.zip":"Postal code","address.country":"Country","grid.addRow":"+ Add row","grid.moveUp":"Move row up","grid.moveDown":"Move row down","grid.removeRow":"Remove row","grid.empty":"No rows yet","grid.columns":"Row template","select.search":"Search…","select.empty":"No options","select.clear":"Clear","rules.when":"When","rules.then":"Then","rules.addRule":"+ Add rule","rules.addEffect":"+ Effect","rules.removeRule":"Remove rule","rules.removeEffect":"Remove effect","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Inputs","category.Layout":"Layout","category.Data":"Data","brick.text.name":"Text","brick.email.name":"Email","brick.password.name":"Password","brick.url.name":"URL","brick.phone.name":"Phone","brick.textarea.name":"Text area","brick.number.name":"Number","brick.date.name":"Date","brick.time.name":"Time","brick.datetime.name":"Date / Time","brick.select.name":"Select","brick.multi-select.name":"Multi select","brick.radio.name":"Radio","brick.select-boxes.name":"Select boxes","brick.checkbox.name":"Checkbox","brick.tags.name":"Tags","brick.signature.name":"Signature","brick.data-grid.name":"Data grid","brick.address.name":"Address","brick.file.name":"File","brick.hidden.name":"Hidden","brick.content.name":"Content","brick.recap.name":"Recap","brick.nested-form.name":"Nested form","brick.code.name":"Code","nestedForm.ref":"Referenced form","nestedForm.missing":"Set the specRef config to reference a form.","nestedForm.loading":"Loading nested forms…","panel.specRef":"Referenced form (specRef)","panel.optionsRef":"Options catalog (optionsRef)","recap.empty":"Nothing to summarize yet.","recap.yes":"Yes","recap.no":"No","panel.cfg.showEmpty":"Show empty fields","panel.cfg.groupBySections":"Group by section","brick.group.name":"Group","brick.row.name":"Row","brick.column.name":"Column","brick.stepper.name":"Stepper","brick.tabs.name":"Tabs"},zs={"palette.search":"Rechercher une brique…","palette.empty":"Aucune brique ne correspond à « {query} »","builder.undo":"Annuler","builder.editLocale":"Langue d'édition","builder.redo":"Rétablir","builder.copyJson":"Copier le JSON","builder.importJson":"Importer le JSON","builder.importInvalid":"JSON de formulaire invalide","builder.pasteHint":"Collez avec Ctrl+V pour importer une spec","builder.copied":"Copié !","builder.downloadJson":"Télécharger le .json","builder.hint":"Sélectionnez une brique pour éditer ses propriétés","drop.hint":"Déposez une brique ici","empty.title":"Votre formulaire est vide","empty.hint":"Glissez une brique depuis la palette pour commencer","actions.move":"Déplacer","actions.duplicate":"Dupliquer","actions.delete":"Supprimer","stepper.back":"← Précédent","stepper.next":"Suivant →","stepper.submit":"Envoyer","panel.cfg.validateSteps":"Valider chaque étape","panel.cfg.allowStepClick":"Autoriser le saut d’étapes au clic","panel.cfg.showSubmit":"Bouton d’envoi à la dernière étape","panel.cfg.validateTabs":"Valider l’onglet avant de le quitter","signature.clear":"Effacer","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Règles","panel.key":"Clé","panel.label":"Libellé","panel.placeholder":"Placeholder","panel.prefix":"Préfixe","panel.suffix":"Suffixe","panel.accept":"Types de fichiers acceptés","panel.mask":"Masque de saisie (9=chiffre, a=lettre, *=tout)","panel.uploadUrl":"URL d'upload","panel.cfg.multiple":"Autoriser plusieurs fichiers","panel.optionsSource":"Source des options","panel.options":"Options (une par ligne)","panel.content":"Contenu","panel.dataKey":"Clé de données","panel.url":"URL","panel.headers":"En-têtes ({token} lit les données du formulaire)","panel.searchParam":"Paramètre de recherche serveur","panel.labelKey":"Clé du libellé","panel.valueKey":"Clé de la valeur","panel.errorMessage":"Message d'erreur","panel.required":"Obligatoire","panel.minLength":"Longueur min","panel.maxLength":"Longueur max","panel.min":"Min","panel.max":"Max","panel.pattern":"Motif (regex)","panel.minItems":"Éléments min","panel.maxItems":"Éléments max","panel.emailFormat":"Format email","panel.urlFormat":"Format URL","panel.custom":"Personnalisé (JavaScript)","panel.fallbackMessage":"Message par défaut","panel.styleProperty":"propriété","panel.styleValue":"valeur","file.choose":"Choisir un fichier…","file.uploading":"Envoi en cours…","file.remove":"Retirer le fichier","file.addAnother":"+ Ajouter un fichier","address.street":"Rue","address.city":"Ville","address.zip":"Code postal","address.country":"Pays","grid.addRow":"+ Ajouter une ligne","grid.moveUp":"Monter la ligne","grid.moveDown":"Descendre la ligne","grid.removeRow":"Supprimer la ligne","grid.empty":"Aucune ligne","grid.columns":"Modèle de ligne","select.search":"Rechercher…","select.empty":"Aucune option","select.clear":"Effacer","rules.when":"Quand","rules.then":"Alors","rules.addRule":"+ Ajouter une règle","rules.addEffect":"+ Effet","rules.removeRule":"Supprimer la règle","rules.removeEffect":"Supprimer l'effet","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Champs","category.Layout":"Mise en page","category.Data":"Données","brick.text.name":"Texte","brick.email.name":"Email","brick.password.name":"Mot de passe","brick.url.name":"URL","brick.phone.name":"Téléphone","brick.textarea.name":"Zone de texte","brick.number.name":"Nombre","brick.date.name":"Date","brick.time.name":"Heure","brick.datetime.name":"Date / Heure","brick.select.name":"Liste déroulante","brick.multi-select.name":"Sélection multiple","brick.radio.name":"Boutons radio","brick.select-boxes.name":"Cases à cocher","brick.checkbox.name":"Case à cocher","brick.tags.name":"Étiquettes","brick.signature.name":"Signature","brick.data-grid.name":"Grille de données","brick.address.name":"Adresse","brick.file.name":"Fichier","brick.hidden.name":"Caché","brick.content.name":"Contenu","brick.recap.name":"Récapitulatif","brick.nested-form.name":"Formulaire imbriqué","brick.code.name":"Code","nestedForm.ref":"Formulaire référencé","nestedForm.missing":"Renseignez la config specRef pour référencer un formulaire.","nestedForm.loading":"Chargement des formulaires imbriqués…","panel.specRef":"Formulaire référencé (specRef)","panel.optionsRef":"Catalogue d'options (optionsRef)","recap.empty":"Rien à récapituler pour le moment.","recap.yes":"Oui","recap.no":"Non","panel.cfg.showEmpty":"Afficher les champs vides","panel.cfg.groupBySections":"Regrouper par section","brick.group.name":"Groupe","brick.row.name":"Ligne","brick.column.name":"Colonne","brick.stepper.name":"Étapes","brick.tabs.name":"Onglets"},Us=Symbol.for("formkrafter.i18n"),qs=globalThis,Fs=qs[Us]??={current:{...Ls}};function Vs(t={}){Fs.current={...Ls,...t}}function Bs(t,e){let i=Fs.current[t]??t;for(const[t,r]of Object.entries(e??{}))i=i.replace(`{${t}}`,String(r));return i}function Gs(t,e){return Fs.current[t]??e}var Hs=new Set(["__proto__","constructor","prototype"]);class Ks{value;constructor(t){this.value=t}}var Js=(t,e,i)=>{t.scopes[t.scopes.length-1].set(e,i)},Ws=t=>{if("number"==typeof t)return t;const e=String(t);if(Hs.has(e))throw new Error(`Access to "${e}" is not allowed`);return e},Zs=(t,e)=>({object:Ys(t,e.object),prop:Ws(e.computed?Ys(t,e.property):e.property.name),optional:!0===e.optional}),Ys=(t,e)=>{if(++t.steps>1e5)throw new Error("Sandbox execution budget exceeded");switch(e.type){case"Program":case"BlockStatement":for(const i of e.body){const e=Ys(t,i);if(e instanceof Ks)return e}return;case"ReturnStatement":return new Ks(e.argument?Ys(t,e.argument):void 0);case"IfStatement":return Ys(t,e.test)?Ys(t,e.consequent):e.alternate?Ys(t,e.alternate):void 0;case"VariableDeclaration":for(const i of e.declarations){const e=i.id;if("Identifier"!==e.type)throw new Error("Only simple variable names are supported");Js(t,e.name,i.init?Ys(t,i.init):void 0)}return;case"ExpressionStatement":return void Ys(t,e.expression);case"Literal":return e.value;case"TemplateLiteral":{const i=e.expressions;let r="";return e.quasis.forEach(((e,n)=>{r+=e.value.cooked??"",n<i.length&&(r+=String(Ys(t,i[n])))})),r}case"Identifier":return((t,e)=>{for(let i=t.scopes.length-1;i>=0;i--)if(t.scopes[i].has(e))return t.scopes[i].get(e);throw new Error(`Unknown identifier "${e}"`)})(t,e.name);case"ThisExpression":return;case"ChainExpression":return Ys(t,e.expression);case"MemberExpression":return((t,e)=>{const{object:i,prop:r,optional:n}=Zs(t,e);if(null==i){if(n)return;throw new Error(`Cannot read "${String(r)}" of ${String(i)}`)}return i[r]})(t,e);case"CallExpression":{const i=e.callee,r=[];for(const i of e.arguments)if("SpreadElement"===i.type){const e=Ys(t,i.argument);Array.isArray(e)&&r.push(...e)}else r.push(Ys(t,i));if("MemberExpression"===i.type){const{object:n,prop:s,optional:o}=Zs(t,i);if(null==n){if(o||!0===e.optional)return;throw new Error(`Cannot call "${String(s)}" of ${String(n)}`)}const a=n[s];if("function"!=typeof a){if(!0===e.optional&&null==a)return;throw new Error(`"${String(s)}" is not a function`)}if(a===Function||a===eval)throw new Error("This function is not allowed");return a.apply(n,r)}const n=Ys(t,i);if("function"!=typeof n){if(!0===e.optional&&null==n)return;throw new Error("Value is not a function")}if(n===Function||n===eval)throw new Error("This function is not allowed");return n(...r)}case"ArrowFunctionExpression":{const i=e.params,r=e.body,n=[...t.scopes];return(...s)=>{const o=new Map;i.forEach(((t,e)=>{if("Identifier"!==t.type)throw new Error("Only simple parameters are supported");o.set(t.name,s[e])}));const a={steps:t.steps,scopes:[...n,o]},h=Ys(a,r);return t.steps=a.steps,h instanceof Ks?h.value:!0===e.expression?h:void 0}}case"BinaryExpression":{const i=Ys(t,e.left),r=Ys(t,e.right);switch(e.operator){case"===":return i===r;case"!==":return i!==r;case"==":return i==r;case"!=":return i!=r;case"<":return i<r;case"<=":return i<=r;case">":return i>r;case">=":return i>=r;case"+":return i+r;case"-":return i-r;case"*":return i*r;case"/":return i/r;case"%":return i%r;case"**":return i**r;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"LogicalExpression":{const i=Ys(t,e.left);switch(e.operator){case"&&":return i&&Ys(t,e.right);case"||":return i||Ys(t,e.right);case"??":return i??Ys(t,e.right);default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"UnaryExpression":{const i=Ys(t,e.argument);switch(e.operator){case"!":return!i;case"-":return-i;case"+":return+i;case"typeof":return typeof i;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"ConditionalExpression":return Ys(t,e.test)?Ys(t,e.consequent):Ys(t,e.alternate);case"AssignmentExpression":{const i=e.left;if("Identifier"!==i.type||"="!==e.operator)throw new Error("Only simple assignments are supported");const r=Ys(t,e.right);return((t,e,i)=>{for(let r=t.scopes.length-1;r>=0;r--)if(t.scopes[r].has(e))return void t.scopes[r].set(e,i);throw new Error(`Cannot assign to unknown identifier "${e}"`)})(t,i.name,r),r}case"ArrayExpression":{const i=[];for(const r of e.elements)if(r)if("SpreadElement"===r.type){const e=Ys(t,r.argument);Array.isArray(e)&&i.push(...e)}else i.push(Ys(t,r));return i}case"ObjectExpression":{const i={};for(const r of e.properties){if("SpreadElement"===r.type){const e=Ys(t,r.argument);if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))i[String(Ws(t))]=r;continue}const e=r.key,n=Ws(r.computed?Ys(t,e):"Identifier"===e.type?e.name:e.value);i[String(n)]=Ys(t,r.value)}return i}default:throw new Error(`Unsupported syntax: ${e.type}`)}},Qs={undefined:void 0,NaN:NaN,Infinity:1/0,Math,JSON,Number,String,Boolean,Array,Object,Date,parseInt,parseFloat,isNaN,isFinite};class Xs{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchSpec(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load spec "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}class to{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchOptions(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load options "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}var eo=Symbol.for("formkrafter.core.services"),io=globalThis,ro=io[eo]??={jsRunnerService:new class{validateJs(t,e={ecmaVersion:"latest",allowReturnOutsideFunction:!0}){try{return Yt(t,e),{valid:!0}}catch(t){return{valid:!1,error:t instanceof Error?t:new Error(String(t))}}}eval(t,e={}){return function(t,e={}){const i=Yt(t,{ecmaVersion:"latest",allowReturnOutsideFunction:!0}),r={steps:0,scopes:[new Map(Object.entries({...Qs,...e})),new Map]},n=Ys(r,i);return n instanceof Ks?n.value:void 0}(t,e)}},dataSourceService:new class{defaults;cache=new Map;constructor(t={}){this.defaults=t}fetchOptions(t,e){const i={...this.defaults.headers,...e?.headers},r={};Object.keys(i).length&&(r.headers=i),this.defaults.credentials&&(r.credentials=this.defaults.credentials);const n=`${t}|${JSON.stringify(r)}`;let s=this.cache.get(n);return s||(s=fetch(t,Object.keys(r).length?r:void 0).then((e=>{if(!e.ok)throw new Error(`Data source request failed (${e.status}): ${t}`);return e.json()})).then((t=>Array.isArray(t)?t:[])).catch((t=>{throw this.cache.delete(n),t})),this.cache.set(n,s)),s}},fileUploadService:new class{async upload(t){const e=globalThis.btoa;if(!e)throw new Error("No base64 encoder available");const i=new Uint8Array(await t.arrayBuffer());let r="";for(const t of i)r+=String.fromCharCode(t);return{name:t.name,type:t.type,size:t.size,url:`data:${t.type};base64,${e(r)}`}}},specSourceService:new Xs,optionSourceService:new to};ro.specSourceService??=new Xs,ro.optionSourceService??=new to;var no=(t,e)=>{try{return ro.jsRunnerService.eval(t,{dataMap:e??{}})}catch(t){return t instanceof Error?t:new Error(String(t))}},so=(t,e)=>((t,e)=>((t,e)=>t?.filter((t=>((t,e)=>"jsonLogic"===t.type?null!=t.logic&&!0===n.apply(t.logic,e):"javaScript"===t.type&&!!t.code&&!0===no(t.code,e))(t,e))))(t,e)?.map((t=>t.effects)).flat().filter((t=>null!=t)))(t,e)?.map((t=>{let i;return t.property?("boolean"===t.property.type?i=t.boolean:"logic"===t.property.type&&null!=t.logic?i=n.apply(t.logic,e):"code"===t.property.type&&t.code?i=no(t.code,e):"string"===t.property.type&&(i=t.string),{[t.property.target]:i}):{}})).flat().reduce(((t,e)=>({...t,...e})),{})??{hidden:!1},oo=(t,e)=>{if(Array.isArray(e))return e.map((e=>oo(t,e))).filter(Boolean).join(", ");if(!0===e)return Gs("recap.yes","Yes");if(!1===e)return Gs("recap.no","No");if(e&&"object"==typeof e)return"string"==typeof e.name&&"url"in e?e.name:Object.values(e).filter((t=>"string"==typeof t&&t)).join(" ");const i=String(e??"");if(null!=t.configs?.options){const e=Ds(t.configs.options,"string"==typeof t.configs.labelKey?t.configs.labelKey:"label","string"==typeof t.configs.valueKey?t.configs.valueKey:"value").find((t=>t.value===i));if(e)return e.label}return i},ao=t=>null==t||""===t||Array.isArray(t)&&0===t.length,ho=(t,e)=>String(js(t.configs?.label,e)??t.name??t.configs?.key??""),uo=t=>{const e=[];for(const i of t.children??[]){const t=i.configs?.key;"input"===i.type&&t&&!t.startsWith("_")&&e.push(i)}return e},co=(t,e,i,r,n=!1)=>{if(!t)return[];const s=[];for(const o of t.children??[]){if("recap"===o.id||"action"===o.type)continue;if(!0===so(o.rules,e).hidden)continue;const t=o.configs?.key,a=ho(o,i);if("collection"===o.type){const n=t&&Array.isArray(e?.[t])?e[t]:[];if(!n.length&&!r)continue;const h=uo(o);s.push({kind:"collection",label:a,columns:h.map((t=>ho(t,i))),rows:n.map((t=>h.map((e=>{const i=t?.[e.configs.key];return ao(i)?"—":oo(e,i)}))))});continue}if("panel"===o.type){const t=js(o.configs?.label,i);if(n&&"string"==typeof t&&t.trim()){const n=co(o,e,i,r);n.length&&(s.push({kind:"section",label:t}),s.push(...n));continue}s.push(...co(o,e,i,r,n));continue}if("input"!==o.type||!t||t.startsWith("_"))continue;const h=e?.[t];ao(h)&&!r||s.push({kind:"field",label:a,value:ao(h)?"—":oo(o,h)})}return s};function fo(t,e){return t.replace(/\{(\w+)\}/g,((t,i)=>{const r=e?.[i];return null==r?"":String(r)}))}function lo(t,e){if("string"!=typeof t||!t.trim())return;const i={};for(const r of t.split("\n")){const t=r.indexOf(":");if(t<=0)continue;const n=r.slice(0,t).trim(),s=fo(r.slice(t+1).trim(),e);n&&(i[n]=s)}return Object.keys(i).length?i:void 0}function po(t,e,i){if(!i)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${encodeURIComponent(e)}=${encodeURIComponent(i)}`}class mo{type;dataType;id;name;configsForm;category;styles;unWrapData;isPrivate;validators;defaultConfigs;constructor(t){this.type=t.type,this.dataType=t.dataType,this.id=t.id,this.name=t.name,this.configsForm=t.configsForm,this.category=t.category,this.styles=t.styles,this.unWrapData=t.unWrapData??!1,this.isPrivate=t.isPrivate??!1,this.validators=t.validators??[],this.defaultConfigs=t.defaultConfigs}getBrickEmptySpec(){return{type:this.type,dataType:this.dataType,id:this.id,name:this.name,...void 0!==this.category?{category:this.category}:{},...void 0!==this.configsForm?{configsForm:this.configsForm}:{},...void 0!==this.styles?{styles:this.styles}:{},...void 0!==this.defaultConfigs?{configs:{...this.defaultConfigs}}:{},validators:this.validators}}}var vo=new Un.Ajv({allErrors:!0});Jn(vo,["email","uri"]),Vn(vo);var yo=new WeakMap,go=t=>{if("required"===t.keyword)return t.params.missingProperty;if("errorMessage"===t.keyword){const e=t.params.errors?.[0];return e?go(e):void 0}return t.instancePath.split("/").filter(Boolean)[0]},$o=(t,e,i)=>{const r={},n=((t,e)=>{let i=yo.get(t);i||(i=new Map,yo.set(t,i));const r=e??"";let n=i.get(r);if(!n){const s=function(t,e){if(!t)return;const i={},r=[],n={},s=t=>{const i=js(t,e);return"string"==typeof i?i:void 0};for(const o of Ns(t)){const t=o.configs?.key,a=!0===o.configs?.multiple&&"object"===o.dataType?"array":o.dataType;if(!t||!a||"void"===a)continue;const h=o.validations?.find((t=>"required"===t.validator)),u={type:a,nullable:!h},c={type:Cs("type",e)};for(const t of o.validations??[]){const{validator:i,value:r}=t,n=s(t.message)??Cs(i,e,r);"minLength"===i&&null!=r?(u.minLength=Number(r),c.minLength=n):"maxLength"===i&&null!=r?(u.maxLength=Number(r),c.maxLength=n):"min"===i&&null!=r?(u.minimum=Number(r),c.minimum=n):"max"===i&&null!=r?(u.maximum=Number(r),c.maximum=n):"pattern"===i&&"string"==typeof r&&r?(u.pattern=r,c.pattern=n):"minItems"===i&&null!=r?(u.minItems=Number(r),c.minItems=n):"maxItems"===i&&null!=r?(u.maxItems=Number(r),c.maxItems=n):"email"===i?(u.format="email",c.format=n):"url"===i&&(u.format="uri",c.format=n)}u.errorMessage=c,i[t]=u,h&&(r.push(t),n[t]=s(h.message)??Cs("required",e))}return{type:"object",properties:i,required:r,...Object.keys(n).length?{errorMessage:{required:n}}:{},additionalProperties:!1}}(t,e);if(!s)return;try{n=vo.compile(s)}catch{return}i.set(r,n)}return n})(t,i);if(n&&!n(e))for(const t of n.errors??[]){const e=go(t);e&&!(e in r)&&t.message&&(r[e]=t.message)}for(const[n,s]of Object.entries(((t,e,i)=>{const r={},n=e??{};for(const e of Ns(t)){const t=e.configs?.key;if(t)for(const s of e.validations??[]){if("custom"!==s.validator||!s.customValidator)continue;const e=no(`const value = dataMap?.[${JSON.stringify(t)}];\n${s.customValidator}`,n);if(!0!==e&&null!=e&&!(t in r))if("string"==typeof e)r[t]=e;else if(e instanceof Error)r[t]=e.message;else{const e=js(s.message,i);r[t]="string"==typeof e?e:Cs("custom",i)}}}return r})(t,e,i)))n in r||(r[n]=s);const s="object"==typeof e&&null!==e?e:void 0;for(const e of((t,e)=>{const i=new Set,r=(t,n)=>{const s=n||!!t.rules?.length&&!0===so(t.rules,e).hidden,o=t.configs?.key;if(s&&o&&i.add(o),"collection"!==t.type)for(const e of t.children??[])r(e,s)};return r(t,!1),i})(t,s))delete r[e];return{valid:0===Object.keys(r).length,errors:r}};function wo(t){return t.split(".").slice(1).map((t=>`/children/${t}`)).join("")}function bo(t,e){if(t.configs?.uid===e)return"";for(const[i,r]of(t.children??[]).entries()){const t=bo(r,e);if(void 0!==t)return`/children/${i}${t}`}}function _o(t,e){let i=t;for(const t of e.split(".").slice(1))i=i?.children?.[Number(t)];return i}var Eo=(Ss??xs).applyPatch,ko=(t,e,i)=>({spec:Eo(t,e,!0,!1).newDocument,patches:e,inverse:i}),So=(t,e)=>{const i=_o(t,e);if(!i)throw new Error(`No brick at path "${e}"`);return i},xo=(t,e)=>{const i=bo(t,e);if(void 0===i)throw new Error(`No brick with uid "${e}"`);let r=t;for(const t of i.split("/children/").slice(1))r=r.children[Number(t)];return{pointer:i,brick:r}},Oo=t=>JSON.parse(JSON.stringify(t));function jo(t,e,i,r){const n=So(t,i),s=wo(i),o=Oo(e);if(!n.children){const e=`${s}/children`;return ko(t,[{op:"add",path:e,value:[o]}],[{op:"remove",path:e}])}const a=`${s}/children/${Math.min(r??n.children.length,n.children.length)}`;return ko(t,[{op:"add",path:a,value:o}],[{op:"remove",path:a}])}function Po(t,e){if("0"===e)throw new Error("Cannot remove the root brick");const i=So(t,e),r=wo(e);return ko(t,[{op:"remove",path:r}],[{op:"add",path:r,value:i}])}function Io(t,e,i){if("0"===e||"0"===i)throw new Error("Cannot move the root brick");const r=So(t,e),n=e.split(".").map(Number),s=i.split(".").map(Number),o=n.length-1,a=n[o],h=s.length>o&&n.slice(0,o).every(((t,e)=>t===s[e])),u=[...s];if(h){if(u[o]===a&&u.length>n.length)throw new Error(`Cannot move a brick into its own subtree ("${e}" → "${i}")`);u[o]>a&&(u[o]-=1)}const c=wo(e),f=wo(u.join("."));return ko(t,[{op:"remove",path:c},{op:"add",path:f,value:r}],[{op:"remove",path:f},{op:"add",path:c,value:r}])}var Co=t=>({...t,...t.configs?{configs:{...t.configs,uid:crypto.randomUUID()}}:{},...t.children?{children:t.children.map(Co)}:{}});function Ao(t,e){if("0"===e)throw new Error("Cannot duplicate the root brick");const i=So(t,e),r=e.split("."),n=Number(r[r.length-1])+1,s=wo([...r.slice(0,-1),String(n)].join(".")),o=Co(Oo(i));return ko(t,[{op:"add",path:s,value:o}],[{op:"remove",path:s}])}var No=(t,e,i,r,n)=>{const s=`${e}/${i}`;return void 0===n?ko(t,[{op:"add",path:s,value:r}],[{op:"remove",path:s}]):ko(t,[{op:"replace",path:s,value:r}],[{op:"replace",path:s,value:n}])};function To(t,e,i){const{pointer:r,brick:n}=xo(t,e),s={...n.configs,...i};return No(t,r,"configs",s,n.configs)}function Mo(t,e,i){const{pointer:r,brick:n}=xo(t,e),s={...n.styles,...i};return No(t,r,"styles",s,n.styles)}function Ro(t,e,i){const{pointer:r,brick:n}=xo(t,e);return No(t,r,"validations",i,n.validations)}function Do(t,e,i){const{pointer:r,brick:n}=xo(t,e);return No(t,r,"rules",i,n.rules)}class Lo{past=[];future=[];record(t){this.past.push({patches:t.patches,inverse:t.inverse}),this.future=[]}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}undo(t){const e=this.past.pop();if(e)return this.future.push(e),Eo(t,e.inverse,!0,!1).newDocument}redo(t){const e=this.future.pop();if(e)return this.past.push(e),Eo(t,e.patches,!0,!1).newDocument}clear(){this.past=[],this.future=[]}}var zo=t=>"nested-form"===t.id&&"string"==typeof t.configs?.specRef,Uo=t=>{if(!t)return!1;for(const{brick:e}of As(t))if(zo(e)&&e.configs?.specRef)return!0;return!1};async function qo(t,e={}){const i=e.specSourceService??ro.specSourceService,r=e.maxDepth??5,n=async(t,e)=>{if(zo(t)&&t.configs?.specRef){const s=String(t.configs.specRef);if(e.includes(s))throw new Error(`Circular nested form reference: ${[...e,s].join(" → ")}`);if(e.length>=r)throw new Error(`Nested forms exceed the maximum depth of ${r} (${s})`);const o=await i.fetchSpec(s),a=await n(structuredClone(o),[...e,s]);return{type:"panel",id:"group",name:t.name,configs:{...t.configs,label:t.configs.label??a.name},styles:t.styles,rules:t.rules,children:a.children??[]}}return t.children?.length?{...t,children:await Promise.all(t.children.map((t=>n(t,e))))}:t};return n(structuredClone(t),[])}export{Do as A,mo as B,co as C,js as D,Vs as E,zs as F,Lo as S,Ts as a,Bs as b,Os as c,fo as d,qo as e,Gs as f,so as g,Uo as h,As as i,po as j,no as k,Ns as l,jo as m,Ds as n,_o as o,lo as p,Io as q,Ps as r,ro as s,Po as t,Ao as u,$o as v,Ms as w,To as x,Mo as y,Ro as z}
|
|
12
|
+
*/function ws(t,e){e.unobserve()}function bs(t,e){var i,r=function(t){return ys.get(t)}(t);if(r){var n=function(t,e){return t.observers.get(e)}(r,e);i=n&&n.observer}else r=new gs(t),ys.set(t,r);if(i)return i;if(i={},r.value=Xn(t),e){i.callback=e,i.next=null;var s=function(){_s(i)},o=function(){clearTimeout(i.next),i.next=setTimeout(s)};"undefined"!=typeof window&&(window.addEventListener("mouseup",o),window.addEventListener("keyup",o),window.addEventListener("mousedown",o),window.addEventListener("keydown",o),window.addEventListener("change",o))}return i.patches=[],i.object=t,i.unobserve=function(){_s(i),clearTimeout(i.next),function(t,e){t.observers.delete(e.callback)}(r,i),"undefined"!=typeof window&&(window.removeEventListener("mouseup",o),window.removeEventListener("keyup",o),window.removeEventListener("mousedown",o),window.removeEventListener("keydown",o),window.removeEventListener("change",o))},r.observers.set(e,new $s(e,i)),i}function _s(t,e){void 0===e&&(e=!1);var i=ys.get(t.object);Es(i.value,t.object,t.patches,"",e),t.patches.length&&fs(i.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r}function Es(t,e,i,r,n){if(e!==t){"function"==typeof e.toJSON&&(e=e.toJSON());for(var s=Qn(e),o=Qn(t),a=!1,h=o.length-1;h>=0;h--){var u=t[f=o[h]];if(!Yn(e,f)||void 0===e[f]&&void 0!==u&&!1===Array.isArray(e))Array.isArray(t)===Array.isArray(e)?(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"remove",path:r+"/"+es(f)}),a=!0):(n&&i.push({op:"test",path:r,value:t}),i.push({op:"replace",path:r,value:e}));else{var c=e[f];"object"==typeof u&&null!=u&&"object"==typeof c&&null!=c&&Array.isArray(u)===Array.isArray(c)?Es(u,c,i,r+"/"+es(f),n):u!==c&&(n&&i.push({op:"test",path:r+"/"+es(f),value:Xn(u)}),i.push({op:"replace",path:r+"/"+es(f),value:Xn(c)}))}}if(a||s.length!=o.length)for(h=0;h<s.length;h++){var f;Yn(t,f=s[h])||void 0===e[f]||i.push({op:"add",path:r+"/"+es(f),value:Xn(e[f])})}}}function ks(t,e,i){void 0===i&&(i=!1);var r=[];return Es(t,e,r,"",i),r}var Ss=Object.assign({},vs,Object.freeze({__proto__:null,compare:ks,generate:_s,observe:bs,unobserve:ws}),{JsonPatchError:ss,deepClone:Xn,escapePathComponent:es,unescapePathComponent:is}),xs=Object.freeze({__proto__:null,JsonPatchError:ss,_areEquals:ms,applyOperation:cs,applyPatch:fs,applyReducer:ls,compare:ks,deepClone:Xn,default:Ss,escapePathComponent:es,generate:_s,getValueByPointer:us,observe:bs,unescapePathComponent:is,unobserve:ws,validate:ps,validator:ds});function Os(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&Object.keys(t).length>0&&Object.values(t).every((t=>"string"==typeof t))}function js(t,e){return Os(t)?e&&void 0!==t[e]?t[e]:Object.values(t)[0]:t}function Ps(t,e){if(!t)return t;const i={};for(const[r,n]of Object.entries(t))i[r]=js(n,e);return i}var Is={en:{required:"This field is required",minLength:"Must be at least {value} characters",maxLength:"Must be at most {value} characters",min:"Must be at least {value}",max:"Must be at most {value}",pattern:"Invalid format",minItems:"Select at least {value} item(s)",maxItems:"Select at most {value} item(s)",email:"Invalid email address",url:"Invalid URL",type:"Invalid value",custom:"Invalid value"},fr:{required:"Ce champ est obligatoire",minLength:"Minimum {value} caractères",maxLength:"Maximum {value} caractères",min:"Minimum {value}",max:"Maximum {value}",pattern:"Format invalide",minItems:"Sélectionnez au moins {value} élément(s)",maxItems:"Sélectionnez au plus {value} élément(s)",email:"Adresse email invalide",url:"URL invalide",type:"Valeur invalide",custom:"Valeur invalide"}};function Cs(t,e,i){return((Is[e??"en"]??Is.en)[t]??Is.en[t]??"Invalid value").replace("{value}",String(i??""))}function*As(t,e="0"){if(t){yield{brick:t,path:e};for(const[i,r]of(t.children??[]).entries())yield*As(r,`${e}.${i}`)}}function*Ns(t){if(t&&(yield t,"collection"!==t.type))for(const e of t.children??[])yield*Ns(e)}function Ts(t,e){if(t.configs?.key&&e)return t.unWrapData?e:e[t.configs.key]}function Ms(t,e){if(t.configs?.key)return t.unWrapData?e:{[t.configs.key]:e}}var Rs=(t,e)=>{if(!e.includes("."))return t[e];let i=t;for(const t of e.split(".")){if("object"!=typeof i||null===i)return;i=i[t]}return i};function Ds(t,e="label",i="value"){return Array.isArray(t)?t.map((t=>{if("object"==typeof t&&null!==t){const r=t,n=Rs(r,e)??Rs(r,i),s=Rs(r,i)??Rs(r,e);return{label:String(n??""),value:String(s??"")}}return{label:String(t),value:String(t)}})).filter((t=>""!==t.label)):String(t??"").split("\n").map((t=>t.trim())).filter(Boolean).map((t=>({label:t,value:t})))}var Ls={"palette.search":"Search bricks…","palette.empty":"No brick matches “{query}”","builder.undo":"Undo","builder.redo":"Redo","builder.editLocale":"Editing language","builder.copyJson":"Copy JSON","builder.importJson":"Import JSON","builder.importInvalid":"Invalid form JSON","builder.pasteHint":"Press Ctrl+V to paste a spec","builder.copied":"Copied!","builder.downloadJson":"Download .json","builder.hint":"Select a brick to edit its properties","drop.hint":"Drop a brick here","empty.title":"Your form is empty","empty.hint":"Drag a brick from the palette to get started","actions.move":"Move","actions.duplicate":"Duplicate","actions.delete":"Delete","stepper.back":"← Back","stepper.next":"Next →","stepper.submit":"Submit","panel.cfg.validateSteps":"Validate each step","panel.cfg.allowStepClick":"Allow clicking steps to jump","panel.cfg.showSubmit":"Submit button on last step","panel.cfg.validateTabs":"Validate tab before leaving it","signature.clear":"Clear","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Rules","panel.key":"Key","panel.label":"Label","panel.placeholder":"Placeholder","panel.prefix":"Prefix","panel.suffix":"Suffix","panel.accept":"Accepted file types","panel.mask":"Input mask (9=digit, a=letter, *=any)","panel.uploadUrl":"Upload URL","panel.cfg.multiple":"Allow multiple files","panel.optionsSource":"Options source","panel.options":"Options (one per line)","panel.content":"Content","panel.dataKey":"Data key","panel.url":"URL","panel.headers":"Headers ({token} reads form data)","panel.searchParam":"Server search param","panel.labelKey":"Label key","panel.valueKey":"Value key","panel.errorMessage":"Error message","panel.required":"Required","panel.minLength":"Min length","panel.maxLength":"Max length","panel.min":"Min","panel.max":"Max","panel.pattern":"Pattern (regex)","panel.minItems":"Min items","panel.maxItems":"Max items","panel.emailFormat":"Email format","panel.urlFormat":"URL format","panel.custom":"Custom (JavaScript)","panel.fallbackMessage":"Fallback message","panel.styleProperty":"property","panel.styleValue":"value","file.choose":"Choose a file…","file.uploading":"Uploading…","file.remove":"Remove file","file.addAnother":"+ Add a file","address.street":"Street","address.city":"City","address.zip":"Postal code","address.country":"Country","grid.addRow":"+ Add row","grid.moveUp":"Move row up","grid.moveDown":"Move row down","grid.removeRow":"Remove row","grid.empty":"No rows yet","grid.columns":"Row template","select.search":"Search…","select.empty":"No options","select.clear":"Clear","rules.when":"When","rules.then":"Then","rules.addRule":"+ Add rule","rules.addEffect":"+ Effect","rules.removeRule":"Remove rule","rules.removeEffect":"Remove effect","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Inputs","category.Layout":"Layout","category.Data":"Data","brick.text.name":"Text","brick.email.name":"Email","brick.password.name":"Password","brick.url.name":"URL","brick.phone.name":"Phone","brick.textarea.name":"Text area","brick.number.name":"Number","brick.date.name":"Date","brick.time.name":"Time","brick.datetime.name":"Date / Time","brick.select.name":"Select","brick.multi-select.name":"Multi select","brick.radio.name":"Radio","brick.select-boxes.name":"Select boxes","brick.checkbox.name":"Checkbox","brick.tags.name":"Tags","brick.signature.name":"Signature","brick.data-grid.name":"Data grid","brick.address.name":"Address","brick.file.name":"File","brick.hidden.name":"Hidden","brick.content.name":"Content","brick.recap.name":"Recap","brick.nested-form.name":"Nested form","brick.code.name":"Code","nestedForm.ref":"Referenced form","nestedForm.missing":"Set the specRef config to reference a form.","nestedForm.loading":"Loading nested forms…","panel.specRef":"Referenced form (specRef)","panel.optionsRef":"Options catalog (optionsRef)","recap.empty":"Nothing to summarize yet.","recap.yes":"Yes","recap.no":"No","panel.cfg.showEmpty":"Show empty fields","panel.cfg.groupBySections":"Group by section","brick.group.name":"Group","brick.row.name":"Row","brick.column.name":"Column","brick.stepper.name":"Stepper","brick.tabs.name":"Tabs"},zs={"palette.search":"Rechercher une brique…","palette.empty":"Aucune brique ne correspond à « {query} »","builder.undo":"Annuler","builder.editLocale":"Langue d'édition","builder.redo":"Rétablir","builder.copyJson":"Copier le JSON","builder.importJson":"Importer le JSON","builder.importInvalid":"JSON de formulaire invalide","builder.pasteHint":"Collez avec Ctrl+V pour importer une spec","builder.copied":"Copié !","builder.downloadJson":"Télécharger le .json","builder.hint":"Sélectionnez une brique pour éditer ses propriétés","drop.hint":"Déposez une brique ici","empty.title":"Votre formulaire est vide","empty.hint":"Glissez une brique depuis la palette pour commencer","actions.move":"Déplacer","actions.duplicate":"Dupliquer","actions.delete":"Supprimer","stepper.back":"← Précédent","stepper.next":"Suivant →","stepper.submit":"Envoyer","panel.cfg.validateSteps":"Valider chaque étape","panel.cfg.allowStepClick":"Autoriser le saut d’étapes au clic","panel.cfg.showSubmit":"Bouton d’envoi à la dernière étape","panel.cfg.validateTabs":"Valider l’onglet avant de le quitter","signature.clear":"Effacer","panel.tab.config":"Config","panel.tab.validation":"Validation","panel.tab.styles":"Styles","panel.tab.rules":"Règles","panel.key":"Clé","panel.label":"Libellé","panel.placeholder":"Placeholder","panel.prefix":"Préfixe","panel.suffix":"Suffixe","panel.accept":"Types de fichiers acceptés","panel.mask":"Masque de saisie (9=chiffre, a=lettre, *=tout)","panel.uploadUrl":"URL d'upload","panel.cfg.multiple":"Autoriser plusieurs fichiers","panel.optionsSource":"Source des options","panel.options":"Options (une par ligne)","panel.content":"Contenu","panel.dataKey":"Clé de données","panel.url":"URL","panel.headers":"En-têtes ({token} lit les données du formulaire)","panel.searchParam":"Paramètre de recherche serveur","panel.labelKey":"Clé du libellé","panel.valueKey":"Clé de la valeur","panel.errorMessage":"Message d'erreur","panel.required":"Obligatoire","panel.minLength":"Longueur min","panel.maxLength":"Longueur max","panel.min":"Min","panel.max":"Max","panel.pattern":"Motif (regex)","panel.minItems":"Éléments min","panel.maxItems":"Éléments max","panel.emailFormat":"Format email","panel.urlFormat":"Format URL","panel.custom":"Personnalisé (JavaScript)","panel.fallbackMessage":"Message par défaut","panel.styleProperty":"propriété","panel.styleValue":"valeur","file.choose":"Choisir un fichier…","file.uploading":"Envoi en cours…","file.remove":"Retirer le fichier","file.addAnother":"+ Ajouter un fichier","address.street":"Rue","address.city":"Ville","address.zip":"Code postal","address.country":"Pays","grid.addRow":"+ Ajouter une ligne","grid.moveUp":"Monter la ligne","grid.moveDown":"Descendre la ligne","grid.removeRow":"Supprimer la ligne","grid.empty":"Aucune ligne","grid.columns":"Modèle de ligne","select.search":"Rechercher…","select.empty":"Aucune option","select.clear":"Effacer","rules.when":"Quand","rules.then":"Alors","rules.addRule":"+ Ajouter une règle","rules.addEffect":"+ Effet","rules.removeRule":"Supprimer la règle","rules.removeEffect":"Supprimer l'effet","rules.mode.simple":"simple","rules.mode.json":"json","rules.mode.js":"JS","category.Inputs":"Champs","category.Layout":"Mise en page","category.Data":"Données","brick.text.name":"Texte","brick.email.name":"Email","brick.password.name":"Mot de passe","brick.url.name":"URL","brick.phone.name":"Téléphone","brick.textarea.name":"Zone de texte","brick.number.name":"Nombre","brick.date.name":"Date","brick.time.name":"Heure","brick.datetime.name":"Date / Heure","brick.select.name":"Liste déroulante","brick.multi-select.name":"Sélection multiple","brick.radio.name":"Boutons radio","brick.select-boxes.name":"Cases à cocher","brick.checkbox.name":"Case à cocher","brick.tags.name":"Étiquettes","brick.signature.name":"Signature","brick.data-grid.name":"Grille de données","brick.address.name":"Adresse","brick.file.name":"Fichier","brick.hidden.name":"Caché","brick.content.name":"Contenu","brick.recap.name":"Récapitulatif","brick.nested-form.name":"Formulaire imbriqué","brick.code.name":"Code","nestedForm.ref":"Formulaire référencé","nestedForm.missing":"Renseignez la config specRef pour référencer un formulaire.","nestedForm.loading":"Chargement des formulaires imbriqués…","panel.specRef":"Formulaire référencé (specRef)","panel.optionsRef":"Catalogue d'options (optionsRef)","recap.empty":"Rien à récapituler pour le moment.","recap.yes":"Oui","recap.no":"Non","panel.cfg.showEmpty":"Afficher les champs vides","panel.cfg.groupBySections":"Regrouper par section","brick.group.name":"Groupe","brick.row.name":"Ligne","brick.column.name":"Colonne","brick.stepper.name":"Étapes","brick.tabs.name":"Onglets"},Us=Symbol.for("formkrafter.i18n"),qs=globalThis,Fs=qs[Us]??={current:{...Ls}};function Vs(t={}){Fs.current={...Ls,...t}}function Bs(t,e){let i=Fs.current[t]??t;for(const[t,r]of Object.entries(e??{}))i=i.replace(`{${t}}`,String(r));return i}function Gs(t,e){return Fs.current[t]??e}var Hs=new Set(["__proto__","constructor","prototype"]);class Ks{value;constructor(t){this.value=t}}var Js=(t,e,i)=>{t.scopes[t.scopes.length-1].set(e,i)},Ws=t=>{if("number"==typeof t)return t;const e=String(t);if(Hs.has(e))throw new Error(`Access to "${e}" is not allowed`);return e},Zs=(t,e)=>({object:Ys(t,e.object),prop:Ws(e.computed?Ys(t,e.property):e.property.name),optional:!0===e.optional}),Ys=(t,e)=>{if(++t.steps>1e5)throw new Error("Sandbox execution budget exceeded");switch(e.type){case"Program":case"BlockStatement":for(const i of e.body){const e=Ys(t,i);if(e instanceof Ks)return e}return;case"ReturnStatement":return new Ks(e.argument?Ys(t,e.argument):void 0);case"IfStatement":return Ys(t,e.test)?Ys(t,e.consequent):e.alternate?Ys(t,e.alternate):void 0;case"VariableDeclaration":for(const i of e.declarations){const e=i.id;if("Identifier"!==e.type)throw new Error("Only simple variable names are supported");Js(t,e.name,i.init?Ys(t,i.init):void 0)}return;case"ExpressionStatement":return void Ys(t,e.expression);case"Literal":return e.value;case"TemplateLiteral":{const i=e.expressions;let r="";return e.quasis.forEach(((e,n)=>{r+=e.value.cooked??"",n<i.length&&(r+=String(Ys(t,i[n])))})),r}case"Identifier":return((t,e)=>{for(let i=t.scopes.length-1;i>=0;i--)if(t.scopes[i].has(e))return t.scopes[i].get(e);throw new Error(`Unknown identifier "${e}"`)})(t,e.name);case"ThisExpression":return;case"ChainExpression":return Ys(t,e.expression);case"MemberExpression":return((t,e)=>{const{object:i,prop:r,optional:n}=Zs(t,e);if(null==i){if(n)return;throw new Error(`Cannot read "${String(r)}" of ${String(i)}`)}return i[r]})(t,e);case"CallExpression":{const i=e.callee,r=[];for(const i of e.arguments)if("SpreadElement"===i.type){const e=Ys(t,i.argument);Array.isArray(e)&&r.push(...e)}else r.push(Ys(t,i));if("MemberExpression"===i.type){const{object:n,prop:s,optional:o}=Zs(t,i);if(null==n){if(o||!0===e.optional)return;throw new Error(`Cannot call "${String(s)}" of ${String(n)}`)}const a=n[s];if("function"!=typeof a){if(!0===e.optional&&null==a)return;throw new Error(`"${String(s)}" is not a function`)}if(a===Function||a===eval)throw new Error("This function is not allowed");return a.apply(n,r)}const n=Ys(t,i);if("function"!=typeof n){if(!0===e.optional&&null==n)return;throw new Error("Value is not a function")}if(n===Function||n===eval)throw new Error("This function is not allowed");return n(...r)}case"ArrowFunctionExpression":{const i=e.params,r=e.body,n=[...t.scopes];return(...s)=>{const o=new Map;i.forEach(((t,e)=>{if("Identifier"!==t.type)throw new Error("Only simple parameters are supported");o.set(t.name,s[e])}));const a={steps:t.steps,scopes:[...n,o]},h=Ys(a,r);return t.steps=a.steps,h instanceof Ks?h.value:!0===e.expression?h:void 0}}case"BinaryExpression":{const i=Ys(t,e.left),r=Ys(t,e.right);switch(e.operator){case"===":return i===r;case"!==":return i!==r;case"==":return i==r;case"!=":return i!=r;case"<":return i<r;case"<=":return i<=r;case">":return i>r;case">=":return i>=r;case"+":return i+r;case"-":return i-r;case"*":return i*r;case"/":return i/r;case"%":return i%r;case"**":return i**r;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"LogicalExpression":{const i=Ys(t,e.left);switch(e.operator){case"&&":return i&&Ys(t,e.right);case"||":return i||Ys(t,e.right);case"??":return i??Ys(t,e.right);default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"UnaryExpression":{const i=Ys(t,e.argument);switch(e.operator){case"!":return!i;case"-":return-i;case"+":return+i;case"typeof":return typeof i;default:throw new Error(`Unsupported operator "${String(e.operator)}"`)}}case"ConditionalExpression":return Ys(t,e.test)?Ys(t,e.consequent):Ys(t,e.alternate);case"AssignmentExpression":{const i=e.left;if("Identifier"!==i.type||"="!==e.operator)throw new Error("Only simple assignments are supported");const r=Ys(t,e.right);return((t,e,i)=>{for(let r=t.scopes.length-1;r>=0;r--)if(t.scopes[r].has(e))return void t.scopes[r].set(e,i);throw new Error(`Cannot assign to unknown identifier "${e}"`)})(t,i.name,r),r}case"ArrayExpression":{const i=[];for(const r of e.elements)if(r)if("SpreadElement"===r.type){const e=Ys(t,r.argument);Array.isArray(e)&&i.push(...e)}else i.push(Ys(t,r));return i}case"ObjectExpression":{const i={};for(const r of e.properties){if("SpreadElement"===r.type){const e=Ys(t,r.argument);if(e&&"object"==typeof e)for(const[t,r]of Object.entries(e))i[String(Ws(t))]=r;continue}const e=r.key,n=Ws(r.computed?Ys(t,e):"Identifier"===e.type?e.name:e.value);i[String(n)]=Ys(t,r.value)}return i}default:throw new Error(`Unsupported syntax: ${e.type}`)}},Qs={undefined:void 0,NaN:NaN,Infinity:1/0,Math,JSON,Number,String,Boolean,Array,Object,Date,parseInt,parseFloat,isNaN,isFinite};class Xs{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchSpec(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load spec "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}class to{defaults;cache=new Map;constructor(t={}){this.defaults=t}resolveUrl(t){return/^https?:\/\//.test(t)||!this.defaults.baseUrl?t:`${this.defaults.baseUrl.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}fetchOptions(t){const e=this.resolveUrl(t);let i=this.cache.get(e);return i||(i=(this.defaults.fetch??globalThis.fetch.bind(globalThis))(e,{headers:this.defaults.headers,credentials:this.defaults.credentials}).then((async e=>{if(!e.ok)throw new Error(`Failed to load options "${t}" (${e.status})`);return await e.json()})),i.catch((()=>this.cache.delete(e))),this.cache.set(e,i)),i}}var eo=Symbol.for("formkrafter.core.services"),io=globalThis,ro=io[eo]??={jsRunnerService:new class{validateJs(t,e={ecmaVersion:"latest",allowReturnOutsideFunction:!0}){try{return Yt(t,e),{valid:!0}}catch(t){return{valid:!1,error:t instanceof Error?t:new Error(String(t))}}}eval(t,e={}){return function(t,e={}){const i=Yt(t,{ecmaVersion:"latest",allowReturnOutsideFunction:!0}),r={steps:0,scopes:[new Map(Object.entries({...Qs,...e})),new Map]},n=Ys(r,i);return n instanceof Ks?n.value:void 0}(t,e)}},dataSourceService:new class{defaults;cache=new Map;constructor(t={}){this.defaults=t}fetchOptions(t,e){const i={...this.defaults.headers,...e?.headers},r={};Object.keys(i).length&&(r.headers=i),this.defaults.credentials&&(r.credentials=this.defaults.credentials);const n=`${t}|${JSON.stringify(r)}`;let s=this.cache.get(n);return s||(s=fetch(t,Object.keys(r).length?r:void 0).then((e=>{if(!e.ok)throw new Error(`Data source request failed (${e.status}): ${t}`);return e.json()})).then((e=>{if(!Array.isArray(e))throw new Error(`Data source did not return an array: ${t}`);return e})).catch((t=>{throw this.cache.delete(n),t})),this.cache.set(n,s)),s}},fileUploadService:new class{async upload(t){const e=globalThis.btoa;if(!e)throw new Error("No base64 encoder available");const i=new Uint8Array(await t.arrayBuffer());let r="";for(const t of i)r+=String.fromCharCode(t);return{name:t.name,type:t.type,size:t.size,url:`data:${t.type};base64,${e(r)}`}}},specSourceService:new Xs,optionSourceService:new to};ro.specSourceService??=new Xs,ro.optionSourceService??=new to;var no=(t,e)=>{try{return ro.jsRunnerService.eval(t,{dataMap:e??{}})}catch(t){return t instanceof Error?t:new Error(String(t))}},so=(t,e)=>((t,e)=>((t,e)=>t?.filter((t=>((t,e)=>"jsonLogic"===t.type?null!=t.logic&&!0===n.apply(t.logic,e):"javaScript"===t.type&&!!t.code&&!0===no(t.code,e))(t,e))))(t,e)?.map((t=>t.effects)).flat().filter((t=>null!=t)))(t,e)?.map((t=>{let i;return t.property?("boolean"===t.property.type?i=t.boolean:"logic"===t.property.type&&null!=t.logic?i=n.apply(t.logic,e):"code"===t.property.type&&t.code?i=no(t.code,e):"string"===t.property.type&&(i=t.string),{[t.property.target]:i}):{}})).flat().reduce(((t,e)=>({...t,...e})),{})??{hidden:!1},oo=(t,e)=>{if(Array.isArray(e))return e.map((e=>oo(t,e))).filter(Boolean).join(", ");if(!0===e)return Gs("recap.yes","Yes");if(!1===e)return Gs("recap.no","No");if(e&&"object"==typeof e)return"string"==typeof e.name&&"url"in e?e.name:Object.values(e).filter((t=>"string"==typeof t&&t)).join(" ");const i=String(e??"");if(null!=t.configs?.options){const e=Ds(t.configs.options,"string"==typeof t.configs.labelKey?t.configs.labelKey:"label","string"==typeof t.configs.valueKey?t.configs.valueKey:"value").find((t=>t.value===i));if(e)return e.label}return i},ao=t=>null==t||""===t||Array.isArray(t)&&0===t.length,ho=(t,e)=>String(js(t.configs?.label,e)??t.name??t.configs?.key??""),uo=t=>{const e=[];for(const i of t.children??[]){const t=i.configs?.key;"input"===i.type&&t&&!t.startsWith("_")&&e.push(i)}return e},co=(t,e,i,r,n=!1)=>{if(!t)return[];const s=[];for(const o of t.children??[]){if("recap"===o.id||"action"===o.type)continue;if(!0===so(o.rules,e).hidden)continue;const t=o.configs?.key,a=ho(o,i);if("collection"===o.type){const n=t&&Array.isArray(e?.[t])?e[t]:[];if(!n.length&&!r)continue;const h=uo(o);s.push({kind:"collection",label:a,columns:h.map((t=>ho(t,i))),rows:n.map((t=>h.map((e=>{const i=t?.[e.configs.key];return ao(i)?"—":oo(e,i)}))))});continue}if("panel"===o.type){const t=js(o.configs?.label,i);if(n&&"string"==typeof t&&t.trim()){const n=co(o,e,i,r);n.length&&(s.push({kind:"section",label:t}),s.push(...n));continue}s.push(...co(o,e,i,r,n));continue}if("input"!==o.type||!t||t.startsWith("_"))continue;const h=e?.[t];ao(h)&&!r||s.push({kind:"field",label:a,value:ao(h)?"—":oo(o,h)})}return s};function fo(t,e){return t.replace(/\{(\w+)\}/g,((t,i)=>{const r=e?.[i];return null==r?"":String(r)}))}function lo(t,e){if("string"!=typeof t||!t.trim())return;const i={};for(const r of t.split("\n")){const t=r.indexOf(":");if(t<=0)continue;const n=r.slice(0,t).trim(),s=fo(r.slice(t+1).trim(),e);n&&(i[n]=s)}return Object.keys(i).length?i:void 0}function po(t,e,i){if(!i)return t;const r=t.includes("?")?"&":"?";return`${t}${r}${encodeURIComponent(e)}=${encodeURIComponent(i)}`}class mo{type;dataType;id;name;configsForm;category;styles;unWrapData;isPrivate;validators;defaultConfigs;constructor(t){this.type=t.type,this.dataType=t.dataType,this.id=t.id,this.name=t.name,this.configsForm=t.configsForm,this.category=t.category,this.styles=t.styles,this.unWrapData=t.unWrapData??!1,this.isPrivate=t.isPrivate??!1,this.validators=t.validators??[],this.defaultConfigs=t.defaultConfigs}getBrickEmptySpec(){return{type:this.type,dataType:this.dataType,id:this.id,name:this.name,...void 0!==this.category?{category:this.category}:{},...void 0!==this.configsForm?{configsForm:this.configsForm}:{},...void 0!==this.styles?{styles:this.styles}:{},...void 0!==this.defaultConfigs?{configs:{...this.defaultConfigs}}:{},validators:this.validators}}}var vo=new Un.Ajv({allErrors:!0});Jn(vo,["email","uri"]),Vn(vo);var yo=new WeakMap,go=t=>{if("required"===t.keyword)return t.params.missingProperty;if("errorMessage"===t.keyword){const e=t.params.errors?.[0];return e?go(e):void 0}return t.instancePath.split("/").filter(Boolean)[0]},$o=(t,e,i)=>{const r={},n=((t,e)=>{let i=yo.get(t);i||(i=new Map,yo.set(t,i));const r=e??"";let n=i.get(r);if(!n){const s=function(t,e){if(!t)return;const i={},r=[],n={},s=t=>{const i=js(t,e);return"string"==typeof i?i:void 0};for(const o of Ns(t)){const t=o.configs?.key,a=!0===o.configs?.multiple&&"object"===o.dataType?"array":o.dataType;if(!t||!a||"void"===a)continue;const h=o.validations?.find((t=>"required"===t.validator)),u={type:a,nullable:!h},c={type:Cs("type",e)};for(const t of o.validations??[]){const{validator:i,value:r}=t,n=s(t.message)??Cs(i,e,r);"minLength"===i&&null!=r?(u.minLength=Number(r),c.minLength=n):"maxLength"===i&&null!=r?(u.maxLength=Number(r),c.maxLength=n):"min"===i&&null!=r?(u.minimum=Number(r),c.minimum=n):"max"===i&&null!=r?(u.maximum=Number(r),c.maximum=n):"pattern"===i&&"string"==typeof r&&r?(u.pattern=r,c.pattern=n):"minItems"===i&&null!=r?(u.minItems=Number(r),c.minItems=n):"maxItems"===i&&null!=r?(u.maxItems=Number(r),c.maxItems=n):"email"===i?(u.format="email",c.format=n):"url"===i&&(u.format="uri",c.format=n)}u.errorMessage=c,i[t]=u,h&&(r.push(t),n[t]=s(h.message)??Cs("required",e))}return{type:"object",properties:i,required:r,...Object.keys(n).length?{errorMessage:{required:n}}:{},additionalProperties:!1}}(t,e);if(!s)return;try{n=vo.compile(s)}catch{return}i.set(r,n)}return n})(t,i);if(n&&!n(e))for(const t of n.errors??[]){const e=go(t);e&&!(e in r)&&t.message&&(r[e]=t.message)}for(const[n,s]of Object.entries(((t,e,i)=>{const r={},n=e??{};for(const e of Ns(t)){const t=e.configs?.key;if(t)for(const s of e.validations??[]){if("custom"!==s.validator||!s.customValidator)continue;const e=no(`const value = dataMap?.[${JSON.stringify(t)}];\n${s.customValidator}`,n);if(!0!==e&&null!=e&&!(t in r))if("string"==typeof e)r[t]=e;else if(e instanceof Error)r[t]=e.message;else{const e=js(s.message,i);r[t]="string"==typeof e?e:Cs("custom",i)}}}return r})(t,e,i)))n in r||(r[n]=s);const s="object"==typeof e&&null!==e?e:void 0;for(const e of((t,e)=>{const i=new Set,r=(t,n)=>{const s=n||!!t.rules?.length&&!0===so(t.rules,e).hidden,o=t.configs?.key;if(s&&o&&i.add(o),"collection"!==t.type)for(const e of t.children??[])r(e,s)};return r(t,!1),i})(t,s))delete r[e];return{valid:0===Object.keys(r).length,errors:r}};function wo(t){return t.split(".").slice(1).map((t=>`/children/${t}`)).join("")}function bo(t,e){if(t.configs?.uid===e)return"";for(const[i,r]of(t.children??[]).entries()){const t=bo(r,e);if(void 0!==t)return`/children/${i}${t}`}}function _o(t,e){let i=t;for(const t of e.split(".").slice(1))i=i?.children?.[Number(t)];return i}var Eo=(Ss??xs).applyPatch,ko=(t,e,i)=>({spec:Eo(t,e,!0,!1).newDocument,patches:e,inverse:i}),So=(t,e)=>{const i=_o(t,e);if(!i)throw new Error(`No brick at path "${e}"`);return i},xo=(t,e)=>{const i=bo(t,e);if(void 0===i)throw new Error(`No brick with uid "${e}"`);let r=t;for(const t of i.split("/children/").slice(1))r=r.children[Number(t)];return{pointer:i,brick:r}},Oo=t=>JSON.parse(JSON.stringify(t));function jo(t,e,i,r){const n=So(t,i),s=wo(i),o=Oo(e);if(!n.children){const e=`${s}/children`;return ko(t,[{op:"add",path:e,value:[o]}],[{op:"remove",path:e}])}const a=`${s}/children/${Math.min(r??n.children.length,n.children.length)}`;return ko(t,[{op:"add",path:a,value:o}],[{op:"remove",path:a}])}function Po(t,e){if("0"===e)throw new Error("Cannot remove the root brick");const i=So(t,e),r=wo(e);return ko(t,[{op:"remove",path:r}],[{op:"add",path:r,value:i}])}function Io(t,e,i){if("0"===e||"0"===i)throw new Error("Cannot move the root brick");const r=So(t,e),n=e.split(".").map(Number),s=i.split(".").map(Number),o=n.length-1,a=n[o],h=s.length>o&&n.slice(0,o).every(((t,e)=>t===s[e])),u=[...s];if(h){if(u[o]===a&&u.length>n.length)throw new Error(`Cannot move a brick into its own subtree ("${e}" → "${i}")`);u[o]>a&&(u[o]-=1)}const c=wo(e),f=wo(u.join("."));return ko(t,[{op:"remove",path:c},{op:"add",path:f,value:r}],[{op:"remove",path:f},{op:"add",path:c,value:r}])}var Co=t=>({...t,...t.configs?{configs:{...t.configs,uid:crypto.randomUUID()}}:{},...t.children?{children:t.children.map(Co)}:{}});function Ao(t,e){if("0"===e)throw new Error("Cannot duplicate the root brick");const i=So(t,e),r=e.split("."),n=Number(r[r.length-1])+1,s=wo([...r.slice(0,-1),String(n)].join(".")),o=Co(Oo(i));return ko(t,[{op:"add",path:s,value:o}],[{op:"remove",path:s}])}var No=(t,e,i,r,n)=>{const s=`${e}/${i}`;return void 0===n?ko(t,[{op:"add",path:s,value:r}],[{op:"remove",path:s}]):ko(t,[{op:"replace",path:s,value:r}],[{op:"replace",path:s,value:n}])};function To(t,e,i){const{pointer:r,brick:n}=xo(t,e),s={...n.configs,...i};return No(t,r,"configs",s,n.configs)}function Mo(t,e,i){const{pointer:r,brick:n}=xo(t,e),s={...n.styles,...i};return No(t,r,"styles",s,n.styles)}function Ro(t,e,i){const{pointer:r,brick:n}=xo(t,e);return No(t,r,"validations",i,n.validations)}function Do(t,e,i){const{pointer:r,brick:n}=xo(t,e);return No(t,r,"rules",i,n.rules)}class Lo{past=[];future=[];record(t){this.past.push({patches:t.patches,inverse:t.inverse}),this.future=[]}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}undo(t){const e=this.past.pop();if(e)return this.future.push(e),Eo(t,e.inverse,!0,!1).newDocument}redo(t){const e=this.future.pop();if(e)return this.past.push(e),Eo(t,e.patches,!0,!1).newDocument}clear(){this.past=[],this.future=[]}}var zo=t=>"nested-form"===t.id&&"string"==typeof t.configs?.specRef,Uo=t=>{if(!t)return!1;for(const{brick:e}of As(t))if(zo(e)&&e.configs?.specRef)return!0;return!1};async function qo(t,e={}){const i=e.specSourceService??ro.specSourceService,r=e.maxDepth??5,n=async(t,e)=>{if(zo(t)&&t.configs?.specRef){const s=String(t.configs.specRef);if(e.includes(s))throw new Error(`Circular nested form reference: ${[...e,s].join(" → ")}`);if(e.length>=r)throw new Error(`Nested forms exceed the maximum depth of ${r} (${s})`);const o=await i.fetchSpec(s),a=await n(structuredClone(o),[...e,s]);return{type:"panel",id:"group",name:t.name,configs:{...t.configs,label:t.configs.label??a.name},styles:t.styles,rules:t.rules,children:a.children??[]}}return t.children?.length?{...t,children:await Promise.all(t.children.map((t=>n(t,e))))}:t};return n(structuredClone(t),[])}export{Ns as A,mo as B,co as C,js as D,Vs as E,zs as F,Lo as S,Gs as a,Ts as b,jo as c,_o as d,Po as e,Bs as f,so as g,Ao as h,Mo as i,Ro as j,Do as k,As as l,Io as m,Uo as n,qo as o,Os as p,fo as q,Ps as r,ro as s,po as t,To as u,$o as v,Ms as w,lo as x,Ds as y,no as z}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as e,h as r,g as i,H as o}from"./p-qLZlXROB.js";import{getBrickMolds as s,getBrickMoldsGroupedByCategory as n,getBrick as a,registerDefaultBricks as l,newBrickSpec as c}from"./index.esm.js";import{f as d,a as f,g as u,r as p,b as h,w as k,v,s as b,S as g,c as m,d as _,m as y,e as x,h as w,u as j,i as O,j as C,k as S,l as D,n as z,o as M,p as E,q as A,t as T,x as $,y as R,z as I,A as L}from"./p-BrSkjQut.js";function V(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function F(t,e){if(t){if("string"==typeof t)return V(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?V(t,e):void 0}}function N(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,o,s,n,a=[],l=!0,c=!1;try{if(s=(r=r.call(t)).next,0===e);else for(;!(l=(i=s.call(r)).done)&&(a.push(i.value),a.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=r.return&&(n=r.return(),Object(n)!==n))return}finally{if(c)throw o}}return a}}(t,e)||F(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var U,K={},P={};function q(){return U||(U=1,Object.defineProperty(P,"__esModule",{value:!0}),P.bind=void 0,P.bind=function(t,e){var r=e.type,i=e.listener,o=e.options;return t.addEventListener(r,i,o),function(){t.removeEventListener(r,i,o)}}),P}var B,J,H={};function W(){if(B)return H;B=1;var t=H&&H.__assign||function(){return t=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};Object.defineProperty(H,"__esModule",{value:!0}),H.bindAll=void 0;var e=q();function r(t){if(void 0!==t)return"boolean"==typeof t?{capture:t}:t}return H.bindAll=function(i,o,s){var n=o.map((function(o){var n=function(e,i){return null==i?e:t(t({},e),{options:t(t({},r(i)),r(e.options))})}(o,s);return(0,e.bind)(i,n)}));return function(){n.forEach((function(t){return t()}))}},H}function G(){return J||(J=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=t.bind=void 0;var e=q();Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return e.bind}});var r=W();Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return r.bindAll}})}(K)),K}var X=G(),Z="data-pdnd-honey-pot";function Y(t){return t instanceof Element&&t.hasAttribute(Z)}function Q(t){var e=N(document.elementsFromPoint(t.x,t.y),2),r=e[0],i=e[1];return r?Y(r)?null!=i?i:null:r:null}function tt(t){return tt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tt(t)}function et(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=tt(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e);if("object"!=tt(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==tt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var rt={inset:"unset",border:"none",padding:0,margin:0,overflow:"visible",color:"inherit",background:"transparent",width:"auto",height:"auto"};function it(t){var e=null;return function(){if(!e){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];var s=t.apply(this,i);e={result:s}}return e.result}}var ot=it((function(){return"undefined"!=typeof HTMLElement&&"function"==typeof HTMLElement.prototype.showPopover}));function st(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function nt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?st(Object(r),!0).forEach((function(e){et(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):st(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function at(t){var e=function(t){return{x:Math.min(t.x,window.innerWidth-2),y:Math.min(t.y,window.innerHeight-2)}}(function(t){return{x:Math.max(t.x,0),y:Math.max(t.y,0)}}(function(t){return{x:t.x-1,y:t.y-1}}(function(t){return{x:Math.floor(t.x),y:Math.floor(t.y)}}(t.client))));return DOMRect.fromRect({x:e.x,y:e.y,width:2,height:2})}function lt(t){var e=t.clientRect;return{left:"".concat(e.left,"px"),top:"".concat(e.top,"px"),width:"".concat(e.width,"px"),height:"".concat(e.height,"px")}}function ct(t){return function(t){if(Array.isArray(t))return V(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||F(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var dt=it((function(){return navigator.userAgent.includes("Firefox")})),ft=it((function(){var t=navigator.userAgent;return t.includes("AppleWebKit")&&!t.includes("Chrome")})),ut={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};function pt(t){return{altKey:t.altKey,button:t.button,buttons:t.buttons,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX,pageY:t.pageY}}!function(){if("undefined"!=typeof window&&ft()){var t={enterCount:0,isOverWindow:!1};X.bindAll(window,[{type:"dragstart",listener:function(){t.enterCount=0,t.isOverWindow=!0}},{type:"drop",listener:e},{type:"dragend",listener:e},{type:"dragenter",listener:function(e){t.isOverWindow||0!==t.enterCount||(e[ut.isEnteringWindow]=!0),t.isOverWindow=!0,t.enterCount++}},{type:"dragleave",listener:function(e){t.enterCount--,t.isOverWindow&&0===t.enterCount&&(e[ut.isLeavingWindow]=!0,t.isOverWindow=!1)}}],{capture:!0})}function e(){t={enterCount:0,isOverWindow:!1}}}();var ht,kt,vt,bt,gt,mt=(ht=function(t){return t()},kt=[],vt=null,(bt=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];kt=e,vt||(vt=requestAnimationFrame((function(){vt=null,ht.apply(void 0,kt)})))}).cancel=function(){vt&&(cancelAnimationFrame(vt),vt=null)},bt),_t=(gt=null,{schedule:function(t){var e=requestAnimationFrame((function(){gt=null,t()}));gt={frameId:e,fn:t}},flush:function(){gt&&(cancelAnimationFrame(gt.frameId),gt.fn(),gt=null)}}),yt={isActive:!1};function xt(){return!yt.isActive}function wt(t){return t.dataTransfer?t.dataTransfer.setDragImage.bind(t.dataTransfer):null}function jt(t){var e,r=t.event,i=null===(e=t.current[0])||void 0===e?void 0:e.dropEffect;null!=i&&r.dataTransfer&&(r.dataTransfer.dropEffect=i)}var Ot={canStart:xt,start:function(t){var e=t.event,r=t.dragType,i=t.getDropTargetsOver,o=t.dispatchEvent;if(xt()){var s=function(t){var e=t.event,r=t.dragType,i=t.getDropTargetsOver,o=pt(e);return"external"===r.startedFrom?{input:o,dropTargets:[]}:{input:o,dropTargets:i({input:o,source:r.payload,target:e.target,current:[]})}}({event:e,dragType:r,getDropTargetsOver:i});yt.isActive=!0;var n={current:s};jt({event:e,current:s.dropTargets});var a,l,c=function(t){var e=t.source,r=t.initial,i=t.dispatchEvent,o={dropTargets:[]};function s(t){i(t),o={dropTargets:t.payload.location.current.dropTargets}}return{start:function(t){var i={current:r,previous:o,initial:r};s({eventName:"onGenerateDragPreview",payload:{source:e,location:i,nativeSetDragImage:t.nativeSetDragImage}}),_t.schedule((function(){s({eventName:"onDragStart",payload:{source:e,location:i}})}))},dragUpdate:function(t){var i=t.current;_t.flush(),mt.cancel(),s({eventName:"onDropTargetChange",payload:{source:e,location:{initial:r,previous:o,current:i}}})},drag:function(t){var i=t.current;mt((function(){_t.flush(),s({eventName:"onDrag",payload:{source:e,location:{initial:r,previous:o,current:i}}})}))},drop:function(t){var i=t.current,n=t.updatedSourcePayload;_t.flush(),mt.cancel(),s({eventName:"onDrop",payload:{source:null!=n?n:e,location:{current:i,previous:o,initial:r}}})}}}({source:r.payload,dispatchEvent:o,initial:s}),d=X.bindAll(window,[{type:"dragover",listener:function(t){u(t),c.drag({current:n.current})}},{type:"dragenter",listener:u},{type:"dragleave",listener:function(t){var e,i,o;o=(i={dragLeave:t}.dragLeave).relatedTarget,"dragleave"===i.type&&(ft()?function(t){var e=t.dragLeave;return!!ft()&&e.hasOwnProperty(ut.isLeavingWindow)}({dragLeave:i}):null==o||(dt()?"nodeName"in(e=o)&&e.ownerDocument!==document:o instanceof HTMLIFrameElement))&&(f({input:n.current.input,dropTargets:[]}),"external"===r.startedFrom&&p())}},{type:"drop",listener:function(t){n.current={dropTargets:n.current.dropTargets,input:pt(t)},n.current.dropTargets.length?(t.preventDefault(),jt({event:t,current:n.current.dropTargets}),c.drop({current:n.current,updatedSourcePayload:"external"===r.type?r.getDropPayload(t):null}),h()):p()}},{type:"dragend",listener:function(t){n.current={dropTargets:n.current.dropTargets,input:pt(t)},p()}}].concat(ct([{type:"pointermove",listener:(a=0,function(){a<20?a++:l()})},{type:"pointerdown",listener:l=p}])),{capture:!0});c.start({nativeSetDragImage:wt(e)})}function f(t){var e=function(t){var e=t.current,r=t.next;if(e.length!==r.length)return!0;for(var i=0;i<e.length;i++)if(e[i].element!==r[i].element)return!0;return!1}({current:n.current.dropTargets,next:t.dropTargets});n.current=t,e&&c.dragUpdate({current:n.current})}function u(t){var e=pt(t),o=Y(t.target)?Q({x:e.clientX,y:e.clientY}):t.target,s=i({target:o,input:e,source:r.payload,current:n.current.dropTargets});s.length&&(t.preventDefault(),jt({event:t,current:s})),f({dropTargets:s,input:e})}function p(){n.current.dropTargets.length&&f({dropTargets:[],input:n.current.input}),c.drop({current:n.current,updatedSourcePayload:null}),h()}function h(){yt.isActive=!1,d()}}},Ct=new Map;function St(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(){e.forEach((function(t){return t()}))}}function Dt(t,e){var r=e.attribute;return t.setAttribute(r,e.value),function(){return t.removeAttribute(r)}}function zt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function Mt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?zt(Object(r),!0).forEach((function(e){et(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):zt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Et(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return At(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?At(t,e):void 0}}(t))||e){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return n=t.done,t},e:function(t){a=!0,s=t},f:function(){try{n||null==r.return||r.return()}finally{if(a)throw s}}}}function At(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function Tt(t){return t.slice(0).reverse()}function $t(t){var e=t.typeKey,r=t.defaultDropEffect,i=new WeakMap,o="data-drop-target-for-".concat(e),s="[".concat(o,"]");function n(t){var e,o,a,l,c=t.source,d=t.target,f=t.input,u=t.result,p=void 0===u?[]:u;if(null==d)return p;if(!(d instanceof Element))return d instanceof Node?n({source:c,target:d.parentElement,input:f,result:p}):p;var h=d.closest(s);if(null==h)return p;var k=i.get(h);if(null==k)return p;var v={input:f,source:c,element:k.element};if(k.canDrop&&!k.canDrop(v))return n({source:c,target:k.element.parentElement,input:f,result:p});var b=null!==(e=null===(o=k.getData)||void 0===o?void 0:o.call(k,v))&&void 0!==e?e:{},g=null!==(a=null===(l=k.getDropEffect)||void 0===l?void 0:l.call(k,v))&&void 0!==a?a:r,m={data:b,element:k.element,dropEffect:g,isActiveDueToStickiness:!1};return n({source:c,target:k.element.parentElement,input:f,result:[].concat(ct(p),[m])})}function a(t){var e,r=t.eventName,o=t.payload,s=Et(o.location.current.dropTargets);try{for(s.s();!(e=s.n()).done;){var n,a=e.value,l=i.get(a.element),c=Mt(Mt({},o),{},{self:a});null==l||null===(n=l[r])||void 0===n||n.call(l,c)}}catch(t){s.e(t)}finally{s.f()}}var l={onGenerateDragPreview:a,onDrag:a,onDragStart:a,onDrop:a,onDropTargetChange:function(t){var e,r=t.payload,o=new Set(r.location.current.dropTargets.map((function(t){return t.element}))),s=new Set,n=Et(r.location.previous.dropTargets);try{for(n.s();!(e=n.n()).done;){var a,l=e.value;s.add(l.element);var c,d=i.get(l.element),f=o.has(l.element),u=Mt(Mt({},r),{},{self:l});null==d||null===(a=d.onDropTargetChange)||void 0===a||a.call(d,u),f||null==d||null===(c=d.onDragLeave)||void 0===c||c.call(d,u)}}catch(t){n.e(t)}finally{n.f()}var p,h=Et(r.location.current.dropTargets);try{for(h.s();!(p=h.n()).done;){var k,v,b=p.value;if(!s.has(b.element)){var g=Mt(Mt({},r),{},{self:b}),m=i.get(b.element);null==m||null===(k=m.onDropTargetChange)||void 0===k||k.call(m,g),null==m||null===(v=m.onDragEnter)||void 0===v||v.call(m,g)}}}catch(t){h.e(t)}finally{h.f()}}};return{dropTargetForConsumers:function(t){return it(St(Dt(t.element,{attribute:o,value:"true"}),function(t){return i.set(t.element,t),function(){return i.delete(t.element)}}(t)))},getIsOver:function(t){var e=t.source,r=t.input,o=t.current,s=n({source:e,target:t.target,input:r});if(s.length>=o.length)return s;for(var a=Tt(o),l=Tt(s),c=[],d=0;d<a.length;d++){var f,u=a[d],p=l[d];if(null==p){var h=c[d-1],k=a[d-1];if((null==h?void 0:h.element)!==(null==k?void 0:k.element))break;var v=i.get(u.element);if(!v)break;var b={input:r,source:e,element:v.element};if(v.canDrop&&!v.canDrop(b))break;if(null===(f=v.getIsSticky)||void 0===f||!f.call(v,b))break;c.push(Mt(Mt({},u),{},{isActiveDueToStickiness:!0}))}else c.push(p)}return Tt(c)},dispatchEvent:function(t){l[t.eventName](t)}}}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i}function It(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function Lt(){var t=new Set,e=null;function r(t){e&&(t.canMonitor&&!t.canMonitor(e.canMonitorArgs)||e.active.add(t))}return{dispatchEvent:function(i){var o=i.eventName,s=i.payload;if("onGenerateDragPreview"===o){e={canMonitorArgs:{initial:s.location.initial,source:s.source},active:new Set};var n,a=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rt(t,e):void 0}}(t))||e){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return n=t.done,t},e:function(t){a=!0,s=t},f:function(){try{n||null==r.return||r.return()}finally{if(a)throw s}}}}(t);try{for(a.s();!(n=a.n()).done;)r(n.value)}catch(t){a.e(t)}finally{a.f()}}if(e){for(var l=0,c=Array.from(e.active);l<c.length;l++){var d,f=c[l];e.active.has(f)&&(null===(d=f[o])||void 0===d||d.call(f,s))}"onDrop"===o&&(e.active.clear(),e=null)}},monitorForConsumers:function(i){var o=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?It(Object(r),!0).forEach((function(e){et(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):It(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},i);return t.add(o),r(o),it((function(){t.delete(o),e&&e.active.delete(o)}))}}}var Vt,Ft=it((function(){return navigator.userAgent.toLocaleLowerCase().includes("android")})),Nt="text/plain",Ut=new WeakMap,Kt=(Vt=null,{bindEvents:function(){return Vt=null,X.bind(window,{type:"pointermove",listener:function(t){Vt={x:t.clientX,y:t.clientY}},options:{capture:!0}})},getOnPostDispatch:function(){var t=null;return function(e){var r=e.eventName,i=e.payload;if("onDragStart"===r){var o=i.location.initial.input;t=function(t){var e=t.initial,r=document.createElement("div");r.setAttribute(Z,"true"),ot()&&r.setAttribute("popover","manual");var i=at({client:e});Object.assign(r.style,nt(nt({position:"fixed"},ot()?rt:{zIndex:2147483647}),{},{backgroundColor:"transparent",padding:0,margin:0,boxSizing:"border-box",pointerEvents:"auto"},lt({clientRect:i}))),document.body.appendChild(r),ot()&&r.showPopover();var o=X.bind(window,{type:"pointermove",listener:function(t){i=at({client:{x:t.clientX,y:t.clientY}}),Object.assign(r.style,lt({clientRect:i}))},options:{capture:!0}});return function(t){var e=t.current;if(o(),function(t){var e=t.client,r=t.clientRect;return e.x>=r.x&&e.x<=r.x+r.width&&e.y>=r.y&&e.y<=r.y+r.height}({client:e,clientRect:i}))r.remove();else var s=X.bindAll(window,[{type:"pointerdown",listener:n},{type:"pointermove",listener:n},{type:"focusin",listener:n},{type:"focusout",listener:n},{type:"dragstart",listener:n},{type:"dragenter",listener:n},{type:"dragover",listener:n}],{capture:!0});function n(){s(),r.remove()}}}({initial:null!=Vt?Vt:{x:o.clientX,y:o.clientY}})}if("onDrop"===r){var s,n=i.location.current.input;null===(s=t)||void 0===s||s({current:{x:n.clientX,y:n.clientY}}),t=null,Vt=null}}}}),Pt=function(t){var e=t.typeKey,r=t.mount,i=t.dispatchEventToSource,o=t.onPostDispatch,s=t.defaultDropEffect,n=Lt(),a=$t({typeKey:e,defaultDropEffect:s});function l(t){null==i||i(t),a.dispatchEvent(t),n.dispatchEvent(t),null==o||o(t)}function c(t){Ot.start({event:t.event,dragType:t.dragType,getDropTargetsOver:a.getIsOver,dispatchEvent:l})}return{registerUsage:function(){return i=function(t){var e=t.typeKey,r=t.mount,i=Ct.get(e);if(i)return i.usageCount++,i;var o={typeKey:e,unmount:r(),usageCount:1};return Ct.set(e,o),o}(t={typeKey:e,mount:function(){return r({canStart:Ot.canStart,start:c})}}),function(){i.usageCount--,i.usageCount>0||(i.unmount(),Ct.delete(t.typeKey))};var t,i},dropTarget:a.dropTargetForConsumers,monitor:n.monitorForConsumers}}({typeKey:"element",defaultDropEffect:"move",mount:function(t){return St(Kt.bindEvents(),X.bind(document,{type:"dragstart",listener:function(e){var r,i,o,s,n,a;if(t.canStart(e)&&!e.defaultPrevented&&e.dataTransfer){var l=e.target;if(l instanceof HTMLElement){var c=Ut.get(l);if(c){var d=pt(e),f={element:c.element,dragHandle:null!==(r=c.dragHandle)&&void 0!==r?r:null,input:d};if(!c.canDrag||c.canDrag(f)){if(c.dragHandle){var u=Q({x:d.clientX,y:d.clientY});if(!c.dragHandle.contains(u))return void e.preventDefault()}var p=null!==(i=null===(o=c.getInitialDataForExternal)||void 0===o?void 0:o.call(c,f))&&void 0!==i?i:null;if(p)for(var h=0,k=Object.entries(p);h<k.length;h++){var v=N(k[h],2),b=v[1];e.dataTransfer.setData(v[0],null!=b?b:"")}!Ft()||e.dataTransfer.types.includes(Nt)||e.dataTransfer.types.includes("text/uri-list")||e.dataTransfer.setData(Nt,"pdnd:android-fallback"),e.dataTransfer.setData("application/vnd.pdnd","");var g={element:c.element,dragHandle:null!==(s=c.dragHandle)&&void 0!==s?s:null,data:null!==(n=null===(a=c.getInitialData)||void 0===a?void 0:a.call(c,f))&&void 0!==n?n:{}};t.start({event:e,dragType:{type:"element",payload:g,startedFrom:"internal"}})}else e.preventDefault()}}}}}))},dispatchEventToSource:function(t){var e,r,i=t.eventName,o=t.payload;null===(e=Ut.get(o.source.element))||void 0===e||null===(r=e[i])||void 0===r||r.call(e,o)},onPostDispatch:Kt.getOnPostDispatch()}),qt=Pt.dropTarget;function Bt(t){return it(St(Pt.registerUsage(),function(t){return Ut.set(t.element,t),function(){Ut.delete(t.element)}}(t),Dt(t.element,{attribute:"draggable",value:"true"})))}function Jt(t,e,r){if("new-brick"===t.kind){const i=s().find((e=>e.type===t.moldType&&e.id===t.moldId));if(!i)return;return{source:"new",mold:i,parentPath:e,index:r}}if("move-brick"===t.kind)return{source:"move",from:t.path,parentPath:e,index:r}}const Ht=class{constructor(r){t(this,r),this.brickRemove=e(this,"brickRemove"),this.brickDuplicate=e(this,"brickDuplicate"),this.brickDrop=e(this,"brickDrop"),this.brickSelect=e(this,"brickSelect"),this.selected=!1,this.isDragging=!1,this.isDropTarget=!1,this.cleanups=[]}componentDidLoad(){this.handleEl&&this.cleanups.push(Bt({element:this.handleEl,getInitialData:()=>({kind:"move-brick",path:this.path}),onDragStart:()=>this.isDragging=!0,onDrop:()=>this.isDragging=!1})),this.cleanups.push(qt({element:this.host,onDrag:({location:t})=>{var e;return this.isDropTarget=(null===(e=t.current.dropTargets[0])||void 0===e?void 0:e.element)===this.host},onDragLeave:()=>this.isDropTarget=!1,onDrop:({source:t,location:e})=>{var r;if(this.isDropTarget=!1,(null===(r=e.current.dropTargets[0])||void 0===r?void 0:r.element)!==this.host)return;const i=this.path.split("."),o=Jt(t.data,i.slice(0,-1).join("."),Number(i[i.length-1]));o&&this.brickDrop.emit(o)}}))}disconnectedCallback(){this.cleanups.forEach((t=>t())),this.cleanups=[]}render(){return r("div",{key:"ea1cc1c7af646f403330c98b251714f3968c1aae",class:{"fk-actions":!0,"fk-actions--dragging":this.isDragging,"fk-actions--drop-before":this.isDropTarget,"fk-actions--selected":this.selected},onClick:t=>{t.stopPropagation(),this.brickSelect.emit({path:this.path})}},r("div",{key:"99c08de8c78ff6362103f9e355ff6aa3da1367ee",class:"fk-actions__toolbar"},r("button",{key:"8702b1f565ea639585614d4c6e88b2dc44c7ed7c",type:"button",class:"fk-actions__button fk-actions__handle",ref:t=>this.handleEl=t,title:d("actions.move")},"⠿"),r("button",{key:"7394adc36780dbd61195b69cd21fce3c8a852f2a",type:"button",class:"fk-actions__button",title:d("actions.duplicate"),onClick:t=>{t.stopPropagation(),this.brickDuplicate.emit({path:this.path})}},"⧉"),r("button",{key:"ddea0decbc02a4b0627170c973ed19180aa6f651",type:"button",class:"fk-actions__button fk-actions__button--danger",title:d("actions.delete"),onClick:t=>{t.stopPropagation(),this.brickRemove.emit({path:this.path})}},"✕")),r("slot",{key:"44fa7c12a7581ff6b62f29fb1249d427594b5e1f"}))}get host(){return i(this)}};Ht.style=".fk-actions.sc-fk-brick-actions{position:relative;padding:calc(var(--fk-spacing) / 2);border:1px solid transparent;border-radius:var(--fk-radius)}.fk-actions.sc-fk-brick-actions:hover{border-color:var(--fk-color-border)}.fk-actions--selected.sc-fk-brick-actions,.fk-actions--selected.sc-fk-brick-actions:hover{border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-actions--dragging.sc-fk-brick-actions{opacity:0.5}.fk-actions--drop-before.sc-fk-brick-actions::before{content:'';position:absolute;top:-2px;left:0;right:0;height:3px;border-radius:2px;background:var(--fk-color-primary)}.fk-actions__toolbar.sc-fk-brick-actions{position:absolute;top:calc(var(--fk-spacing) / -2);right:var(--fk-spacing);z-index:1;display:none;gap:2px;padding:2px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);box-shadow:0 2px 6px var(--fk-color-shadow)}.fk-actions.sc-fk-brick-actions:hover>.fk-actions__toolbar.sc-fk-brick-actions{display:flex}.fk-actions__button.sc-fk-brick-actions{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer}.fk-actions__button.sc-fk-brick-actions:hover{background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent);color:var(--fk-color-primary)}.fk-actions__button--danger.sc-fk-brick-actions:hover{background:color-mix(in srgb, var(--fk-color-danger) 12%, transparent);color:var(--fk-color-danger)}.fk-actions__handle.sc-fk-brick-actions{cursor:grab}";const Wt=class{constructor(e){t(this,e),this.query="",this.collapsed={}}toggle(t){this.collapsed=Object.assign(Object.assign({},this.collapsed),{[t]:!this.collapsed[t]})}render(){const t=n(),e=this.query.trim().toLowerCase(),i=Object.entries(t).map((([t,r])=>({category:t,molds:e?r.filter((r=>[r.name,f(`brick.${r.id}.name`,r.name),r.id,t,f(`category.${t}`,t)].some((t=>t.toLowerCase().includes(e))))):r}))).filter((t=>t.molds.length>0));return r(o,{key:"65362cc9fe11c5814857ecb43a4695f09ae8514a"},r("div",{key:"9cdab3a85fef9552d8169f21f23a515b873b6de2",class:"fk-palette"},r("input",{key:"c257151b6d7458cc93bf4a4533c25692ff5820cf",class:"fk-palette__search",type:"search",placeholder:d("palette.search"),value:this.query,onInput:t=>this.query=t.target.value}),i.map((({category:t,molds:i})=>{const o=!e&&this.collapsed[t];return r("section",{class:"fk-palette__group",key:t},r("button",{type:"button",class:"fk-palette__category",onClick:()=>this.toggle(t)},r("span",{class:{"fk-palette__chevron":!0,"fk-palette__chevron--collapsed":o}},"▾"),f(`category.${t}`,t),r("span",{class:"fk-palette__count"},i.length)),o?null:r("div",{class:"fk-palette__items"},i.map((t=>r("fk-brick-mold-item",{brickMold:t,key:`${t.type}:${t.id}`})))))})),0===i.length?r("p",{class:"fk-palette__empty"},d("palette.empty",{query:this.query})):null))}};Wt.style=".fk-palette.sc-fk-brick-list{display:flex;flex-direction:column;gap:var(--fk-spacing);font-family:var(--fk-font)}.fk-palette__search.sc-fk-brick-list{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-palette__search.sc-fk-brick-list:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-palette__category.sc-fk-brick-list{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);width:100%;margin:0 0 calc(var(--fk-spacing) / 2);padding:calc(var(--fk-spacing) / 2) 0;border:none;background:transparent;font:inherit;font-size:0.7rem;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;color:var(--fk-color-muted);cursor:pointer}.fk-palette__category.sc-fk-brick-list:hover{color:var(--fk-color-text)}.fk-palette__chevron.sc-fk-brick-list{display:inline-block;transition:transform 120ms ease}.fk-palette__chevron--collapsed.sc-fk-brick-list{transform:rotate(-90deg)}.fk-palette__count.sc-fk-brick-list{margin-left:auto;font-weight:600;color:var(--fk-color-muted)}.fk-palette__items.sc-fk-brick-list{display:grid;grid-template-columns:repeat(2, minmax(0, 1fr));gap:calc(var(--fk-spacing) / 2)}.fk-palette__empty.sc-fk-brick-list{margin:0;font-size:0.8rem;color:var(--fk-color-muted)}";const Gt=class{constructor(e){t(this,e),this.isDragging=!1}componentDidLoad(){this.cleanup=Bt({element:this.host,getInitialData:()=>({kind:"new-brick",moldType:this.brickMold.type,moldId:this.brickMold.id}),onDragStart:()=>this.isDragging=!0,onDrop:()=>this.isDragging=!1})}disconnectedCallback(){var t;null===(t=this.cleanup)||void 0===t||t.call(this)}render(){return r("div",{key:"0570015fb47b6be613f900a333b061537006edec",class:{"fk-mold":!0,"fk-mold--dragging":this.isDragging},title:f(`brick.${this.brickMold.id}.name`,this.brickMold.name)},r("span",{key:"bf3ab329f7a4b054c56e042dd83822706546c93b",class:"fk-mold__name"},f(`brick.${this.brickMold.id}.name`,this.brickMold.name)))}get host(){return i(this)}};Gt.style=".sc-fk-brick-mold-item-h{display:block;cursor:grab;min-width:0}.fk-mold.sc-fk-brick-mold-item{display:flex;align-items:center;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:var(--fk-color-surface);font-size:0.8rem;transition:border-color 120ms ease, box-shadow 120ms ease}.fk-mold.sc-fk-brick-mold-item:hover{border-color:var(--fk-color-primary);box-shadow:0 1px 4px var(--fk-color-shadow)}.fk-mold--dragging.sc-fk-brick-mold-item{opacity:0.5}.fk-mold__name.sc-fk-brick-mold-item{font-weight:500;color:var(--fk-color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";const Xt=class{constructor(e){t(this,e)}render(){return r(o,{key:"558231ac77ac07f7b40bd08081a498dc5623442c"},r("p",{key:"f1ca1f59750c6ed2b1a3c2e22bd6f7f1dc721496",class:"fk-not-found"},"Brick ",r("slot",{key:"0003d9dcc23c52cb8d466d794eafd4dd6be4b708"})," not found"))}};Xt.style=".fk-not-found.sc-fk-brick-not-found{margin:0;padding:calc(var(--fk-spacing) * 1.5);border:1px dashed var(--fk-color-danger);border-radius:var(--fk-radius);color:var(--fk-color-danger);font-size:0.875rem}";const Zt=class{constructor(r){t(this,r),this.brickDataChange=e(this,"brickDataChange"),this.brickConfigsChange=e(this,"brickConfigsChange"),this.brickStylesChange=e(this,"brickStylesChange"),this.brickValidationsChange=e(this,"brickValidationsChange"),this.brickRulesChange=e(this,"brickRulesChange"),this.brickRemove=e(this,"brickRemove"),this.brickDuplicate=e(this,"brickDuplicate"),this.path="0",this.editable=!1,this.errors={}}render(){var t,e,i,o,s,n;const l=this.brickSpec;if(!l)return null;const c=a(l.type,l.id);if(!c)return r("fk-brick-not-found",null,`${l.type}:${l.id}`);const d=this.editable&&(null===(t=l.editable)||void 0===t||t),f=u(l.rules,this.dataMap);if(!d&&!0===f.hidden)return null;const v="panel"===l.type||"collection"===l.type,b=null===(e=l.configs)||void 0===e?void 0:e.uid,g=(null!==(i=l.children)&&void 0!==i?i:[]).map(((t,e)=>{var i;return r("fk-brick-render",{brickSpec:t,rootSpec:null!==(i=this.rootSpec)&&void 0!==i?i:this.brickSpec,data:this.data,dataMap:this.dataMap,errors:this.errors,locale:this.locale,path:`${this.path}.${e}`,editable:this.editable,selectedUid:this.selectedUid,utils:this.utils})}));d&&v&&g.push(r("fk-drop-area",{path:this.path}));const m={brickSpec:l,configsForm:l.configsForm,configs:p(l.configs,this.locale),locale:this.locale,styles:null!==(o=l.styles)&&void 0!==o?o:{},data:h(l,this.data),dataMap:this.dataMap,rootSpec:null!==(s=this.rootSpec)&&void 0!==s?s:this.brickSpec,error:(null===(n=l.configs)||void 0===n?void 0:n.key)?this.errors[l.configs.key]:void 0,disabled:!d&&!0===f.disabled,path:this.path,editable:d,children:g,validations:l.validations,rules:l.rules,utils:this.utils,onDataChange:t=>{const e=k(l,t);void 0!==e&&this.brickDataChange.emit(e)},onConfigsChange:(t,e)=>this.brickConfigsChange.emit({configs:t,uid:null!=e?e:b}),onStylesChange:(t,e)=>this.brickStylesChange.emit({styles:t,uid:null!=e?e:b}),onValidationsChange:(t,e)=>this.brickValidationsChange.emit({validations:t,uid:null!=e?e:b}),onRulesChange:(t,e)=>this.brickRulesChange.emit({rules:t,uid:null!=e?e:b}),onDelete:t=>this.brickRemove.emit({path:t}),onDuplicate:t=>this.brickDuplicate.emit({path:t})},_=d?c.renderBuilder(m):c.render(m);return d&&"0"!==this.path?r("fk-brick-actions",{path:this.path,selected:void 0!==b&&b===this.selectedUid},_):_}};let Yt;const Qt=class{constructor(r){t(this,r),this.codeChange=e(this,"codeChange"),this.value="",this.placeholder="",this.completions=[],this.disconnected=!1}async componentDidLoad(){const[{EditorState:t},{EditorView:e,keymap:r,lineNumbers:i,placeholder:o},{defaultKeymap:s,history:n,historyKeymap:a},{defaultHighlightStyle:l,syntaxHighlighting:c},{javascript:d,javascriptLanguage:f},{oneDark:u},{autocompletion:p,completionKeymap:h}]=await(null!=Yt?Yt:Yt=Promise.all([import("./p-DtcM1yw5.js"),import("./p-jUqF8CGO.js").then((function(t){return t.i})),import("./p-Do6vaAvb.js"),import("./p-CtXlkz3R.js").then((function(t){return t.w})),import("./p-DZTNUdkF.js"),import("./p-NJy5rYft.js"),import("./p-CzZHZjz2.js")]));if(this.disconnected)return;const k=!!this.host.closest('.dark, [data-fk-theme="dark"]');this.view=new e({parent:this.host,state:t.create({doc:this.value,extensions:[i(),n(),r.of([...s,...a,...h]),d(),p(),f.data.of({autocomplete:t=>{const e=t.matchBefore(/dataMap\s*\.\s*\w*/);if(e){const t=e.text.lastIndexOf(".");return{from:e.from+t+1,options:this.completions.map((t=>({label:t,type:"property"})))}}const r=t.matchBefore(/\w+/);return r||t.explicit?{from:r?r.from:t.pos,options:[{label:"dataMap",type:"variable"},{label:"value",type:"variable"},...this.completions.map((t=>({label:t,type:"variable"})))]}:null}}),...k?[u]:[c(l)],o(this.placeholder),e.domEventHandlers({blur:()=>this.emitIfChanged()})]})})}syncValue(t){if(!this.view||this.view.hasFocus)return;const e=this.view.state.doc.toString();e!==t&&this.view.dispatch({changes:{from:0,to:e.length,insert:t}})}emitIfChanged(){if(!this.view)return;const t=this.view.state.doc.toString();t!==this.value&&this.codeChange.emit(t)}disconnectedCallback(){var t;this.disconnected=!0,null===(t=this.view)||void 0===t||t.destroy(),this.view=void 0}render(){return null}get host(){return i(this)}static get watchers(){return{value:[{syncValue:0}]}}};Qt.style=".sc-fk-code-editor-h{display:block}.sc-fk-code-editor-h .cm-editor.sc-fk-code-editor{min-height:88px;font-size:0.75rem;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface)}.sc-fk-code-editor-h .cm-editor.cm-focused.sc-fk-code-editor{outline:none;border-color:var(--fk-color-primary)}.sc-fk-code-editor-h .cm-gutters.sc-fk-code-editor{border-right:1px solid var(--fk-color-border);background:color-mix(in srgb, var(--fk-color-surface) 70%, transparent);color:var(--fk-color-muted)}.sc-fk-code-editor-h .cm-content.sc-fk-code-editor{font-family:ui-monospace, SFMono-Regular, Menlo, monospace}";const te=class{constructor(r){t(this,r),this.gridValueChange=e(this,"gridValueChange"),this.disabled=!1,this.touched={},this.addRow=t=>{t.preventDefault(),this.gridValueChange.emit([...this.rows(),{}])}}rows(){return Array.isArray(this.value)?this.value:[]}rowSpec(){var t,e;return(null===(t=this.rowSpecCache)||void 0===t?void 0:t.source)!==this.spec&&(this.rowSpecCache={source:this.spec,rowSpec:{type:"panel",id:"grid-row",name:"Row",configs:{key:"row"},children:null!==(e=this.spec.children)&&void 0!==e?e:[]}}),this.rowSpecCache.rowSpec}rowErrors(t){const e=Object.fromEntries(Object.entries(t).filter((([,t])=>""!==t&&null!=t)));return v(this.rowSpec(),e,this.locale).errors}visibleRowErrors(t){var e,r;const i=null!==(e=this.rows()[t])&&void 0!==e?e:{},o=null!==(r=this.touched[t])&&void 0!==r?r:{},s={};for(const[t,e]of Object.entries(this.rowErrors(i)))o[t]&&(s[t]=e);return s}handleRowChange(t){var e,r;t.stopPropagation();const i=t.target.closest("[data-grid-row]"),o=Number(null!==(e=null==i?void 0:i.getAttribute("data-grid-row"))&&void 0!==e?e:-1);if(o<0)return;const s=Object.assign({},null!==(r=this.touched[o])&&void 0!==r?r:{});for(const e of Object.keys(t.detail))s[e]=!0;this.touched=Object.assign(Object.assign({},this.touched),{[o]:s});const n=this.rows().map(((e,r)=>r===o?Object.assign(Object.assign({},e),t.detail):e));this.gridValueChange.emit(n)}async validateRows(){var t,e;const r=this.rows(),i=null!==(e=null===(t=this.spec.configs)||void 0===t?void 0:t.key)&&void 0!==e?e:"grid",o={},s={};return r.forEach(((t,e)=>{var r,n;const a={};for(const t of null!==(r=this.spec.children)&&void 0!==r?r:[])(null===(n=t.configs)||void 0===n?void 0:n.key)&&(a[t.configs.key]=!0);o[e]=a;for(const[r,o]of Object.entries(this.rowErrors(t)))s[`${i}[${e}].${r}`]=o})),this.touched=o,{valid:0===Object.keys(s).length,errors:s}}moveRow(t,e){const r=[...this.rows()],i=t+e;if(i<0||i>=r.length)return;const[o]=r.splice(t,1);r.splice(i,0,o);const s=Object.assign({},this.touched),n=s[t];s[t]=s[i],s[i]=n,this.touched=s,this.gridValueChange.emit(r)}removeRow(t){const e=this.rows().filter(((e,r)=>r!==t)),r={};for(const[e,i]of Object.entries(this.touched)){const o=Number(e);o<t?r[o]=i:o>t&&(r[o-1]=i)}this.touched=r,this.gridValueChange.emit(e.length?e:void 0)}render(){var t;const e=null!==(t=this.spec.children)&&void 0!==t?t:[],i=this.rows();return r("div",{key:"32c03a6c5e156ea13b98188a6ea0a1417d584e12",class:"fk-grid"},0===i.length?r("p",{class:"fk-grid__empty"},d("grid.empty")):null,i.map(((t,o)=>r("div",{class:"fk-grid__row","data-grid-row":o,key:o},r("div",{class:"fk-grid__cells"},e.map(((e,i)=>r("fk-brick-render",{brickSpec:e,data:t,dataMap:t,errors:this.visibleRowErrors(o),locale:this.locale,path:`grid.${o}.${i}`,utils:this.utils})))),r("div",{class:"fk-grid__row-actions"},r("button",{type:"button",class:"fk-grid__move",title:f("grid.moveUp","Move row up"),"aria-label":f("grid.moveUp","Move row up"),disabled:this.disabled||0===o,onClick:t=>{t.preventDefault(),this.moveRow(o,-1)}},"↑"),r("button",{type:"button",class:"fk-grid__move",title:f("grid.moveDown","Move row down"),"aria-label":f("grid.moveDown","Move row down"),disabled:this.disabled||o===i.length-1,onClick:t=>{t.preventDefault(),this.moveRow(o,1)}},"↓"),r("button",{type:"button",class:"fk-grid__remove",title:d("grid.removeRow"),"aria-label":d("grid.removeRow"),disabled:this.disabled,onClick:t=>{t.preventDefault(),this.removeRow(o)}},"✕"))))),r("button",{key:"548ec4b5763e128d428047c06236d13100e76dfa",type:"button",class:"fk-grid__add",disabled:this.disabled,onClick:this.addRow},d("grid.addRow")))}};te.style=".sc-fk-data-grid-h{display:block}.fk-grid.sc-fk-data-grid{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-grid__empty.sc-fk-data-grid{margin:0;padding:var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);font-size:0.85rem;color:var(--fk-color-muted);text-align:center}.fk-grid__row.sc-fk-data-grid{display:flex;align-items:flex-start;gap:var(--fk-spacing);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-grid__cells.sc-fk-data-grid{display:flex;flex:1;flex-wrap:wrap;gap:var(--fk-spacing);min-width:0}.fk-grid__cells.sc-fk-data-grid>*.sc-fk-data-grid{flex:1;min-width:160px}.fk-grid__remove.sc-fk-data-grid{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:4px 6px;border-radius:calc(var(--fk-radius) / 2)}.fk-grid__remove.sc-fk-data-grid:hover:not(:disabled){color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-grid__add.sc-fk-data-grid{align-self:flex-start;font:inherit;font-size:0.8rem;font-weight:600;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-grid__add.sc-fk-data-grid:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-grid__row-actions.sc-fk-data-grid{display:flex;flex-direction:column;gap:2px;flex-shrink:0}.fk-grid__move.sc-fk-data-grid{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:2px 6px;border-radius:calc(var(--fk-radius) / 2)}.fk-grid__move.sc-fk-data-grid:hover:not(:disabled){color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 10%, transparent)}.fk-grid__move.sc-fk-data-grid:disabled{opacity:0.3;cursor:default}.fk-grid__move.sc-fk-data-grid:focus-visible,.fk-grid__remove.sc-fk-data-grid:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:1px}";const ee=class{constructor(r){t(this,r),this.brickDrop=e(this,"brickDrop"),this.empty=!1,this.isOver=!1}componentDidLoad(){this.cleanup=qt({element:this.host,onDragEnter:()=>this.isOver=!0,onDragLeave:()=>this.isOver=!1,onDrop:({source:t,location:e})=>{var r;if(this.isOver=!1,(null===(r=e.current.dropTargets[0])||void 0===r?void 0:r.element)!==this.host)return;const i=Jt(t.data,this.path);i&&this.brickDrop.emit(i)}})}disconnectedCallback(){var t;null===(t=this.cleanup)||void 0===t||t.call(this)}render(){return r("div",{key:"9bb01ac55f2a243766efc8dd7fa2a94bda135067",class:{"fk-drop":!0,"fk-drop--over":this.isOver,"fk-drop--empty":this.empty}},this.empty?r("div",{class:"fk-drop__empty"},r("p",{class:"fk-drop__title"},d("empty.title")),r("span",{class:"fk-drop__hint"},d("empty.hint"))):r("span",{class:"fk-drop__hint"},d("drop.hint")))}get host(){return i(this)}};ee.style=".fk-drop.sc-fk-drop-area{display:flex;align-items:center;justify-content:center;min-height:40px;margin-top:calc(var(--fk-spacing) / 2);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);color:var(--fk-color-muted);font-size:0.75rem;transition:border-color 120ms ease, background-color 120ms ease}.fk-drop--over.sc-fk-drop-area{border-color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 8%, transparent);color:var(--fk-color-primary)}.fk-drop--empty.sc-fk-drop-area{min-height:260px;display:flex;align-items:center;justify-content:center}.fk-drop__empty.sc-fk-drop-area{text-align:center}.fk-drop__title.sc-fk-drop-area{margin:0 0 4px;font-size:1.05rem;font-weight:600;color:var(--fk-color-text)}";const re=class{constructor(r){t(this,r),this.fileValueChange=e(this,"fileValueChange"),this.disabled=!1,this.multiple=!1,this.uploading=!1,this.handleFile=async t=>{var e;const r=t.target,i=Array.from(null!==(e=r.files)&&void 0!==e?e:[]);if(i.length){this.uploading=!0,this.uploadError=void 0;try{const t=[];for(const e of this.multiple?i:i.slice(0,1))t.push(await b.fileUploadService.upload(e,{url:this.uploadUrl}));this.emitFiles(this.multiple?[...this.files,...t]:t)}catch(t){this.uploadError=t instanceof Error?t.message:String(t)}finally{this.uploading=!1,r.value=""}}},this.handleRemove=async t=>{var e,r;this.removingUrl=t.url,this.uploadError=void 0;try{await(null===(r=(e=b.fileUploadService).remove)||void 0===r?void 0:r.call(e,t,{url:this.uploadUrl}))}catch(t){this.uploadError=t instanceof Error?t.message:String(t)}finally{this.removingUrl=void 0,this.emitFiles(this.files.filter((e=>e!==t)))}}}get files(){return Array.isArray(this.value)?this.value:this.value?[this.value]:[]}emitFiles(t){this.fileValueChange.emit(this.multiple?t.length?t:void 0:t[0])}formatSize(t){return t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(1)} MB`}renderFile(t){const e=void 0!==this.removingUrl&&this.removingUrl===t.url;return r("div",{class:"fk-file__selected",key:`${t.url}:${t.name}`},r("span",{class:"fk-file__icon","aria-hidden":"true"},r("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},r("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r("polyline",{points:"14 2 14 8 20 8"}))),r("span",{class:"fk-file__meta"},r("span",{class:"fk-file__name",title:t.name},t.name),r("span",{class:"fk-file__size"},this.formatSize(t.size))),r("button",{type:"button",class:"fk-file__remove",title:d("file.remove"),disabled:this.disabled||e,onClick:e=>{e.preventDefault(),this.handleRemove(t)}},e?"…":"✕"))}render(){const t=this.files,e=this.multiple||0===t.length;return r("div",{key:"b179e3159400056f09024f21657c6378cf13af27",class:"fk-file"},t.map((t=>this.renderFile(t))),e?r("button",{type:"button",class:"fk-file__choose",disabled:this.disabled||this.uploading,onClick:t=>{var e;t.preventDefault(),null===(e=this.inputEl)||void 0===e||e.click()}},this.uploading?d("file.uploading"):this.multiple&&t.length?f("file.addAnother","+ Add a file"):d("file.choose")):null,r("input",{key:"1fae3967a4514742dd2b6f63290c93e1b86f2ec7",class:"fk-file__native",type:"file",accept:this.accept,multiple:this.multiple,disabled:this.disabled,ref:t=>this.inputEl=t,onChange:this.handleFile}),this.uploadError?r("span",{class:"fk-field__error"},this.uploadError):null)}};re.style=".sc-fk-file-input-h{display:block}.fk-file.sc-fk-file-input{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 2);align-items:flex-start}.fk-file__native.sc-fk-file-input{display:none}.fk-file__choose.sc-fk-file-input{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-file__choose.sc-fk-file-input:hover:not(:disabled){border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-file__choose.sc-fk-file-input:disabled{opacity:0.55;cursor:not-allowed}.fk-file__selected.sc-fk-file-input{display:flex;align-items:center;gap:var(--fk-spacing);width:100%;box-sizing:border-box;padding:calc(var(--fk-spacing) * 0.75) var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface)}.fk-file__icon.sc-fk-file-input{display:inline-flex;flex-shrink:0;color:var(--fk-color-primary)}.fk-file__meta.sc-fk-file-input{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}.fk-file__name.sc-fk-file-input{font-size:0.85rem;font-weight:600;color:var(--fk-color-text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.fk-file__size.sc-fk-file-input{font-size:0.72rem;color:var(--fk-color-muted);white-space:nowrap}.fk-file__remove.sc-fk-file-input{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.8rem;cursor:pointer;padding:4px 6px;border-radius:calc(var(--fk-radius) / 2);flex-shrink:0}.fk-file__remove.sc-fk-file-input:hover:not(:disabled){background:color-mix(in srgb, var(--fk-color-danger) 12%, transparent)}.fk-file__remove.sc-fk-file-input:hover:not(:disabled){color:var(--fk-color-danger)}";const ie=class{constructor(r){t(this,r),this.specChange=e(this,"specChange"),this.locales=[],this.currentData={},this.copied=!1,this.history=new g,this.importFromClipboard=async()=>{try{const t=await navigator.clipboard.readText();this.importSpec(t,!1)}catch(t){this.flashImportError(d("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 t=new Blob([this.specJson()],{type:"application/json"}),e=URL.createObjectURL(t),r=document.createElement("a");r.href=e,r.download="form-spec.json",r.click(),URL.revokeObjectURL(e)},this.undo=()=>{if(!this.currentSpec)return;const t=this.history.undo(this.currentSpec);void 0!==t&&(this.currentSpec=t,this.specChange.emit({spec:t,patches:[],inverse:[]}))},this.redo=()=>{if(!this.currentSpec)return;const t=this.history.redo(this.currentSpec);void 0!==t&&(this.currentSpec=t,this.specChange.emit({spec:t,patches:[],inverse:[]}))}}componentWillLoad(){l(),this.editLocale=this.locales[0],this.currentSpec=this.spec,this.currentData=Object.assign({},this.data)}syncSpec(t){this.currentSpec=t,this.history.clear()}handleBrickDrop(t){var e,r;t.stopPropagation();const{source:i,mold:o,from:s,parentPath:n,index:a}=t.detail;if("new"===i&&o){const t=c(o.type,o.id);if(!t)return;return this.currentSpec?void this.applyUpdate(m(this.currentSpec,t,n,a)):void this.setRootSpec("panel"===t.type?t:this.wrapInRootGroup(t))}if("move"===i&&s&&this.currentSpec){if(n===s||n.startsWith(`${s}.`))return;const t=_(this.currentSpec,n);if(!t)return;const i=null!==(r=null===(e=t.children)||void 0===e?void 0:e.length)&&void 0!==r?r:0,o=s.split("."),l=o.slice(0,-1).join("."),c=Number(o[o.length-1]),d=null!=a?a:i;if(l===n&&(d===c||d===c+1))return;this.applyUpdate(y(this.currentSpec,s,`${n}.${d}`))}}handleBrickRemove(t){t.stopPropagation(),this.currentSpec&&("0"!==t.detail.path?this.applyUpdate(x(this.currentSpec,t.detail.path)):this.setRootSpec(void 0))}handleBrickDuplicate(t){t.stopPropagation(),this.currentSpec&&this.applyUpdate(w(this.currentSpec,t.detail.path))}handleConfigsChange(t){t.stopPropagation(),this.currentSpec&&t.detail.uid&&this.applyUpdate(j(this.currentSpec,t.detail.uid,t.detail.configs))}handleStylesChange(t){t.stopPropagation(),this.currentSpec&&t.detail.uid&&this.applyUpdate(O(this.currentSpec,t.detail.uid,t.detail.styles))}handleValidationsChange(t){t.stopPropagation(),this.currentSpec&&t.detail.uid&&this.applyUpdate(C(this.currentSpec,t.detail.uid,t.detail.validations))}handleRulesChange(t){t.stopPropagation(),this.currentSpec&&t.detail.uid&&this.applyUpdate(S(this.currentSpec,t.detail.uid,t.detail.rules))}handleDataChange(t){this.currentData=t.detail.data}handlePaste(t){var e;const r=t.target;(null==r?void 0:r.closest("input, textarea, select, [contenteditable]"))||this.importSpec(null===(e=t.clipboardData)||void 0===e?void 0:e.getData("text/plain"),!0)}importSpec(t,e){if(t)try{const e=JSON.parse(t);if("object"!=typeof e||null===e||"string"!=typeof e.type||"string"!=typeof e.id)throw new Error("not a brick spec");this.selectedUid=void 0,this.importError=void 0,this.setRootSpec(this.ensureUids(e))}catch(t){e||this.flashImportError(d("builder.importInvalid"))}else e||this.flashImportError(d("builder.importInvalid"))}ensureUids(t){var e;const r=structuredClone(t);for(const{brick:t}of D(r))(null===(e=t.configs)||void 0===e?void 0:e.uid)||(t.configs=Object.assign(Object.assign({},t.configs),{uid:crypto.randomUUID()}));return r}flashImportError(t){this.importError=t,setTimeout((()=>this.importError=void 0),4e3)}handleBrickSelect(t){var e,r;t.stopPropagation(),this.currentSpec&&(this.selectedUid=null===(r=null===(e=_(this.currentSpec,t.detail.path))||void 0===e?void 0:e.configs)||void 0===r?void 0:r.uid)}findSelected(){var t;if(this.currentSpec&&this.selectedUid)for(const{brick:e,path:r}of D(this.currentSpec))if((null===(t=e.configs)||void 0===t?void 0:t.uid)===this.selectedUid)return{brick:e,path:r}}inputFieldKeys(){var t;const e=[];for(const{brick:r}of D(this.currentSpec)){const i=null===(t=r.configs)||void 0===t?void 0:t.key;"input"===r.type&&i&&e.push(i)}return e}wrapInRootGroup(t){const e=c("panel","column");return e?Object.assign(Object.assign({},e),{name:"Form",children:[t]}):t}setRootSpec(t){this.currentSpec=t,this.history.clear(),this.specChange.emit({spec:t,patches:[],inverse:[]})}applyUpdate(t){this.history.record(t),this.currentSpec=t.spec,this.specChange.emit({spec:t.spec,patches:t.patches,inverse:t.inverse})}specJson(){return JSON.stringify(this.currentSpec,null,2)}render(){return r("div",{key:"af343ea1be4efda16bebec84fdae257bb8716da5",class:"fk-builder"},r("aside",{key:"da2b0c2ce2a25f177cb9e06281e21a25c7534ea8",class:"fk-builder__palette"},r("fk-brick-list",{key:"ffa4c165dd42f4883d852bcd43ec5ddce2394995",locale:this.locale})),r("main",{key:"99382c12d06cf3bcf3ff489727a4a6e3d8944348",class:"fk-builder__main"},r("div",{key:"cd0cbfe8e34670419ba09fcb729c3f556e5c958c",class:"fk-builder__toolbar"},r("button",{key:"62f12c0c4be9af7e11df093fae356aab366903e3",type:"button",class:"fk-builder__tool",disabled:!this.history.canUndo,onClick:this.undo},"↩ ",d("builder.undo")),r("button",{key:"91967d3a1ce4c23b288a75e01e0b8616aee71a01",type:"button",class:"fk-builder__tool",disabled:!this.history.canRedo,onClick:this.redo},"↪ ",d("builder.redo")),r("span",{key:"0229215d152c71d6b66ab27c408a02ecab3ce2d6",class:"fk-builder__spacer"}),this.locales.length>1?r("select",{class:"fk-builder__tool","aria-label":d("builder.editLocale"),onChange:t=>this.editLocale=t.target.value},this.locales.map((t=>r("option",{value:t,selected:t===this.editLocale},t.toUpperCase())))):null,this.importError?r("span",{class:"fk-builder__import-error"},this.importError):null,r("button",{key:"c0ebdb023aeace792edaa6deee6394d50ef56899",type:"button",class:"fk-builder__tool",onClick:this.importFromClipboard},"⤓ ",d("builder.importJson")),r("button",{key:"51fb849b1e427b0c53126771baa02ed6d74b8f65",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.copySpec},"⧉ ",d(this.copied?"builder.copied":"builder.copyJson")),r("button",{key:"a4fb8c2fb273777b89abc3aa957a78ea46bc805c",type:"button",class:"fk-builder__tool",disabled:!this.currentSpec,onClick:this.downloadSpec},"⬇ ",d("builder.downloadJson"))),r("div",{key:"0096a51dc1e390d00865bc124958a0caa8c29c80",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:"be3d4d8f6c8d8dd3be892a91d8b47cf197620f74",class:"fk-builder__inspector"},(()=>{const t=this.findSelected();return t?r("fk-property-panel",{brick:t.brick,fields:this.inputFieldKeys(),locales:this.locales,locale:this.locale,editLocale:this.editLocale}):r("p",{class:"fk-builder__hint"},d("builder.hint"))})()))}static get watchers(){return{spec:[{syncSpec:0}]}}};ie.style=".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;text-transform:none;letter-spacing:normal;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)}";const oe=class{constructor(r){t(this,r),this.formDataChange=e(this,"formDataChange"),this.formSubmit=e(this,"formSubmit"),this.editable=!1,this.currentData={},this.touched={},this.expanding=!1,this.utils={validateForm:()=>({isValid:this.runValidation().valid})}}componentWillLoad(){return 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||!z(this.spec))return void(this.expandedSpec=void 0);const t=this.spec;this.expanding=!0;try{const e=await M(t);this.spec===t&&(this.expandedSpec=e)}catch(e){this.spec===t&&(this.expandedSpec=void 0,this.expandError=e instanceof Error?e.message:String(e))}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 e=Object.assign({},this.touched);for(const r of Object.keys(t.detail))e[r]=!0;this.touched=e;const{valid:r,errors:i}=this.runValidation();this.formDataChange.emit({data:this.publicData(),isValid:r,errors:i})}applyValueEffects(t){var e,r;let i=t;for(const{brick:t}of D(this.effectiveSpec())){const o=null===(e=t.configs)||void 0===e?void 0:e.key;if(!o||!(null===(r=t.rules)||void 0===r?void 0:r.length))continue;const s=u(t.rules,i);void 0!==s.value&&i[o]!==s.value&&(i=Object.assign(Object.assign({},i),{[o]:s.value}))}return i}async validate(){var t;const e={};for(const{brick:r}of D(this.effectiveSpec())){const i=null===(t=r.configs)||void 0===t?void 0:t.key;i&&(e[i]=!0)}this.touched=e;const r=this.runValidation(),i=Object.assign({},r.errors);let o=r.valid;const s=Array.from(this.host.querySelectorAll("fk-data-grid"));for(const t of s){const e=await t.validateRows();o=o&&e.valid,Object.assign(i,e.errors)}const n={valid:o,errors:i};return this.formDataChange.emit({data:this.publicData(),isValid:n.valid,errors:n.errors}),n}handleStepTouch(t){t.stopPropagation();const e=Object.assign({},this.touched);for(const r of t.detail.keys)e[r]=!0;this.touched=e}async handleStepperSubmit(t){t.stopPropagation();const e=await this.validate();this.formSubmit.emit({data:this.publicData(),isValid:e.valid,errors:e.errors})}runValidation(){const t=Object.fromEntries(Object.entries(this.currentData).filter((([,t])=>""!==t&&null!=t)));return v(this.effectiveSpec(),t,this.locale)}visibleErrors(){if(this.editable)return{};const t={};for(const[e,r]of Object.entries(this.runValidation().errors))this.touched[e]&&(t[e]=r);return t}render(){return this.spec?this.expanding?r("p",{class:"fk-form__expanding"},d("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 i(this)}static get watchers(){return{data:[{syncData:0}],spec:[{onSpecChange:0}]}}};oe.style=".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)}";const se=class{constructor(r){t(this,r),this.brickConfigsChange=e(this,"brickConfigsChange"),this.brickValidationsChange=e(this,"brickValidationsChange"),this.brickStylesChange=e(this,"brickStylesChange"),this.fields=[],this.locales=[],this.activeTab="config",this.newStyleKey=""}onBrickChange(){this.availableTabs().some((t=>t.id===this.activeTab))||(this.activeTab="config")}availableTabs(){const t=[{id:"config",label:d("panel.tab.config")}];return"input"===this.brick.type&&t.push({id:"validation",label:d("panel.tab.validation")}),t.push({id:"styles",label:d("panel.tab.styles")},{id:"rules",label:d("panel.tab.rules")}),t}localized(t,e){var r;if(this.locales.length<=1)return e||void 0;const i=E(t)?Object.assign({},t):{};return"string"==typeof t&&t&&!E(t)&&(i[this.locales[0]]=t),i[null!==(r=this.editLocale)&&void 0!==r?r:this.locales[0]]=e,i}readLocalized(t){var e,r,i;return E(t)?null!==(r=t[null!==(e=this.editLocale)&&void 0!==e?e:this.locales[0]])&&void 0!==r?r:"":null!==(i=t)&&void 0!==i?i:""}writeTextConfig(t,e){var r;this.emitConfigs({[t]:this.localized(null===(r=this.brick.configs)||void 0===r?void 0:r[t],e)})}emitConfigs(t){var e;const r=null===(e=this.brick.configs)||void 0===e?void 0:e.uid;r&&this.brickConfigsChange.emit({configs:t,uid:r})}emitValidations(t){var e;const r=null===(e=this.brick.configs)||void 0===e?void 0:e.uid;r&&this.brickValidationsChange.emit({validations:t,uid:r})}emitStyles(t){var e;const r=null===(e=this.brick.configs)||void 0===e?void 0:e.uid;r&&this.brickStylesChange.emit({styles:t,uid:r})}validationOf(t){var e;return null===(e=this.brick.validations)||void 0===e?void 0:e.find((e=>e.validator===t))}setValidation(t,e,r={}){var i;const o=this.validationOf(t),s=(null!==(i=this.brick.validations)&&void 0!==i?i:[]).filter((e=>e.validator!==t));this.emitValidations(e?[...s,Object.assign(Object.assign(Object.assign({},o),{validator:t}),r)]:s)}addStyle(t){const e=this.newStyleKey.trim();e&&(this.emitStyles({[e]:t}),this.newStyleKey="")}textField(t,e,i){var o;return r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},t),r("input",{class:"fk-props__input",type:"text",value:null!==(o=e)&&void 0!==o?o:"",onChange:t=>i(t.target.value)}))}optionsFields(){var t,e,i;const o=this.brick.configs;if(!o||!("options"in o)&&!("optionsSource"in o))return[];const s="optionsSource"in o,n=s&&null!==(t=o.optionsSource)&&void 0!==t?t:"static",a=s?[r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},d("panel.optionsSource")),r("select",{class:"fk-props__input",onChange:t=>this.emitConfigs({optionsSource:t.target.value})},["static","dataMap","remote","js","catalog"].map((t=>r("option",{value:t,selected:t===n},t)))))]:[];return"static"===n&&a.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},d("panel.options")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:t=>this.writeTextConfig("options",t.target.value)},this.readLocalized(o.options)))),"dataMap"===n&&a.push(this.textField(d("panel.dataKey"),o.optionsPath,(t=>this.emitConfigs({optionsPath:t})))),"remote"===n&&a.push(this.textField(d("panel.url"),o.optionsUrl,(t=>this.emitConfigs({optionsUrl:t}))),r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},d("panel.headers")),r("textarea",{class:"fk-props__input fk-props__input--textarea",placeholder:"Authorization: Bearer {token}",onChange:t=>this.emitConfigs({optionsHeaders:t.target.value||void 0})},null!==(e=o.optionsHeaders)&&void 0!==e?e:"")),this.textField(d("panel.searchParam"),o.searchParam,(t=>this.emitConfigs({searchParam:t||void 0})))),"js"===n&&a.push(r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},"Code"),r("fk-code-editor",{completions:this.fields,value:null!==(i=o.optionsCode)&&void 0!==i?i:"",placeholder:"return dataMap.country === 'BJ' ? ['Cotonou'] : ['Paris'];",onCodeChange:t=>this.emitConfigs({optionsCode:t.detail})}))),"catalog"===n&&a.push(this.textField(d("panel.optionsRef"),o.optionsRef,(t=>this.emitConfigs({optionsRef:t})))),"remote"!==n&&"js"!==n&&"catalog"!==n||a.push(this.textField(d("panel.labelKey"),o.labelKey,(t=>this.emitConfigs({labelKey:t}))),this.textField(d("panel.valueKey"),o.valueKey,(t=>this.emitConfigs({valueKey:t})))),a}renderConfigTab(){const t=this.brick.configs,e="input"===this.brick.type;return r("section",{class:"fk-props__section"},this.textField(d("panel.key"),null==t?void 0:t.key,(t=>this.emitConfigs({key:t}))),this.textField(d("panel.label"),this.readLocalized(null==t?void 0:t.label),(t=>this.writeTextConfig("label",t))),e?[this.textField(d("panel.placeholder"),this.readLocalized(null==t?void 0:t.placeholder),(t=>this.writeTextConfig("placeholder",t))),this.textField(d("panel.prefix"),null==t?void 0:t.prefix,(t=>this.emitConfigs({prefix:t||void 0}))),this.textField(d("panel.suffix"),null==t?void 0:t.suffix,(t=>this.emitConfigs({suffix:t||void 0})))]:null,t&&"specRef"in t?this.textField(f("panel.specRef","Referenced form (specRef)"),t.specRef,(t=>this.emitConfigs({specRef:t}))):null,t&&"mask"in t?this.textField(f("panel.mask","Input mask (9=digit, a=letter, *=any)"),t.mask,(t=>this.emitConfigs({mask:t}))):null,t&&"accept"in t?this.textField(f("panel.accept","Accepted file types"),t.accept,(t=>this.emitConfigs({accept:t}))):null,t&&"uploadUrl"in t?this.textField(f("panel.uploadUrl","Upload URL"),t.uploadUrl,(t=>this.emitConfigs({uploadUrl:t}))):null,this.optionsFields(),Object.entries(null!=t?t:{}).filter((([,t])=>"boolean"==typeof t)).map((([t,e])=>r("label",{class:"fk-props__field fk-props__field--inline",key:t},r("input",{type:"checkbox",checked:!0===e,onChange:e=>this.emitConfigs({[t]:e.target.checked})}),r("span",{class:"fk-props__label"},f(`panel.cfg.${t}`,t))))),t&&"content"in t?r("label",{class:"fk-props__field"},r("span",{class:"fk-props__label"},d("panel.content")),r("textarea",{class:"fk-props__input fk-props__input--textarea",onChange:t=>this.writeTextConfig("content",t.target.value)},this.readLocalized(t.content))):null)}validationRow(t,e,i){const o=this.validationOf(t);return r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!o,onChange:e=>this.setValidation(t,e.target.checked)}),r("span",{class:"fk-props__label"},e)),o&&i?r("input",{class:"fk-props__input",type:i,placeholder:"number"===i?"value":"regex",value:null==o.value?"":String(o.value),onChange:e=>{const r=e.target.value;this.setValidation(t,!0,{value:"number"===i?""===r?void 0:Number(r):r||void 0})}}):null,o?this.textField(d("panel.errorMessage"),this.readLocalized(o.message),(e=>this.setValidation(t,!0,{message:this.localized(o.message,e)}))):null)}renderValidationTab(){var t;const e=this.brick.dataType,i=this.validationOf("custom");return r("section",{class:"fk-props__section"},this.validationRow("required",d("panel.required")),"string"===e?[this.validationRow("minLength",d("panel.minLength"),"number"),this.validationRow("maxLength",d("panel.maxLength"),"number"),this.validationRow("pattern",d("panel.pattern"),"text"),this.validationRow("email",d("panel.emailFormat")),this.validationRow("url",d("panel.urlFormat"))]:null,"number"===e?[this.validationRow("min",d("panel.min"),"number"),this.validationRow("max",d("panel.max"),"number")]:null,"array"===e?[this.validationRow("minItems",d("panel.minItems"),"number"),this.validationRow("maxItems",d("panel.maxItems"),"number")]:null,r("div",{class:"fk-props__vrule"},r("label",{class:"fk-props__field fk-props__field--inline"},r("input",{type:"checkbox",checked:!!i,onChange:t=>{var e;return this.setValidation("custom",t.target.checked,{customValidator:null!==(e=null==i?void 0:i.customValidator)&&void 0!==e?e:"return true;"})}}),r("span",{class:"fk-props__label"},d("panel.custom"))),i?r("fk-code-editor",{completions:this.fields,value:null!==(t=i.customValidator)&&void 0!==t?t:"",placeholder:'return value?.startsWith("BJ-") ? true : "Must start with BJ-";',onCodeChange:t=>this.setValidation("custom",!0,{customValidator:t.detail})}):null,i?this.textField(d("panel.fallbackMessage"),this.readLocalized(i.message),(t=>this.setValidation("custom",!0,{message:this.localized(i.message,t)}))):null))}renderStylesTab(){var t;return r("section",{class:"fk-props__section"},Object.entries(null!==(t=this.brick.styles)&&void 0!==t?t:{}).map((([t,e])=>r("div",{class:"fk-props__style-row",key:t},r("span",{class:"fk-props__style-key"},t),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",value:String(null!=e?e:""),onChange:e=>this.emitStyles({[t]:e.target.value})}),r("button",{type:"button",class:"fk-props__remove",title:"Remove style",onClick:()=>this.emitStyles({[t]:void 0})},"✕")))),r("div",{class:"fk-props__style-row"},r("input",{class:"fk-props__input",type:"text",placeholder:d("panel.styleProperty"),value:this.newStyleKey,onInput:t=>this.newStyleKey=t.target.value}),r("input",{class:"fk-props__input fk-props__input--grow",type:"text",placeholder:d("panel.styleValue"),onChange:t=>{const e=t.target;this.addStyle(e.value),e.value=""}})))}render(){return r("div",{key:"63f3cd86b0898ce6108378c8510395a6611b5f07",class:"fk-props"},r("header",{key:"ad82d731d10955063e51ad695f0de7d44c7d5fc1",class:"fk-props__header"},r("span",{key:"9e502e5224f8dedf05d8075f995e7778bf18227d",class:"fk-props__type"},this.brick.type),r("h4",{key:"b373bac9ceebab82730d186d665954ac087972fe",class:"fk-props__title"},f(`brick.${this.brick.id}.name`,this.brick.name))),r("div",{key:"81d3770256d746e85270676c1dad68aeebc2389b",class:"fk-props__tabs"},this.availableTabs().map((t=>r("button",{key:t.id,type:"button",class:{"fk-props__tab":!0,"fk-props__tab--active":this.activeTab===t.id},onClick:()=>this.activeTab=t.id},t.label)))),"config"===this.activeTab?this.renderConfigTab():null,"validation"===this.activeTab?this.renderValidationTab():null,"styles"===this.activeTab?this.renderStylesTab():null,"rules"===this.activeTab?r("section",{class:"fk-props__section"},r("fk-rules-editor",{brick:this.brick,fields:this.fields})):null)}static get watchers(){return{brick:[{onBrickChange:0}]}}};se.style=".sc-fk-property-panel-h{display:block}.fk-props.sc-fk-property-panel{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) * 1.5)}.fk-props__header.sc-fk-property-panel{display:flex;flex-direction:column;gap:2px}.fk-props__type.sc-fk-property-panel{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-primary)}.fk-props__title.sc-fk-property-panel{margin:0;font-size:0.95rem;color:var(--fk-color-text)}.fk-props__section.sc-fk-property-panel{display:flex;flex-direction:column;gap:var(--fk-spacing);padding-top:var(--fk-spacing)}.fk-props__tabs.sc-fk-property-panel{display:flex;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-props__tab.sc-fk-property-panel{font:inherit;font-size:0.72rem;font-weight:600;padding:5px 9px;border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);text-transform:none;letter-spacing:normal;cursor:pointer}.fk-props__tab.sc-fk-property-panel:hover{color:var(--fk-color-text)}.fk-props__tab--active.sc-fk-property-panel{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary)}.fk-props__section-title.sc-fk-property-panel{margin:0;font-size:0.7rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-props__field.sc-fk-property-panel{display:flex;flex-direction:column;gap:4px;font-style:normal;text-decoration:none}.fk-props__field--inline.sc-fk-property-panel{flex-direction:row;align-items:center;gap:8px}.fk-props__label.sc-fk-property-panel{font-size:0.75rem;font-weight:600;color:var(--fk-color-muted);font-style:normal;text-decoration:none}.fk-props__input.sc-fk-property-panel{font:inherit;font-size:0.85rem;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-props__input.sc-fk-property-panel:focus{outline:none;border-color:var(--fk-color-primary);box-shadow:0 0 0 2px color-mix(in srgb, var(--fk-color-primary) 20%, transparent)}.fk-props__input--textarea.sc-fk-property-panel{min-height:72px;resize:vertical}.fk-props__vrule.sc-fk-property-panel{display:flex;flex-direction:column;gap:6px;padding:calc(var(--fk-spacing) / 1.5);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5)}.fk-props__style-row.sc-fk-property-panel{display:flex;align-items:center;gap:6px}.fk-props__style-key.sc-fk-property-panel{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;color:var(--fk-color-text);min-width:72px}.fk-props__input--grow.sc-fk-property-panel{flex:1;min-width:0}.fk-props__remove.sc-fk-property-panel{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-props__remove.sc-fk-property-panel:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}";const ne=[{id:"equals",label:"equals"},{id:"notEquals",label:"does not equal"},{id:"greaterThan",label:"is greater than"},{id:"lessThan",label:"is less than"},{id:"isEmpty",label:"is empty"},{id:"isNotEmpty",label:"is not empty"}];function ae(t){const e={var:t.field};switch(t.operator){case"equals":return{"==":[e,t.value]};case"notEquals":return{"!=":[e,t.value]};case"greaterThan":return{">":[e,t.value]};case"lessThan":return{"<":[e,t.value]};case"isEmpty":return{"!":e};case"isNotEmpty":return{"!!":e}}}const le=t=>null!==t&&"object"==typeof t&&"string"==typeof t.var?t.var:void 0,ce={"==":"equals","!=":"notEquals",">":"greaterThan","<":"lessThan"};function de(t){if(!t||"object"!=typeof t)return;const e=Object.entries(t);if(1!==e.length)return;const[r,i]=e[0];if("!"===r||"!!"===r){const t=le(Array.isArray(i)?i[0]:i);if(!t)return;return{field:t,operator:"!"===r?"isEmpty":"isNotEmpty"}}const o=ce[r];if(!o||!Array.isArray(i)||2!==i.length)return;const s=le(i[0]);return s?{field:s,operator:o,value:i[1]}:void 0}function fe(t){if(""===t)return"";try{return JSON.parse(t)}catch(e){return t}}const ue=["hidden","disabled","required","value"],pe=class{constructor(r){t(this,r),this.brickRulesChange=e(this,"brickRulesChange"),this.fields=[],this.forcedModes={},this.jsonErrors={},this.codeErrors={},this.addRule=()=>{var t;this.commit([...this.rules(),{name:`Rule ${this.rules().length+1}`,type:"jsonLogic",logic:ae({field:null!==(t=this.fields[0])&&void 0!==t?t:"",operator:"equals",value:""}),effects:[{property:{target:"hidden",type:"boolean"},boolean:!0}]}])}}rules(){var t;return null!==(t=this.brick.rules)&&void 0!==t?t:[]}commit(t){var e;const r=null===(e=this.brick.configs)||void 0===e?void 0:e.uid;r&&this.brickRulesChange.emit({rules:t,uid:r})}updateRule(t,e){this.commit(this.rules().map(((r,i)=>i===t?Object.assign(Object.assign({},r),e):r)))}removeRule(t){this.commit(this.rules().filter(((e,r)=>r!==t))),this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[t]:void 0})}modeOf(t,e){return"javaScript"===e.type?"javaScript":this.forcedModes[t]?this.forcedModes[t]:de(e.logic)?"simple":"json"}setMode(t,e,r){var i,o,s;this.forcedModes=Object.assign(Object.assign({},this.forcedModes),{[t]:r}),this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[t]:""}),this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[t]:""}),"javaScript"!==r||"javaScript"===e.type?"javaScript"!==r&&"jsonLogic"!==e.type&&this.updateRule(t,{type:"jsonLogic",logic:null!==(o=e.logic)&&void 0!==o?o:ae({field:null!==(s=this.fields[0])&&void 0!==s?s:"",operator:"equals",value:""})}):this.updateRule(t,{type:"javaScript",code:null!==(i=e.code)&&void 0!==i?i:"return true;"})}updateCondition(t,e,r){var i,o;const s=null!==(i=de(e.logic))&&void 0!==i?i:{field:null!==(o=this.fields[0])&&void 0!==o?o:"",operator:"equals",value:""};this.updateRule(t,{logic:ae(Object.assign(Object.assign({},s),r))})}commitJson(t,e){try{const r=JSON.parse(e);this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[t]:""}),this.updateRule(t,{logic:r})}catch(e){this.jsonErrors=Object.assign(Object.assign({},this.jsonErrors),{[t]:e instanceof Error?e.message:String(e)})}}commitCode(t,e){var r,i;const o=b.jsRunnerService.validateJs(`(() => {${e}})();`);this.codeErrors=Object.assign(Object.assign({},this.codeErrors),{[t]:o.valid?"":null!==(i=null===(r=o.error)||void 0===r?void 0:r.message)&&void 0!==i?i:"Invalid code"}),this.updateRule(t,{code:e})}updateEffect(t,e,r){var i;const o=(null!==(i=this.rules()[t].effects)&&void 0!==i?i:[]).map(((t,i)=>i===e?r:t));this.updateRule(t,{effects:o})}addEffect(t){var e;const r=this.rules()[t];this.updateRule(t,{effects:[...null!==(e=r.effects)&&void 0!==e?e:[],{property:{target:"hidden",type:"boolean"},boolean:!0}]})}removeEffect(t,e){var r;const i=this.rules()[t];this.updateRule(t,{effects:(null!==(r=i.effects)&&void 0!==r?r:[]).filter(((t,r)=>r!==e))})}renderCondition(t,e){var i,o;const s=null!==(i=de(e.logic))&&void 0!==i?i:{field:null!==(o=this.fields[0])&&void 0!==o?o:"",operator:"equals",value:""},n="isEmpty"!==s.operator&&"isNotEmpty"!==s.operator;return r("div",{class:"fk-rule__condition"},r("span",{class:"fk-rule__keyword"},d("rules.when")),r("select",{class:"fk-rule__control",onChange:r=>this.updateCondition(t,e,{field:r.target.value})},this.fields.map((t=>r("option",{value:t,selected:t===s.field},t)))),r("select",{class:"fk-rule__control",onChange:r=>this.updateCondition(t,e,{operator:r.target.value})},ne.map((t=>r("option",{value:t.id,selected:t.id===s.operator},t.label)))),n?r("input",{class:"fk-rule__control",type:"text",value:(a=s.value,void 0===a?"":"string"==typeof a?a:JSON.stringify(a)),onChange:r=>this.updateCondition(t,e,{value:fe(r.target.value)})}):null);var a}renderEffect(t,e,i){var o,s,n,a,l;const c=null!==(s=null===(o=e.property)||void 0===o?void 0:o.target)&&void 0!==s?s:"hidden",f=null!==(a=null===(n=e.property)||void 0===n?void 0:n.type)&&void 0!==a?a:"boolean";return r("div",{class:"fk-rule__effect"},r("select",{class:"fk-rule__control",onChange:r=>this.updateEffect(t,i,Object.assign(Object.assign({},e),{property:{target:r.target.value,type:f}}))},ue.map((t=>r("option",{value:t,selected:t===c},t)))),r("select",{class:"fk-rule__control",onChange:e=>{const r=e.target.value;this.updateEffect(t,i,Object.assign({property:{target:c,type:r}},"boolean"===r?{boolean:!0}:{string:""}))}},r("option",{value:"boolean",selected:"boolean"===f},"boolean"),r("option",{value:"string",selected:"string"===f},"string")),"boolean"===f?r("select",{class:"fk-rule__control",onChange:r=>this.updateEffect(t,i,Object.assign(Object.assign({},e),{boolean:"true"===r.target.value}))},r("option",{value:"true",selected:!1!==e.boolean},"true"),r("option",{value:"false",selected:!1===e.boolean},"false")):r("input",{class:"fk-rule__control",type:"text",value:null!==(l=e.string)&&void 0!==l?l:"",onChange:r=>this.updateEffect(t,i,Object.assign(Object.assign({},e),{string:r.target.value}))}),r("button",{type:"button",class:"fk-rule__remove",title:d("rules.removeEffect"),onClick:()=>this.removeEffect(t,i)},"✕"))}render(){return r("div",{key:"f31daa5219d35d255bc9cf2361df03d41e671155",class:"fk-rules"},this.rules().map(((t,e)=>{var i,o,s;const n=this.modeOf(e,t);return r("article",{class:"fk-rule"},r("header",{class:"fk-rule__header"},r("input",{class:"fk-rule__name",type:"text",value:t.name,onChange:t=>this.updateRule(e,{name:t.target.value})}),r("button",{type:"button",class:"fk-rule__remove",title:d("rules.removeRule"),onClick:()=>this.removeRule(e)},"✕")),r("div",{class:"fk-rule__modes"},["simple","json","javaScript"].map((i=>r("button",{type:"button",class:{"fk-rule__mode":!0,"fk-rule__mode--active":n===i},onClick:()=>this.setMode(e,t,i)},d(`rules.mode.${"javaScript"===i?"js":i}`))))),"simple"===n?this.renderCondition(e,t):null,"json"===n?r("div",{class:"fk-rule__advanced"},r("textarea",{class:"fk-rule__code",onChange:t=>this.commitJson(e,t.target.value)},JSON.stringify(null!==(i=t.logic)&&void 0!==i?i:null,null,2)),this.jsonErrors[e]?r("p",{class:"fk-rule__error"},this.jsonErrors[e]):null):null,"javaScript"===n?r("div",{class:"fk-rule__advanced"},r("fk-code-editor",{completions:this.fields,value:null!==(o=t.code)&&void 0!==o?o:"",placeholder:"return dataMap.country === 'BJ';",onCodeChange:t=>this.commitCode(e,t.detail)}),this.codeErrors[e]?r("p",{class:"fk-rule__error"},this.codeErrors[e]):null):null,r("div",{class:"fk-rule__effects"},r("span",{class:"fk-rule__keyword"},d("rules.then")),(null!==(s=t.effects)&&void 0!==s?s:[]).map(((t,r)=>this.renderEffect(e,t,r))),r("button",{type:"button",class:"fk-rule__add",onClick:()=>this.addEffect(e)},d("rules.addEffect"))))})),r("button",{key:"e481d50c0d949f1ef470d55e9d2ee88a25f614e9",type:"button",class:"fk-rule__add",onClick:this.addRule},d("rules.addRule")))}};pe.style=".sc-fk-rules-editor-h{display:block}.fk-rules.sc-fk-rules-editor{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-rule.sc-fk-rules-editor{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 1.5);padding:var(--fk-spacing);border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 1.5);background:color-mix(in srgb, var(--fk-color-surface) 60%, transparent)}.fk-rule__header.sc-fk-rules-editor{display:flex;align-items:center;gap:6px}.fk-rule__name.sc-fk-rules-editor{flex:1;min-width:0;font:inherit;font-size:0.8rem;font-weight:600;padding:4px 6px;border:1px solid transparent;border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-text)}.fk-rule__name.sc-fk-rules-editor:hover,.fk-rule__name.sc-fk-rules-editor:focus{border-color:var(--fk-color-border);background:var(--fk-color-surface);outline:none}.fk-rule__modes.sc-fk-rules-editor{display:flex;gap:4px}.fk-rule__mode.sc-fk-rules-editor{font:inherit;font-size:0.65rem;font-weight:600;text-transform:uppercase;letter-spacing:0.05em;padding:3px 8px;border:1px solid var(--fk-color-border);border-radius:999px;background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__mode--active.sc-fk-rules-editor{border-color:var(--fk-color-primary);background:color-mix(in srgb, var(--fk-color-primary) 12%, transparent);color:var(--fk-color-primary)}.fk-rule__condition.sc-fk-rules-editor,.fk-rule__effect.sc-fk-rules-editor{display:flex;flex-wrap:wrap;align-items:center;gap:4px}.fk-rule__keyword.sc-fk-rules-editor{font-size:0.65rem;font-weight:700;text-transform:uppercase;letter-spacing:0.08em;color:var(--fk-color-muted)}.fk-rule__control.sc-fk-rules-editor{font:inherit;font-size:0.78rem;padding:4px 6px;max-width:100%;min-width:0;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text)}.fk-rule__control.sc-fk-rules-editor:focus{outline:none;border-color:var(--fk-color-primary)}.fk-rule__advanced.sc-fk-rules-editor{display:flex;flex-direction:column;gap:4px}.fk-rule__code.sc-fk-rules-editor{font-family:ui-monospace, SFMono-Regular, Menlo, monospace;font-size:0.75rem;min-height:72px;padding:6px 8px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:var(--fk-color-surface);color:var(--fk-color-text);resize:vertical}.fk-rule__error.sc-fk-rules-editor{margin:0;font-size:0.72rem;color:var(--fk-color-danger)}.fk-rule__effects.sc-fk-rules-editor{display:flex;flex-direction:column;gap:6px}.fk-rule__remove.sc-fk-rules-editor{border:none;background:transparent;color:var(--fk-color-muted);font-size:0.75rem;cursor:pointer;padding:2px 4px;border-radius:calc(var(--fk-radius) / 2)}.fk-rule__remove.sc-fk-rules-editor:hover{color:var(--fk-color-danger);background:color-mix(in srgb, var(--fk-color-danger) 10%, transparent)}.fk-rule__add.sc-fk-rules-editor{align-self:flex-start;font:inherit;font-size:0.75rem;font-weight:600;padding:4px 10px;border:1px dashed var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-rule__add.sc-fk-rules-editor:hover{border-color:var(--fk-color-primary);color:var(--fk-color-primary)}";let he=0;const ke=class{constructor(r){t(this,r),this.selectValueChange=e(this,"selectValueChange"),this.disabled=!1,this.multiple=!1,this.invalid=!1,this.open=!1,this.query="",this.activeIndex=0,this.instanceId="fk-select-"+ ++he,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 r=A(e,this.dataMap);const i=this.searchParam();return i&&(r=T(r,i,this.query.trim())),r}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(),r=t.findIndex((t=>e.includes(t.value)));this.activeIndex=r>=0?r: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 r;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!==(r=e[this.activeIndex])&&void 0!==r?r: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 r=this.remoteUrl();if(!r)return void(this.remoteOptions=[]);const i=$(null===(e=this.configs)||void 0===e?void 0:e.optionsHeaders,this.dataMap),o=`${r}|${JSON.stringify(null!=i?i:{})}`;if(t||o!==this.lastRemoteSignature){this.lastRemoteSignature=o;try{this.remoteError=void 0,this.remoteOptions=await b.dataSourceService.fetchOptions(r,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 r=(null===(e=this.configs)||void 0===e?void 0:e.optionsRef)||"";if(r){if(t||r!==this.lastCatalogRef){this.lastCatalogRef=r;try{this.catalogError=void 0,this.catalogOptions=await b.optionSourceService.fetchOptions(r)}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,r,i,o,s;const n=(null===(t=this.configs)||void 0===t?void 0:t.labelKey)||void 0,a=(null===(e=this.configs)||void 0===e?void 0:e.valueKey)||void 0;switch(this.source()){case"remote":return{options:R(this.remoteOptions,n,a),error:this.remoteError};case"catalog":return{options:R(this.catalogOptions,n,a),error:this.catalogError};case"dataMap":{const t=null===(r=this.configs)||void 0===r?void 0:r.optionsPath;return{options:R(t?null===(i=this.dataMap)||void 0===i?void 0:i[t]:[],n,a)}}case"js":{const t=null===(o=this.configs)||void 0===o?void 0:o.optionsCode;if(!t)return{options:[]};const e=I(t,this.dataMap);return e instanceof Error?{options:[],error:e.message}:{options:R(e,n,a)}}default:return{options:R(null===(s=this.configs)||void 0===s?void 0:s.options,n,a)}}}selectedValues(){return this.multiple?Array.isArray(this.value)?this.value:[]:"string"==typeof this.value&&""!==this.value?[this.value]:[]}labelOf(t,e){var r,i;return null!==(i=null===(r=e.find((e=>e.value===t)))||void 0===r?void 0:r.label)&&void 0!==i?i:t}pick(t){if(this.multiple){const e=this.selectedValues(),r=e.includes(t.value)?e.filter((e=>e!==t.value)):[...e,t.value];this.selectValueChange.emit(r.length?r: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:i,error:o}=this.resolve(),s=this.selectedValues(),n=this.filteredOptions(i);return r("div",{key:"ddf7dfe94b227c3cd965b622bdae28620de02b30",class:{"fk-select":!0,"fk-select--disabled":this.disabled}},r("div",{key:"80526138a1f058c1f87a5d94cb9d9fa18ff34f8d",class:{"fk-select__trigger":!0,"fk-select__trigger--open":this.open},role:"combobox",tabIndex:this.disabled?void 0:0,"aria-label":this.accessibleLabel,"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()}},r("div",{key:"9a57ddcf19d3e8cf185e7f6e97368245ec25bfc4",class:"fk-select__values"},0===s.length?r("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?s.map((t=>r("span",{class:"fk-select__chip",key:t},this.labelOf(t,i),r("button",{type:"button",class:"fk-select__chip-remove","aria-label":`${d("select.clear")} — ${this.labelOf(t,i)}`,disabled:this.disabled,onClick:e=>{e.preventDefault(),e.stopPropagation(),this.unpick(t)}},"✕")))):r("span",{class:"fk-select__value"},this.labelOf(s[0],i))),!this.multiple&&s.length>0&&!this.disabled?r("button",{type:"button",class:"fk-select__clear",title:d("select.clear"),"aria-label":d("select.clear"),onClick:t=>{t.preventDefault(),t.stopPropagation(),this.selectValueChange.emit(void 0)}},"✕"):null,r("span",{key:"7e14336fb18c26aa2ed15938d917570639b8819d",class:"fk-select__caret"},"▾")),this.open?r("div",{class:"fk-select__dropdown"},r("input",{class:"fk-select__search",type:"text",placeholder:d("select.search"),value:this.query,role:"combobox","aria-label":this.accessibleLabel,"aria-expanded":"true","aria-autocomplete":"list","aria-controls":`${this.instanceId}-listbox`,"aria-activedescendant":n.length?`${this.instanceId}-opt-${Math.min(this.activeIndex,n.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,n)}),r("div",{class:"fk-select__options",role:"listbox",id:`${this.instanceId}-listbox`,"aria-multiselectable":this.multiple?"true":void 0},n.map(((t,e)=>{const i=s.includes(t.value),o=e===Math.min(this.activeIndex,n.length-1);return r("div",{key:t.value,id:`${this.instanceId}-opt-${e}`,role:"option","aria-selected":i?"true":"false",class:{"fk-select__option":!0,"fk-select__option--selected":i,"fk-select__option--active":o},onMouseEnter:()=>this.activeIndex=e,onClick:e=>{e.preventDefault(),this.pick(t)}},r("span",{class:"fk-select__option-label"},t.label),i?r("span",{class:"fk-select__check"},"✓"):null)})),0===n.length?r("p",{class:"fk-select__empty"},d("select.empty")):null)):null,o?r("span",{class:"fk-field__error"},o):null)}get host(){return i(this)}static get watchers(){return{configs:[{onConfigsChange:0}],dataMap:[{onDataMapChange:0}]}}};ke.style=".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)}";const ve=class{constructor(r){t(this,r),this.signatureChange=e(this,"signatureChange"),this.disabled=!1,this.drawing=!1,this.start=t=>{if(this.disabled||!this.canvas)return;this.drawing=!0,this.canvas.setPointerCapture(t.pointerId);const e=this.context();e&&(e.lineWidth=2,e.lineCap="round",e.strokeStyle=getComputedStyle(this.canvas).color,e.beginPath(),e.moveTo(...this.position(t)))},this.move=t=>{if(!this.drawing)return;const e=this.context();e&&(e.lineTo(...this.position(t)),e.stroke())},this.end=()=>{this.drawing&&this.canvas&&(this.drawing=!1,this.lastEmitted=this.canvas.toDataURL("image/png"),this.signatureChange.emit(this.lastEmitted))},this.clear=()=>{const t=this.context();t&&this.canvas&&(t.clearRect(0,0,this.canvas.width,this.canvas.height),this.lastEmitted=void 0,this.signatureChange.emit(void 0))}}componentDidLoad(){this.restore()}onValueChange(t){t!==this.lastEmitted&&this.restore()}context(){var t,e;return null!==(e=null===(t=this.canvas)||void 0===t?void 0:t.getContext("2d"))&&void 0!==e?e:void 0}restore(){const t=this.context();if(!t||!this.canvas)return;if(t.clearRect(0,0,this.canvas.width,this.canvas.height),!this.value)return;const e=new Image;e.onload=()=>t.drawImage(e,0,0),e.src=this.value}position(t){const e=this.canvas.getBoundingClientRect();return[(t.clientX-e.left)*this.canvas.width/e.width,(t.clientY-e.top)*this.canvas.height/e.height]}render(){return r("div",{key:"98ea6469116ea5c5950b56cabc87f13ef8de6b70",class:{"fk-signature":!0,"fk-signature--disabled":this.disabled}},r("canvas",{key:"f53f6c78f98e8a2f6e3526379c7ec41485c2046e",class:"fk-signature__canvas",width:480,height:140,ref:t=>this.canvas=t,onPointerDown:this.start,onPointerMove:this.move,onPointerUp:this.end,onPointerLeave:this.end}),r("button",{key:"abf0a85fbe6fb17587bb24c310772c575d4078a0",type:"button",class:"fk-signature__clear",disabled:this.disabled,onClick:this.clear},d("signature.clear")))}static get watchers(){return{value:[{onValueChange:0}]}}};ve.style=".sc-fk-signature-input-h{display:block}.fk-signature.sc-fk-signature-input{display:flex;flex-direction:column;gap:calc(var(--fk-spacing) / 2);align-items:flex-start}.fk-signature__canvas.sc-fk-signature-input{width:100%;max-width:480px;border:1px dashed var(--fk-color-border);border-radius:var(--fk-radius);background:var(--fk-color-surface);color:var(--fk-color-text);touch-action:none;cursor:crosshair}.fk-signature--disabled.sc-fk-signature-input .fk-signature__canvas.sc-fk-signature-input{cursor:not-allowed;opacity:0.6}.fk-signature__clear.sc-fk-signature-input{font:inherit;font-size:0.75rem;padding:3px 10px;border:1px solid var(--fk-color-border);border-radius:calc(var(--fk-radius) / 2);background:transparent;color:var(--fk-color-muted);cursor:pointer}.fk-signature__clear.sc-fk-signature-input:hover:not(:disabled){color:var(--fk-color-danger);border-color:var(--fk-color-danger)}";const be=class{constructor(r){t(this,r),this.stepTouch=e(this,"stepTouch"),this.stepperSubmit=e(this,"stepperSubmit"),this.stepLabels=[],this.editable=!1,this.active=0,this.next=t=>{t.preventDefault(),!this.config("validateSteps",!1)||this.stepValid(this.active)?this.active=Math.min(this.active+1,this.stepLabels.length-1):this.stepTouch.emit({keys:this.stepKeys(this.active)})},this.back=t=>{t.preventDefault(),this.active=Math.max(this.active-1,0)},this.submit=t=>{t.preventDefault(),!this.config("validateSteps",!1)||this.stepValid(this.active)?this.stepperSubmit.emit():this.stepTouch.emit({keys:this.stepKeys(this.active)})}}clampActive(){this.active>Math.max(this.stepLabels.length-1,0)&&(this.active=0)}componentDidRender(){const t=this.host.querySelector(".fk-stepper__body");t&&Array.from(t.children).forEach(((t,e)=>{const r=t;this.editable?r.style.removeProperty("display"):r.style.display=e===this.active?"":"none"}))}config(t,e){var r,i;const o=null===(i=null===(r=this.spec)||void 0===r?void 0:r.configs)||void 0===i?void 0:i[t];return"boolean"==typeof o?o:e}stepSpec(t){var e,r,i;const o=null===(r=null===(e=this.spec)||void 0===e?void 0:e.children)||void 0===r?void 0:r[t];if(o&&this.spec)return(null===(i=this.stepCache)||void 0===i?void 0:i.source)!==this.spec&&(this.stepCache={source:this.spec,specs:[]}),this.stepCache.specs[t]||(this.stepCache.specs[t]={type:"panel",id:"step",name:"Step",configs:{key:`step_${t}`},children:[o]}),this.stepCache.specs[t]}stepKeys(t){var e,r,i;const o=null===(r=null===(e=this.spec)||void 0===e?void 0:e.children)||void 0===r?void 0:r[t];if(!o)return[];const s=[];for(const t of L(o))(null===(i=t.configs)||void 0===i?void 0:i.key)&&s.push(t.configs.key);return s}stepValid(t){var e;const r=this.stepSpec(t);if(!r)return!0;const i=Object.fromEntries(Object.entries(null!==(e=this.dataMap)&&void 0!==e?e:{}).filter((([,t])=>""!==t&&null!=t)));return v(r,i,this.locale).valid}goToStep(t){if(this.editable||t<=this.active)this.active=t;else if(this.config("allowStepClick",!0)){if(this.config("validateSteps",!1))for(let e=this.active;e<t;e++)if(!this.stepValid(e))return this.active=e,void this.stepTouch.emit({keys:this.stepKeys(e)});this.active=t}}render(){const t=Math.max(this.stepLabels.length-1,0),e=!this.editable&&this.config("showSubmit",!1)&&this.active===t;return r("div",{key:"e053abb2a58d5d1a9072bac99e8ecf676b07e583",class:"fk-stepper"},r("ol",{key:"b3128e48f60b756cb2ef68d69f7d63172eb304e0",class:"fk-stepper__nav"},this.stepLabels.map(((t,e)=>r("li",{key:`${e}-${t}`,class:{"fk-stepper__step":!0,"fk-stepper__step--active":e===this.active,"fk-stepper__step--done":!this.editable&&e<this.active}},r("button",{type:"button",class:"fk-stepper__step-button","aria-current":e===this.active?"step":void 0,onClick:t=>{t.preventDefault(),this.goToStep(e)}},r("span",{class:"fk-stepper__index"},e+1),r("span",{class:"fk-stepper__label"},t)))))),r("div",{key:"2da56f865c1919777ec34954ccbceac4985694af",class:"fk-stepper__body"},r("slot",{key:"bca4f9af6e507c0f47fef5251426e19acf84f8e5"})),!this.editable&&this.stepLabels.length>1?r("div",{class:"fk-stepper__actions"},r("button",{type:"button",class:"fk-stepper__button",disabled:0===this.active,onClick:this.back},d("stepper.back")),this.active<t?r("button",{type:"button",class:"fk-stepper__button fk-stepper__button--primary",onClick:this.next},d("stepper.next")):null,e?r("button",{type:"button",class:"fk-stepper__button fk-stepper__button--primary",onClick:this.submit},d("stepper.submit")):null):null)}get host(){return i(this)}static get watchers(){return{stepLabels:[{clampActive:0}]}}};be.style=".sc-fk-stepper-h{display:block}.fk-stepper.sc-fk-stepper{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-stepper__nav.sc-fk-stepper{display:flex;flex-wrap:wrap;gap:calc(var(--fk-spacing) * 1.5);margin:0;padding:0 0 var(--fk-spacing);list-style:none;border-bottom:1px solid var(--fk-color-border)}.fk-stepper__step.sc-fk-stepper{display:flex;align-items:center;gap:calc(var(--fk-spacing) / 2);cursor:pointer;color:var(--fk-color-muted);font-size:0.85rem}.fk-stepper__index.sc-fk-stepper{display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;border:1px solid var(--fk-color-border);font-size:0.72rem;font-weight:700}.fk-stepper__step--active.sc-fk-stepper{color:var(--fk-color-text);font-weight:600}.fk-stepper__step--active.sc-fk-stepper .fk-stepper__index.sc-fk-stepper{border-color:var(--fk-color-primary);background:var(--fk-color-primary);color:#ffffff}.fk-stepper__step--done.sc-fk-stepper .fk-stepper__index.sc-fk-stepper{border-color:var(--fk-color-primary);color:var(--fk-color-primary)}.fk-stepper__actions.sc-fk-stepper{display:flex;justify-content:space-between;padding-top:var(--fk-spacing);border-top:1px solid var(--fk-color-border)}.fk-stepper__button.sc-fk-stepper{font:inherit;font-size:0.85rem;padding:calc(var(--fk-spacing) / 1.5) calc(var(--fk-spacing) * 1.5);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-stepper__button--primary.sc-fk-stepper{border-color:var(--fk-color-primary);background:var(--fk-color-primary);color:#ffffff}.fk-stepper__button.sc-fk-stepper:disabled{opacity:0.45;cursor:not-allowed}.fk-stepper__step-button.sc-fk-stepper{all:unset;display:inline-flex;align-items:center;gap:inherit;cursor:pointer}.fk-stepper__step-button.sc-fk-stepper:focus-visible{outline:2px solid color-mix(in srgb, var(--fk-color-primary) 55%, transparent);outline-offset:2px;border-radius:calc(var(--fk-radius) / 2)}";const ge=class{constructor(r){t(this,r),this.stepTouch=e(this,"stepTouch"),this.tabLabels=[],this.editable=!1,this.active=0}clampActive(){this.active>Math.max(this.tabLabels.length-1,0)&&(this.active=0)}componentDidRender(){const t=this.host.querySelector(".fk-tabs__body");t&&Array.from(t.children).forEach(((t,e)=>{const r=t;this.editable?r.style.removeProperty("display"):r.style.display=e===this.active?"":"none"}))}validateTabs(){var t,e;return!0===(null===(e=null===(t=this.spec)||void 0===t?void 0:t.configs)||void 0===e?void 0:e.validateTabs)}tabSpec(t){var e,r,i;const o=null===(r=null===(e=this.spec)||void 0===e?void 0:e.children)||void 0===r?void 0:r[t];if(o&&this.spec)return(null===(i=this.tabCache)||void 0===i?void 0:i.source)!==this.spec&&(this.tabCache={source:this.spec,specs:[]}),this.tabCache.specs[t]||(this.tabCache.specs[t]={type:"panel",id:"tab",name:"Tab",configs:{key:`tab_${t}`},children:[o]}),this.tabCache.specs[t]}tabKeys(t){var e,r,i;const o=null===(r=null===(e=this.spec)||void 0===e?void 0:e.children)||void 0===r?void 0:r[t];if(!o)return[];const s=[];for(const t of L(o))(null===(i=t.configs)||void 0===i?void 0:i.key)&&s.push(t.configs.key);return s}tabValid(t){var e;const r=this.tabSpec(t);if(!r)return!0;const i=Object.fromEntries(Object.entries(null!==(e=this.dataMap)&&void 0!==e?e:{}).filter((([,t])=>""!==t&&null!=t)));return v(r,i,this.locale).valid}goToTab(t){t!==this.active&&(this.editable||!this.validateTabs()||this.tabValid(this.active)?this.active=t:this.stepTouch.emit({keys:this.tabKeys(this.active)}))}render(){return r("div",{key:"ebded73697ab12ae23d267ea30437129b10efffa",class:"fk-tabs"},r("div",{key:"b027f709c510a5ba1f2b38fdd20b7b131cf5888c",class:"fk-tabs__nav",role:"tablist"},this.tabLabels.map(((t,e)=>r("button",{key:`${e}-${t}`,type:"button",role:"tab","aria-selected":e===this.active?"true":"false",tabIndex:e===this.active?0:-1,class:{"fk-tabs__tab":!0,"fk-tabs__tab--active":e===this.active},onKeyDown:t=>{const r=this.tabLabels.length;!r||"ArrowRight"!==t.key&&"ArrowLeft"!==t.key||(t.preventDefault(),this.goToTab((e+("ArrowRight"===t.key?1:-1)+r)%r),requestAnimationFrame((()=>{var t;null===(t=this.host.querySelector(".fk-tabs__tab--active"))||void 0===t||t.focus()})))},onClick:t=>{t.preventDefault(),this.goToTab(e)}},t)))),r("div",{key:"ec7ed61a3f1f126268e2f1e0dfacfdb85dc542cd",class:"fk-tabs__body"},r("slot",{key:"4e86782cfe37f893992787265fdc764367672f67"})))}get host(){return i(this)}static get watchers(){return{tabLabels:[{clampActive:0}]}}};ge.style=".sc-fk-tabs-h{display:block}.fk-tabs.sc-fk-tabs{display:flex;flex-direction:column;gap:var(--fk-spacing)}.fk-tabs__nav.sc-fk-tabs{display:flex;flex-wrap:wrap;gap:2px;border-bottom:1px solid var(--fk-color-border)}.fk-tabs__tab.sc-fk-tabs{font:inherit;font-size:0.85rem;font-weight:500;padding:calc(var(--fk-spacing) / 1.5) var(--fk-spacing);border:none;border-bottom:2px solid transparent;border-radius:0;background:transparent;color:var(--fk-color-muted);text-transform:none;letter-spacing:normal;cursor:pointer}.fk-tabs__tab.sc-fk-tabs:hover{color:var(--fk-color-text)}.fk-tabs__tab--active.sc-fk-tabs{color:var(--fk-color-primary);border-bottom-color:var(--fk-color-primary);font-weight:600}";export{Ht as fk_brick_actions,Wt as fk_brick_list,Gt as fk_brick_mold_item,Xt as fk_brick_not_found,Zt as fk_brick_render,Qt as fk_code_editor,te as fk_data_grid,ee as fk_drop_area,re as fk_file_input,ie as fk_form_builder,oe as fk_form_render,se as fk_property_panel,pe as fk_rules_editor,ke as fk_select_input,ve as fk_signature_input,be as fk_stepper,ge as fk_tabs}
|
|
@@ -6,6 +6,7 @@ export declare class FkPropertyPanel {
|
|
|
6
6
|
brick: BrickSpec;
|
|
7
7
|
fields: string[];
|
|
8
8
|
locales: string[];
|
|
9
|
+
locale?: string;
|
|
9
10
|
editLocale?: string;
|
|
10
11
|
brickConfigsChange: EventEmitter<BrickConfigsChangeDetail>;
|
|
11
12
|
brickValidationsChange: EventEmitter<BrickValidationsChangeDetail>;
|
|
@@ -18,6 +18,7 @@ export namespace Components {
|
|
|
18
18
|
"selected": boolean;
|
|
19
19
|
}
|
|
20
20
|
interface FkBrickList {
|
|
21
|
+
"locale"?: string;
|
|
21
22
|
}
|
|
22
23
|
interface FkBrickMoldItem {
|
|
23
24
|
"brickMold": BrickMold;
|
|
@@ -94,6 +95,7 @@ export namespace Components {
|
|
|
94
95
|
}
|
|
95
96
|
interface FkFormBuilder {
|
|
96
97
|
"data"?: Record<string, unknown>;
|
|
98
|
+
"locale"?: string;
|
|
97
99
|
/**
|
|
98
100
|
* @default []
|
|
99
101
|
*/
|
|
@@ -118,6 +120,7 @@ export namespace Components {
|
|
|
118
120
|
* @default []
|
|
119
121
|
*/
|
|
120
122
|
"fields": string[];
|
|
123
|
+
"locale"?: string;
|
|
121
124
|
/**
|
|
122
125
|
* @default []
|
|
123
126
|
*/
|
|
@@ -550,6 +553,7 @@ declare namespace LocalJSX {
|
|
|
550
553
|
"selected"?: boolean;
|
|
551
554
|
}
|
|
552
555
|
interface FkBrickList {
|
|
556
|
+
"locale"?: string;
|
|
553
557
|
}
|
|
554
558
|
interface FkBrickMoldItem {
|
|
555
559
|
"brickMold": BrickMold;
|
|
@@ -636,6 +640,7 @@ declare namespace LocalJSX {
|
|
|
636
640
|
}
|
|
637
641
|
interface FkFormBuilder {
|
|
638
642
|
"data"?: Record<string, unknown>;
|
|
643
|
+
"locale"?: string;
|
|
639
644
|
/**
|
|
640
645
|
* @default []
|
|
641
646
|
*/
|
|
@@ -662,6 +667,7 @@ declare namespace LocalJSX {
|
|
|
662
667
|
* @default []
|
|
663
668
|
*/
|
|
664
669
|
"fields"?: string[];
|
|
670
|
+
"locale"?: string;
|
|
665
671
|
/**
|
|
666
672
|
* @default []
|
|
667
673
|
*/
|
|
@@ -739,6 +745,9 @@ declare namespace LocalJSX {
|
|
|
739
745
|
"path": string;
|
|
740
746
|
"selected": boolean;
|
|
741
747
|
}
|
|
748
|
+
interface FkBrickListAttributes {
|
|
749
|
+
"locale": string;
|
|
750
|
+
}
|
|
742
751
|
interface FkBrickRenderAttributes {
|
|
743
752
|
"path": string;
|
|
744
753
|
"editable": boolean;
|
|
@@ -763,12 +772,16 @@ declare namespace LocalJSX {
|
|
|
763
772
|
"uploadUrl": string;
|
|
764
773
|
"multiple": boolean;
|
|
765
774
|
}
|
|
775
|
+
interface FkFormBuilderAttributes {
|
|
776
|
+
"locale": string;
|
|
777
|
+
}
|
|
766
778
|
interface FkFormRenderAttributes {
|
|
767
779
|
"editable": boolean;
|
|
768
780
|
"selectedUid": string;
|
|
769
781
|
"locale": string;
|
|
770
782
|
}
|
|
771
783
|
interface FkPropertyPanelAttributes {
|
|
784
|
+
"locale": string;
|
|
772
785
|
"editLocale": string;
|
|
773
786
|
}
|
|
774
787
|
interface FkSelectInputAttributes {
|
|
@@ -793,7 +806,7 @@ declare namespace LocalJSX {
|
|
|
793
806
|
|
|
794
807
|
interface IntrinsicElements {
|
|
795
808
|
"fk-brick-actions": Omit<FkBrickActions, keyof FkBrickActionsAttributes> & { [K in keyof FkBrickActions & keyof FkBrickActionsAttributes]?: FkBrickActions[K] } & { [K in keyof FkBrickActions & keyof FkBrickActionsAttributes as `attr:${K}`]?: FkBrickActionsAttributes[K] } & { [K in keyof FkBrickActions & keyof FkBrickActionsAttributes as `prop:${K}`]?: FkBrickActions[K] } & OneOf<"path", FkBrickActions["path"], FkBrickActionsAttributes["path"]>;
|
|
796
|
-
"fk-brick-list": FkBrickList;
|
|
809
|
+
"fk-brick-list": Omit<FkBrickList, keyof FkBrickListAttributes> & { [K in keyof FkBrickList & keyof FkBrickListAttributes]?: FkBrickList[K] } & { [K in keyof FkBrickList & keyof FkBrickListAttributes as `attr:${K}`]?: FkBrickListAttributes[K] } & { [K in keyof FkBrickList & keyof FkBrickListAttributes as `prop:${K}`]?: FkBrickList[K] };
|
|
797
810
|
"fk-brick-mold-item": FkBrickMoldItem;
|
|
798
811
|
"fk-brick-not-found": FkBrickNotFound;
|
|
799
812
|
"fk-brick-render": Omit<FkBrickRender, keyof FkBrickRenderAttributes> & { [K in keyof FkBrickRender & keyof FkBrickRenderAttributes]?: FkBrickRender[K] } & { [K in keyof FkBrickRender & keyof FkBrickRenderAttributes as `attr:${K}`]?: FkBrickRenderAttributes[K] } & { [K in keyof FkBrickRender & keyof FkBrickRenderAttributes as `prop:${K}`]?: FkBrickRender[K] };
|
|
@@ -802,7 +815,7 @@ declare namespace LocalJSX {
|
|
|
802
815
|
"fk-drop-area": Omit<FkDropArea, keyof FkDropAreaAttributes> & { [K in keyof FkDropArea & keyof FkDropAreaAttributes]?: FkDropArea[K] } & { [K in keyof FkDropArea & keyof FkDropAreaAttributes as `attr:${K}`]?: FkDropAreaAttributes[K] } & { [K in keyof FkDropArea & keyof FkDropAreaAttributes as `prop:${K}`]?: FkDropArea[K] } & OneOf<"path", FkDropArea["path"], FkDropAreaAttributes["path"]>;
|
|
803
816
|
"fk-empty-form": FkEmptyForm;
|
|
804
817
|
"fk-file-input": Omit<FkFileInput, keyof FkFileInputAttributes> & { [K in keyof FkFileInput & keyof FkFileInputAttributes]?: FkFileInput[K] } & { [K in keyof FkFileInput & keyof FkFileInputAttributes as `attr:${K}`]?: FkFileInputAttributes[K] } & { [K in keyof FkFileInput & keyof FkFileInputAttributes as `prop:${K}`]?: FkFileInput[K] };
|
|
805
|
-
"fk-form-builder": FkFormBuilder;
|
|
818
|
+
"fk-form-builder": Omit<FkFormBuilder, keyof FkFormBuilderAttributes> & { [K in keyof FkFormBuilder & keyof FkFormBuilderAttributes]?: FkFormBuilder[K] } & { [K in keyof FkFormBuilder & keyof FkFormBuilderAttributes as `attr:${K}`]?: FkFormBuilderAttributes[K] } & { [K in keyof FkFormBuilder & keyof FkFormBuilderAttributes as `prop:${K}`]?: FkFormBuilder[K] };
|
|
806
819
|
"fk-form-render": Omit<FkFormRender, keyof FkFormRenderAttributes> & { [K in keyof FkFormRender & keyof FkFormRenderAttributes]?: FkFormRender[K] } & { [K in keyof FkFormRender & keyof FkFormRenderAttributes as `attr:${K}`]?: FkFormRenderAttributes[K] } & { [K in keyof FkFormRender & keyof FkFormRenderAttributes as `prop:${K}`]?: FkFormRender[K] };
|
|
807
820
|
"fk-property-panel": Omit<FkPropertyPanel, keyof FkPropertyPanelAttributes> & { [K in keyof FkPropertyPanel & keyof FkPropertyPanelAttributes]?: FkPropertyPanel[K] } & { [K in keyof FkPropertyPanel & keyof FkPropertyPanelAttributes as `attr:${K}`]?: FkPropertyPanelAttributes[K] } & { [K in keyof FkPropertyPanel & keyof FkPropertyPanelAttributes as `prop:${K}`]?: FkPropertyPanel[K] };
|
|
808
821
|
"fk-rules-editor": FkRulesEditor;
|