@konfigure/sdk 0.2.1 → 0.3.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/README.md +54 -1
- package/dist/chunk-4KQN5AVT.js +782 -0
- package/dist/chunk-EBEY7ID3.js +1 -0
- package/dist/chunk-HFOEVYNK.js +4 -0
- package/dist/chunk-XR6EHOK2.js +482 -0
- package/dist/client-B2yVMro3.d.ts +80 -0
- package/dist/{configurator-6ISAZiAx.d.ts → configurator-CnGR3YDW.d.ts} +1 -1
- package/dist/index.d.ts +5 -57
- package/dist/index.js +1 -4
- package/dist/showroom.d.ts +145 -0
- package/dist/showroom.js +171 -0
- package/dist/{src-GJ5RXX7G.js → src-SHLZZCVA.js} +6 -6
- package/dist/view.d.ts +1 -1
- package/dist/view.js +3 -785
- package/package.json +5 -1
- package/dist/chunk-ARGXORCF.js +0 -1
- package/dist/chunk-OOVVLYAY.js +0 -482
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {a}from'./chunk-XUSV3KOD.js';var T=class extends Error{static{a(this,"KonfigureError");}code;status;details;constructor(n,t,o={}){super(t,o.cause===void 0?void 0:{cause:o.cause}),this.name="KonfigureError",this.code=n,this.status=o.status,this.details=o.details;}};var E=new WeakMap,Y=0,{toString:Q}=Object.prototype,B=a((e,n)=>Q.call(e)===`[object ${n}]`,"isType"),X=a(e=>{let n=Object.getPrototypeOf(e);return n===null||n===Object.prototype||Object.getPrototypeOf(n)===null},"isPlainObject");function N(e,n){let t=typeof e,o=e?.constructor,s=n?B(e,"Date"):o===Date;if(Object(e)===e&&!s&&!(n?B(e,"RegExp"):o===RegExp)){let i=e,u=E.get(i);if(u)return u;u=++Y+"~",E.set(i,u);let a;if(n?Array.isArray(e):o===Array){let d=e;for(u="@",a=0;a<d.length;a++)u+=N(d[a],n)+",";E.set(d,u);}else if(n?X(i):o===null||o===Object){u="#";let d=Object.keys(i).sort();for(;(a=d.pop())!==void 0;){let S=a;i[S]!==void 0&&(u+=a+":"+N(i[S],n)+",");}E.set(i,u);}return u}return s?e.toJSON():t==="symbol"?e.toString():t==="string"?JSON.stringify(e):""+e}a(N,"stableHash");function Z(e){let n=Object.fromEntries(Object.entries(e.basePartSlots).map(([t,{hidden:o,...s}])=>[t,s]));return N({apiModuleId:e.apiModuleId,basePartSlots:n,invertedSlots:e.invertedSlots,rotatedSlots:e.rotatedSlots,childrenHashes:e.childrenHashes,...e.size&&{size:{width:e.size.width,height:e.size.height}}})}a(Z,"computeModuleContentHash");function ee(e,n,t){let o=e.allowedSurfaceIds??[],s=e.allowedSurfaceGroupIds??[];return o.length===0&&s.length===0||o.includes(n)?true:t!=null&&s.includes(t)}a(ee,"isSurfaceAllowed");function H({preferred:e,inherited:n}){let t=e===void 0?[]:typeof e=="number"?[e]:[...e];return n!==void 0&&t.push(n),t}a(H,"surfaceCandidates");function te(e,n,t){for(let o of H(n))if(t(o))return o;return e.defaultSurfaceId??void 0}a(te,"choosePartSurface");function oe(e,n){return e.defaultPartId!=null&&n.includes(e.defaultPartId)?e.defaultPartId:n[0]}a(oe,"startingPartId");function ne(e){return e.mandatory&&e.defaultPartId?e.defaultPartId:void 0}a(ne,"mandatoryPartId");function re(e,n,t){let o=e.x-t.x,s=e.z-t.z,i=n.x-t.x,u=n.z-t.z,a=o*u-s*i,d=o*i+s*u;return Math.atan2(a,d)}a(re,"calculateAngle");function se(e,n){for(let t=0;t<e.length;t++){let o=e[t];if(o&&o.module&&Object.values(o.module.moduleSlots).some(u=>u.id===n))return [t,o]}return [-1,null]}a(se,"findConnectedModuleSlot");function ue(e,n,t){let o=[],s=new Set;t&&s.add(t.id),s.add(n.id);function i(u){for(let a of Object.values(u)){let d=a.module;!d||s.has(d.id)||(s.add(d.id),o.push(d),i(d.moduleSlots));}}return a(i,"collectRecursive"),i(e),o}a(ue,"collectChildModules");function C(e){return e.apiModuleId}a(C,"getModuleApiId");function k(e,n){return O(e,n).map(t=>t.module)}a(k,"getNeighborModules");function L(e,n){for(let[t,o]of Object.entries(e.moduleSlots))if(o.module?.id===n.id)return t}a(L,"findSlotFacing");function O(e,n){let t=[],o=new Set;for(let[s,i]of Object.entries(e.moduleSlots))if(i.module&&!o.has(i.module.id)){o.add(i.module.id);let u=L(i.module,e);t.push({module:i.module,ourSlotName:s,theirSlotName:u});}for(let s of n)if(!(s.id===e.id||o.has(s.id))){for(let[i,u]of Object.entries(s.moduleSlots))if(u.module?.id===e.id){o.add(s.id);let a=L(e,s)??ie(e,s,i);t.push({module:s,ourSlotName:a,theirSlotName:i});break}}return t}a(O,"getDirectionalNeighbors");function ie(e,n,t){let o=C(e),s=n.moduleSlots[t];if(o&&s){let a=s.compatibleModules?.find(d=>d.id===o)?.allowedSlotNames;if(a?.length===1)return a[0];if(a&&a.length>1){let d=a.filter(S=>{let M=e.moduleSlots[S];return M&&!M.module});if(d.length===1)return d[0]}}let i=Object.entries(e.moduleSlots).filter(([u,a])=>!a.module);if(i.length===1)return i[0][0]}a(ie,"determineConnectingSlot");function ae(e){return e?.apiPartId}a(ae,"getPartApiId");function j(e,n,t){let o=0;switch(e){case "module":for(let s of t){let i=C(s);i!==void 0&&n.includes(i)&&o++;}break;case "part":for(let s of t)for(let i of Object.values(s.basePartSlots)){let u=ae(i.part);u!==void 0&&n.includes(u)&&o++;}break}return o}a(j,"countTargets");function V(e,n,t){return !e||e==="current_module"||e==="all_modules"?true:e==="neighbors"?k(n,t).length>0:true}a(V,"checkScope");function I(e,n){if(!e)return false;if(n.includes(e.apiPartId))return true;for(let t of Object.values(e.partSlots))if(I(t.part,n))return true;return false}a(I,"partMatchesRecursively");function A(e,n,t){let o=0;for(let s of n){let i=e.basePartSlots[s];i&&I(i.part,t)&&o++;}return o}a(A,"countTargetsInSlots");function G(e,n,t){if(!e?.partSlots)return false;let o=e.partSlots[n];if(o&&o.part&&t.includes(o.part.apiPartId))return true;for(let s of Object.values(e.partSlots))if(G(s.part,n,t))return true;return false}a(G,"nestedSlotHoldsPart");function le(e,n){let{currentModule:t,accessoryPartIdsBySlot:o}=n;if(!t)return false;let s=e.targetIds??[],i=e.slotName;if(i){let u=t.basePartSlots[i];if(u&&I(u.part,s))return true;for(let d of Object.values(t.basePartSlots))if(G(d.part,i,s))return true;let a=o?.[i];return !!(a&&a.some(d=>s.includes(d)))}if(Object.values(t.basePartSlots).some(u=>I(u.part,s)))return true;if(o){for(let u of Object.values(o))if(u.some(a=>s.includes(a)))return true}return false}a(le,"evaluateHasPart");function ce(e,n){let{allModules:t}=n,o=e.targetIds??[];return t.some(s=>{let i=C(s);return i!==void 0&&o.includes(i)})}a(ce,"evaluateHasModule");function de(e,n){return false}a(de,"evaluateHasSurface");function fe(e,n,t){if(t&&e.theirSlotName){let o=t.replace("{slotName}",e.theirSlotName),s=e.module.basePartSlots[o];if(s)return I(s.part,n)}return Object.values(e.module.basePartSlots).some(o=>I(o.part,n))}a(fe,"neighborHasTargetPart");function me(e,n){let{currentModule:t,allModules:o}=n;if(!t)return false;let s=e.targetIds??[],i=e.moduleSlotName,u=e.neighborBaseSlotPattern,a=O(t,o);return (i?a.filter(S=>S.ourSlotName===i):a).some(S=>fe(S,s,u))}a(me,"evaluateNeighborHasPart");function ge(e,n){let{currentModule:t,allModules:o}=n;if(!t)return false;let s=e.targetIds??[];return k(t,o).some(u=>{let a=C(u);return a!==void 0&&s.includes(a)})}a(ge,"evaluateNeighborHasModule");function pe(e,n){let{changedSlotName:t}=n;return t===e.slotName}a(pe,"evaluateSlotIs");function he(e,n){let{allModules:t}=n,o=e.targetIds??[];return j(e.targetType??"",o,t)>=(Number(e.value)||0)}a(he,"evaluateCountGte");function be(e,n){let{allModules:t}=n,o=e.targetIds??[];return j(e.targetType??"",o,t)<=(Number(e.value)||0)}a(be,"evaluateCountLte");function Se(e,n){let{currentModule:t}=n;if(!t)return false;let o=e.targetIds??[];return A(t,e.slotNames??[],o)>=(Number(e.value)||0)}a(Se,"evaluateCountInSlotsGte");function ye(e,n){let{currentModule:t}=n;if(!t)return false;let o=e.targetIds??[],s=A(t,e.slotNames??[],o),i=A(t,e.compareSlotNames??[],o);return s-i>=(Number(e.value)||0)}a(ye,"evaluateCountInSlotsDiffGte");function Re(e,n){let{changedPartId:t,changedSlotName:o}=n;if(!t)return false;let s=e.targetIds??[];return (!e.slotName||e.slotName===o)&&(s.length===0||s.includes(t))}a(Re,"evaluatePartChanged");function xe(e,n){let{changedSurfaceId:t}=n;if(!t)return false;let o=e.targetIds??[];return o.length===0||o.includes(t)}a(xe,"evaluateSurfaceChanged");var ve={has_part:le,has_module:ce,has_surface:de,neighbor_has_part:me,neighbor_has_module:ge,slot_is:pe,count_gte:he,count_lte:be,count_in_slots_gte:Se,count_in_slots_diff_gte:ye,part_changed:Re,surface_changed:xe};function z(e,n){let t=ve[e.type];return t?t(e,n):false}a(z,"evaluateCondition");function w(e){return e?.apiPartId}a(w,"partApiId");function Ce(e){let n=new Set;for(let l of e)for(let c of l.actions)if(c.type==="forbid"&&c.targetType==="module"&&c.adjacencyCheck)for(let f of c.targetIds)n.add(f);function t(l,c){return l.conditions.every(f=>z(f,c))}a(t,"evaluateConditions");function o(l,c){if(!l.targetModuleIds||l.targetModuleIds.length===0)return true;let f=C(c);return f===void 0?true:l.targetModuleIds.includes(f)}a(o,"ruleAppliesToModule");function s(l,c,f,R,h){let p={currentModule:f,allModules:R,targetPartId:l,changedSlotName:c,baseSlotName:h};for(let b of e)if(o(b,f)&&t(b,p))for(let g of b.actions){if(g.type!=="forbid"||g.targetType!=="part"||!g.targetIds.includes(l))continue;let y=V(g.scope,f,R),v=!g.slotName||g.slotName===c||g.slotName===h;if(y&&v)return {ruleName:b.name,message:g.message||b.name}}return null}a(s,"checkPart");function i(l,c,f){let R={currentModule:c,allModules:f,targetModuleId:l};for(let h of e)if(o(h,c)&&t(h,R)){for(let p of h.actions)if(!(p.type!=="forbid"||p.targetType!=="module")&&!p.adjacencyCheck&&p.targetIds.includes(l))return {ruleName:h.name,message:p.message||h.name}}return null}a(i,"checkModule");function u(l){return n.has(l)}a(u,"needsAdjacencyCheck");let a$1=e.filter(l=>l.ruleType==="sync_parts"||l.ruleType==="cascade_change");function d(l,c,f,R){let h=f.basePartSlots[R];if(!h)return;let p=h.compatibleParts??[];if(p.some(y=>w(y)===c))return c;let b=C(f),g=l.partMappings?.find(y=>y.sourcePartId===c&&y.targetModuleId===b);if(g)return p.some(y=>w(y)===g.targetPartId)?g.targetPartId:void 0}a(d,"mapPartForModule");function S(l,c,f,R){let h=[],p={currentModule:f,allModules:R,changedPartId:l,changedSlotName:c};for(let b of a$1)if(o(b,f)&&t(b,p))for(let g of b.actions){if(g.type!=="sync"||g.scope!=="all_modules")continue;let y=g.slotName||c;for(let v of R){if(v.id===f.id)continue;let P=v.basePartSlots[y];if(!P)continue;let $=d(b,l,v,y);$!==void 0&&w(P.part)!==$&&h.push({moduleId:v.id,slotName:y,newPartId:$});}}return h}a(S,"partChangeSyncs");function M(l,c){let f=[];if(c.length===0)return f;for(let R of a$1)if(o(R,l))for(let h of R.actions){if(h.type!=="sync"||h.scope!=="all_modules")continue;let p=h.slotName;if(!p)continue;let b=l.basePartSlots[p];if(!b)continue;let g;for(let v of c){let P=v.basePartSlots[p];if(P&&(g=w(P.part),g!==void 0))break}if(g===void 0||w(b.part)===g)continue;let y=d(R,g,l,p);y===void 0||y===w(b.part)||f.push({moduleId:l.id,slotName:p,newPartId:y});}return f}return a(M,"newModuleSyncs"),{count:e.length,checkPart:s,checkModule:i,needsAdjacencyCheck:u,partChangeSyncs:S,newModuleSyncs:M}}a(Ce,"createRuleEngine");function K(){return !(typeof process<"u")}a(K,"isDev");function F(e){return e==="error"?"error":e==="warn"?"warn":"log"}a(F,"getConsoleMethod");var m={reset:"\x1B[0m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function D(e){switch(e){case "error":return m.red;case "warn":return m.yellow;case "info":return m.cyan;case "debug":return m.gray;default:return m.white}}a(D,"getLevelColor");var Me={service:"app",environment:"development"},J=K(),Ie={};function q(e){let{rates:n}=Ie;if(!n)return true;let t=e==="error"&&n.error===void 0?100:n[e]??100;return t<=0?false:t>=100?true:Math.random()*100<t}a(q,"shouldSample");function U(e,n,t=false){if(!t&&!q(e))return null;let o={timestamp:new Date().toISOString(),level:e,...Me,...n};return J?Pe(o):console[F(e)](JSON.stringify(o)),o}a(U,"emitWideEvent");function W(e,n,t){if(J){if(!q(e))return;let o=D(e),s=new Date().toISOString().slice(11,23);console.log(`${m.dim}${s}${m.reset} ${o}[${n}]${m.reset} ${t}`);}else U(e,{tag:n,message:t});}a(W,"emitTaggedLog");function we(e){if(e==null)return String(e);if(typeof e=="object"){let n=[];for(let[t,o]of Object.entries(e))o!=null&&(typeof o=="object"?n.push(`${t}=${JSON.stringify(o)}`):n.push(`${t}=${o}`));return n.join(" ")}return String(e)}a(we,"formatValue");function Pe(e){let{timestamp:n,level:t,service:o,environment:s,version:i,...u}=e,a=D(t),d=n.slice(11,23),S=`${m.dim}${d}${m.reset} ${a}${t.toUpperCase()}${m.reset}`;if(S+=` ${m.cyan}[${o}]${m.reset}`,u.method&&u.path&&(S+=` ${u.method} ${u.path}`,delete u.method,delete u.path),u.status){let c=u.status>=400?m.red:m.green;S+=` ${c}${u.status}${m.reset}`,delete u.status;}u.duration&&(S+=` ${m.dim}in ${u.duration}${m.reset}`,delete u.duration),console.log(S);let M=Object.entries(u).filter(([c,f])=>f!==void 0),l=M.length-1;M.forEach(([c,f],R)=>{let p=R===l?"\u2514\u2500":"\u251C\u2500",b=we(f);console.log(` ${m.dim}${p}${m.reset} ${m.cyan}${c}:${m.reset} ${b}`);});}a(Pe,"prettyPrintWideEvent");function _(e){return a(function(t,o){typeof t=="string"&&o!==void 0?W(e,t,o):typeof t=="object"?U(e,t):W(e,"log",String(t));},"logMethod")}a(_,"createLogMethod");var x={info:_("info"),error:_("error"),warn:_("warn"),debug:_("debug")};function Ee(){let e=import.meta;return e.dev?true:e.server||typeof localStorage>"u"?false:localStorage.getItem("debug")==="true"}a(Ee,"isLoggingEnabled");function Ne(e){let n=a(()=>Ee(),"shouldLog");return {debug:a((t,o)=>{n()&&(o?x.debug({tag:e,message:t,...o}):x.debug(e,t));},"debug"),info:a((t,o)=>{n()&&(o?x.info({tag:e,message:t,...o}):x.info(e,t));},"info"),warn:a((t,o)=>{n()&&(o?x.warn({tag:e,message:t,...o}):x.warn(e,t));},"warn"),error:a((t,o)=>{o?x.error({tag:e,message:t,...o}):x.error(e,t);},"error")}}a(Ne,"createClientLogger");export{T as a,Z as b,re as c,se as d,ue as e,Ce as f,ee as g,te as h,oe as i,ne as j,Ne as k};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {g,h,j,i,b,f,a as a$1}from'./chunk-EBEY7ID3.js';import {a}from'./chunk-XUSV3KOD.js';function ce(t){return {catalog:t,modules:new Map(t.modules.map(e=>[e.id,e])),parts:new Map(t.parts.map(e=>[e.id,e])),surfaces:new Map(t.surfaces.map(e=>[e.id,e])),surfaceGroups:new Map(t.surfaceGroups.map(e=>[e.id,e]))}}a(ce,"indexCatalog");function U(t,e,o){let a=t.surfaces.get(o);return a!==void 0&&g(e,o,a.groupId)}a(U,"isSurfaceAllowed");function q(t,e){return e.hasConfigurableSurface?t.catalog.surfaces.filter(o=>U(t,e,o.id)):[]}a(q,"surfacePalette");function B(t,e,o={}){let a=t.parts.get(e),m=a?h(a,{preferred:o.surfaceId,inherited:o.inheritedSurfaceId},y=>U(t,a,y)):void 0,S=a?.hasConfigurableSurface&&m!==void 0&&t.surfaces.has(m)?m:void 0,h$1={};for(let y of a?.partSlots??[]){let p=j(y);h$1[y.name]=p?B(t,p,{inheritedSurfaceId:m}):null;}return {apiPartId:e,...S!==void 0&&{surfaceId:S},nestedSlots:h$1}}a(B,"defaultPartState");function $e(t,e){let o=(e.compatibleParts??[]).map(a=>a.partId).filter(a=>t.parts.has(a));return i(e,o)??null}a($e,"startingPartOf");function E(t){return [...t.basePartSlots??[]].sort((e,o)=>(e.order??0)-(o.order??0))}a(E,"sortedBaseSlots");function J(t){let e=Object.fromEntries(Object.entries(t.children).map(([o,a])=>[o,J(a)]));return {...t,children:e,hash:b({apiModuleId:t.apiModuleId,basePartSlots:t.basePartSlots,invertedSlots:t.invertedSlots,rotatedSlots:t.rotatedSlots,childrenHashes:Object.fromEntries(Object.entries(e).map(([o,a])=>[o,a.hash])),size:t.size})}}a(J,"withHash");function fe(t,e){let o={},a={};for(let m of E(e)){let S=$e(t,m);S!=null&&(o[m.name]=B(t,S),m.defaultInverted&&(a[m.name]=true));}return J({apiModuleId:e.id,basePartSlots:o,invertedSlots:a,rotatedSlots:{},children:{},childSlotNames:{},position:{x:0,y:0,z:0},rotationY:0})}a(fe,"defaultModuleState");function Ae(t,e){return !!t&&!!e&&t.trim().toLowerCase()===e.trim().toLowerCase()}a(Ae,"sameName");function pe(t,e,o){let a=fe(t,o);if(!e)return a;let m=t.modules.get(e.apiModuleId),S={...a.basePartSlots};for(let y of E(o)){let p=e.basePartSlots[y.name];if(!p)continue;let C=t.parts.get(p.apiPartId),x=(y.compatibleParts??[]).map(O=>O.partId),v=x.find(O=>Ae(t.parts.get(O)?.name,C?.name));if(v===void 0){let A=(m?.basePartSlots?.find($=>$.name===y.name)?.compatibleParts??[]).findIndex($=>$.partId===p.apiPartId);A>=0&&A<x.length&&(v=x[A]);}v===void 0&&(v=S[y.name]?.apiPartId),v!==void 0&&(S[y.name]=B(t,v,{surfaceId:p.surfaceId}));}let h=e.size?ke(o.sizing,e.size):null;return J({...a,basePartSlots:S,...h&&{size:h}})}a(pe,"carryOverModuleState");function ke(t,e){if(!t)return null;let o=a((a,m)=>Math.round(Math.min(m.max,Math.max(m.min,a))),"clamp");return {width:o(e.width,t.width),height:o(e.height,t.height)}}a(ke,"fitSize");function ne(t,e){return {productLineId:t.catalog.productLine.id,rootModule:fe(t,e),modifiers:{},quantities:{modules:1,connectors:0},extraConnections:[],environment:"space"}}a(ne,"initialState");function oe(t){return t?1+Object.values(t.children).reduce((e,o)=>e+oe(o),0):0}a(oe,"countModules");function me(t){return {apiPartId:t.apiPartId,partSlots:Object.fromEntries(Object.entries(t.nestedSlots).map(([e,o])=>[e,{part:o?me(o):void 0}]))}}a(me,"rulePart");function F(t,e,o="root"){let a=t.modules.get(e.apiModuleId),m={};for(let[h,y]of Object.entries(e.basePartSlots)){let p=a?.basePartSlots?.find(C=>C.name===h);m[h]={part:me(y),compatibleParts:(p?.compatibleParts??[]).map(C=>({apiPartId:C.partId}))};}let S={};for(let h of a?.moduleSlots??[]){let y=e.children[h.name];S[h.name]={module:y?F(t,y,`${o}/${h.name}`):void 0,compatibleModules:(h.compatibleModuleIds??[]).map(p=>({id:p}))};}return {id:o,apiModuleId:e.apiModuleId,basePartSlots:m,moduleSlots:S}}a(F,"ruleModule");function H(t){let e=[t];for(let o of Object.values(t.moduleSlots))o.module&&e.push(...H(o.module));return e}a(H,"allRuleModules");function N(t,e){return e?/^(https?:|data:|blob:)/i.test(e)?e:new URL(e,`${t}/`).toString():null}a(N,"absoluteUrl");function Q(t,e){if(!t||!e)return t;let o=Date.parse(e);return Number.isNaN(o)?t:`${t}${t.includes("?")?"&":"?"}v=${o}`}a(Q,"versionedUrl");function V(t){return t.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}a(V,"slugify");function D(t){if(Array.isArray(t))return t;let e=t?.items;return Array.isArray(e)?e:[]}a(D,"listRows");function ge(t){return t.status===void 0||t.status==="public"}a(ge,"isPublished");function he(t,e){return {id:e.id,name:e.name,slug:e.slug||V(e.name),description:e.description??null,image:Q(N(t,e.image),e.updatedAt),scenePreset:e.scenePreset??null}}a(he,"toProductLine");function Re(t){let e=new Set;for(let o of t.basePartSlots??[]){o.defaultPartId&&e.add(o.defaultPartId);for(let a of o.compatibleParts??[])e.add(a.partId);}for(let o of t.moduleSlots??[])for(let a of o.accessoryPartIds??[])e.add(a);return e}a(Re,"partIdsOfModule");function ze(t,e){let o=[...t];for(;o.length>0;){let a=e.get(o.pop());for(let m of a?.partSlots??[])for(let S of [m.defaultPartId,...(m.compatibleParts??[]).map(h=>h.partId)])S&&!t.has(S)&&(t.add(S),o.push(S));}return t}a(ze,"closePartIds");var Ne=["normalPath","roughnessPath","metalnessPath","aoPath","heightPath"];function _e(t,e){let o=a(m=>Q(N(t,m),e.updatedAt),"asset"),a$1=null;try{a$1=typeof e.textureJson=="string"?JSON.parse(e.textureJson):e.textureJson??null;}catch{a$1=null;}if(a$1){a$1={...a$1};for(let m of Ne){let S=a$1[m];typeof S=="string"&&(a$1[m]=o(S));}}return {...e,textureJson:a$1,texturePath:o(e.texturePath),thumbnailPath:o(e.thumbnailPath)}}a(_e,"absoluteSurface");function je(t,e){return {...e,image:N(t,e.image),models:e.models.map(o=>o.model3d?{...o,model3d:{...o.model3d,filePath:Q(N(t,o.model3d.filePath),o.model3d.updatedAt)??o.model3d.filePath}}:o)}}a(je,"absolutePart");function be(t,e,o){let a=D(o.modules).filter(ge).map(p=>({...p,image:N(t,p.image)})).sort((p,C)=>(p.sortOrder??0)-(C.sortOrder??0)),m=D(o.parts),S=new Map(m.map(p=>[p.id,p])),h=new Set;for(let p of a)for(let C of Re(p))h.add(C);ze(h,S);let y=D(o.rules).filter(p=>p.productLine?.id===e.id&&ge(p)).sort((p,C)=>C.priority-p.priority);return {productLine:e,modules:a,parts:m.filter(p=>h.has(p.id)).map(p=>je(t,p)),surfaces:D(o.surfaces).filter(p=>p.status!=="deleted").map(p=>_e(t,p)),surfaceGroups:D(o.surfaceGroups),rules:y}}a(be,"buildLineCatalog");var Se={cs:{module:"Model",surface:"Povrch",size:"Rozm\u011Br"},en:{module:"Model",surface:"Finish",size:"Size"},de:{module:"Modell",surface:"Oberfl\xE4che",size:"Ma\xDF"},fr:{module:"Mod\xE8le",surface:"Finition",size:"Dimensions"}};function ye(t,e){if(typeof e=="number")return t.find(a=>a.id===e);let o=e.trim().toLowerCase();return t.find(a=>String(a.id)===o)??t.find(a=>a.code?.trim().toLowerCase()===o)??t.find(a=>a.name.trim().toLowerCase()===o)}a(ye,"findOption");function Te(t){let e=t.textureJson,o=e&&typeof e=="object"?e.color:void 0;return typeof o=="string"?o:null}a(Te,"colourOf");function Pe(t){let e=ce(t.catalog),{catalog:o}=t,a$2=Se[t.locale]??Se.en,m=f(o.rules),S=new Map;if(o.modules.length===0)throw new a$1("unknown_module",`Product line "${o.productLine.name}" has no published modules`);let h=t.state?p(t.state):ne(e,y(t.module));function y(n){if(n===void 0)return o.modules.find(s=>s.allowAsInitialModule!==false)??o.modules[0];let r=ye(o.modules,n);if(!r)throw new a$1("unknown_module",`No module "${n}" in product line "${o.productLine.name}"`);return r}a(y,"resolveModule");function p(n){if(n.productLineId!=null&&n.productLineId!==o.productLine.id)throw new a$1("invalid_state",`State is for product line ${n.productLineId}, this configurator is ${o.productLine.id}`);let r=n.rootModule?J(n.rootModule):null;if(r&&!e.modules.has(r.apiModuleId))throw new a$1("invalid_state",`Module ${r.apiModuleId} is not in this line`);return {productLineId:o.productLine.id,rootModule:r,modifiers:n.modifiers??{},quantities:{...n.quantities,modules:oe(r)},extraConnections:n.extraConnections??[],environment:n.environment??"space"}}a(p,"normalise");function C(){let n=h.rootModule;if(!n)throw new a$1("invalid_state","The configuration has no module");return n}a(C,"root");function x(){return e.modules.get(C().apiModuleId)}a(x,"currentModule");function v(n){return x().basePartSlots?.find(r=>r.name===n)}a(v,"slotOf");function O(){return E(x()).filter(n=>!n.syncWithSlotName)}a(O,"leaderSlots");function A(n){return E(x()).filter(r=>r.syncWithSlotName===n)}a(A,"followersOf");function $(n){return (n.compatibleParts??[]).map(r=>e.parts.get(r.partId)).filter(r=>!!r&&!r.hideFromConfigurator)}a($,"visibleParts");function _(n){let r=C().basePartSlots[n]?.apiPartId;return r===void 0?void 0:e.parts.get(r)}a(_,"partIn");function W(){return O().filter(n=>{let r=_(n.name);return r?q(e,r).length>0:false})}a(W,"surfaceSlots");function j(){let n=[];o.modules.length>1&&n.push({key:"module",kind:"module",label:a$2.module});for(let s of O())$(s).length>1&&n.push({key:s.name,kind:"part",label:s.label||s.name});let r=W();for(let s of r)q(e,_(s.name)).length>1&&n.push({key:`surface:${s.name}`,kind:"surface",label:s.label||s.name,slots:[s.name]});return r.length>0&&n.push({key:"surface",kind:"surface",label:a$2.surface,slots:r.map(s=>s.name)}),n}a(j,"groups");function K(n){let r=j().find(s=>s.key===n);if(!r){let s=j().map(f=>f.key).join(", ");throw new a$1("unknown_group",`No group "${n}" (this module has: ${s})`)}return r}a(K,"requireGroup");function Z(){let n=C().apiModuleId;return o.modules.map(r=>({id:r.id,code:r.code??null,name:r.name,description:r.description??null,image:r.image??null,sizes:r.sizes??null,sizing:r.sizing??null,selected:r.id===n,disabled:false,reason:null}))}a(Z,"moduleOptions");function ee(n){let r=v(n),s=C(),f=s.basePartSlots[n]?.apiPartId,u=F(e,s),b=H(u);return $(r).map(c=>{let g=c.id===f?null:m.checkPart(c.id,n,u,b,n);return {id:c.id,code:c.code??null,name:c.name,description:c.description??null,image:c.image??null,selected:c.id===f,disabled:!!g,reason:g?.message??null}})}a(ee,"partOptions");function d(n){let r=C(),s=new Map;for(let u of n){let b=_(u);if(b)for(let c of q(e,b)){let g=s.get(c.id)??{surface:c,slots:[]};g.slots.push(u),s.set(c.id,g);}}let f=n.map(u=>r.basePartSlots[u]?.surfaceId);return o.surfaces.filter(u=>s.has(u.id)).map(u=>{let{slots:b}=s.get(u.id),c=u.groupId!=null?e.surfaceGroups.get(u.groupId):void 0;return {id:u.id,code:null,name:u.name,description:u.description??null,image:u.thumbnailPath??u.texturePath??null,color:Te(u),groupId:u.groupId??null,groupName:c?.name??null,slots:b,selected:f.length>0&&f.every(g=>g===u.id),disabled:false,reason:null}})}a(d,"surfaceOptions");function l(n){let r=K(n);return r.kind==="module"?Z():r.kind==="part"?ee(r.key):d(r.slots??[])}a(l,"options");function P(n){return l(n).find(r=>r.selected)??null}a(P,"selected");function I(n,r){let s=J(n);h={...h,rootModule:s,quantities:{...h.quantities,modules:1}},te("change",{state:T(),changed:r});}a(I,"commit");function w(n,r,s){let f={...n.basePartSlots};for(let u of [r,...A(r).map(b=>b.name)]){if(!v(u)?.compatibleParts?.some(g=>g.partId===s))continue;let c=f[u];c?.apiPartId!==s&&(f[u]=B(e,s,{surfaceId:c?.surfaceId}));}return {...n,basePartSlots:f}}a(w,"placePart");function L(n,r,s){let f=e.parts.get(n.apiPartId),u=!!f?.hasConfigurableSurface&&U(e,f,r),b=Object.fromEntries(Object.entries(n.nestedSlots).map(([c,g])=>[c,g&&g.surfaceId===s?L(g,r,s):g]));return {...n,...u&&{surfaceId:r},nestedSlots:b}}a(L,"paint");function R(n,r,s){let f={...n.basePartSlots};for(let u of r)for(let b of [u,...A(u).map(c=>c.name)]){let c=f[b];c&&(f[b]=L(c,s,c.surfaceId));}return {...n,basePartSlots:f}}a(R,"paintSlots");function k(n,r){let s=K(n),f=l(n),u=ye(f,r);if(!u){let g=f.map(z=>z.name).join(", ");throw new a$1("unknown_option",`No option "${r}" in "${n}" (${g})`)}if(u.disabled)throw new a$1("option_disabled",u.reason??`"${u.name}" is ruled out`);if(u.selected)return false;let b=C();if(s.kind==="module")return I(pe(e,b,e.modules.get(u.id)),["*"]),true;if(s.kind==="part"){let g=w(b,n,u.id),z=[n],G=F(e,g);for(let Y of m.partChangeSyncs(u.id,n,G,H(G)))Y.moduleId===G.id&&(g=w(g,Y.slotName,Y.newPartId),z.push(Y.slotName));return I(g,z),true}let c=u.slots;return I(R(b,c,u.id),[n,...c.map(g=>`surface:${g}`)].filter((g,z,G)=>G.indexOf(g)===z)),true}a(k,"select");function X(){let n=x().sizing;return n?JSON.parse(JSON.stringify(n)):null}a(X,"sizeLimits");function Ie(){let n=C().size;return n?{...n}:null}a(Ie,"size");function we(n){let r=C();if(n===null){if(!r.size)return false;let{size:c,...g}=r;return I(g,["size"]),true}let s=X();if(!s)throw new a$1("size_not_available",`"${x().name}" comes in one size only`);let f=Math.round(n.width),u=Math.round(n.height),b=a((c,g)=>Number.isFinite(c)&&c>=g.min&&c<=g.max,"fits");if(!b(f,s.width)||!b(u,s.height))throw new a$1("size_out_of_range",`${f} \xD7 ${u} mm is outside ${s.width.min}\u2013${s.width.max} \xD7 ${s.height.min}\u2013${s.height.max} mm`,{details:s});return r.size?.width===f&&r.size?.height===u?false:(I({...r,size:{width:f,height:u}},["size"]),true)}a(we,"setSize");function Ce(){let n=C(),r=x(),s=[{group:"module",label:a$2.module,value:r.name,optionId:r.id}];n.size&&s.push({group:"size",label:a$2.size,value:`${n.size.width} \xD7 ${n.size.height} mm`,optionId:r.id});for(let f of O()){let u=_(f.name);if(!u)continue;$(f).length>1&&s.push({group:f.name,label:f.label||f.name,value:u.name,optionId:u.id});let b=n.basePartSlots[f.name]?.surfaceId,c=b!==void 0?e.surfaces.get(b):void 0;c&&q(e,u).length>0&&s.push({group:`surface:${f.name}`,label:f.label||f.name,value:c.name,optionId:c.id});}return s}a(Ce,"summary");function re(){let n=[],r=h.rootModule;if(!r)return n.push({group:"module",code:"missing_module",message:"No module chosen"}),{valid:false,issues:n};let s=F(e,r),f=H(s);for(let u of E(x())){let b=r.basePartSlots[u.name];if(!b)continue;let c=e.parts.get(b.apiPartId);if(!c||!u.compatibleParts?.some(z=>z.partId===b.apiPartId)){n.push({group:u.name,code:"incompatible_part",message:`Part ${b.apiPartId} does not fit slot "${u.name}"`});continue}let g=m.checkPart(c.id,u.name,s,f,u.name);g&&n.push({group:u.name,code:"rule_violation",message:g.message}),b.surfaceId!==void 0&&!U(e,c,b.surfaceId)&&n.push({group:`surface:${u.name}`,code:"surface_not_allowed",message:`Finish ${b.surfaceId} is not offered for "${c.name}"`});}return {valid:n.length===0,issues:n}}a(re,"validate");function T(){return JSON.parse(JSON.stringify(h))}a(T,"toJSON");function Me(n){h=p(n),te("change",{state:T(),changed:["*"]});}a(Me,"load");function xe(n){h=ne(e,n===void 0?x():y(n)),te("change",{state:T(),changed:["*"]});}a(xe,"reset");function Le(n,r){let s=S.get(n)??new Set;return s.add(r),S.set(n,s),()=>{s.delete(r);}}a(Le,"on");function te(n,r){for(let s of S.get(n)??[])try{s(r);}catch(f){console.error("[konfigure] change listener failed",f);}}a(te,"emit");function ve(n={}){let r=n.name??`${o.productLine.name} \xB7 ${x().name}`;return t.save(T(),r)}a(ve,"save");function Oe(n){let r=re();if(!r.valid)throw new a$1("invalid_state",r.issues.map(s=>s.message).join("; "),{details:r.issues});return t.submitInquiry(T(),n)}return a(Oe,"submitInquiry"),{productLine:o.productLine,catalog:o,instance:t.instance,groups:j,options:l,selected:P,select:k,summary:Ce,validate:re,price:a(()=>null,"price"),module:a(()=>x(),"module"),size:Ie,setSize:we,sizeLimits:X,toJSON:T,load:Me,reset:xe,on:Le,save:ve,submitInquiry:Oe}}a(Pe,"createConfigurator");function tt(t){let e=t.instance.replace(/\/+$/,""),o=t.locale??"cs",a$2=t.fetch??globalThis.fetch.bind(globalThis),m=o==="cs"?"":`/${o}`,S=null,h=new Map;async function y(d,l){let P=`${e}${d}${d.includes("?")?"&":"?"}locale=${o}`,I;try{I=await a$2(P,{method:l?.method??"GET",headers:{Accept:"application/json",...l?.body!==void 0&&{"Content-Type":"application/json"}},body:l?.body!==void 0?JSON.stringify(l.body):void 0,credentials:"omit"});}catch(w){throw new a$1("network",`Could not reach ${e}${d} \u2014 is the instance running, and is this site's origin on its allowed origins?`,{cause:w})}if(!I.ok){let w;try{w=await I.json();}catch{w=void 0;}let L=w?.why??w?.message??I.statusText;throw new a$1("http",`${l?.method??"GET"} ${d}: ${L}`,{status:I.status,details:w})}return await I.json()}a(y,"request");function p(d){return {shareUrl:`${e}${m}/configuration/${d}`,viewUrl:`${e}${m}/configuration/${d}/view`}}a(p,"links");function C(){return S??=y("/api/product-lines/active").then(d=>d.map(l=>he(e,l))).catch(d=>{throw S=null,d}),S}a(C,"productLines");async function x(d){let l=await C(),P=typeof d=="string"?d.trim().toLowerCase():d,I=l.find(w=>w.id===P||String(w.id)===P)??l.find(w=>w.slug===P)??l.find(w=>typeof P=="string"&&V(w.name)===V(P));if(!I){let w=l.map(L=>L.slug).join(", ");throw new a$1("unknown_product_line",`No product line "${d}" (${w})`)}return I}a(x,"productLine");let v=new Map;function O(d){let l=v.get(d);return l||(l=y(d),l.catch(()=>v.delete(d)),v.set(d,l)),l}a(O,"shared");function A(d){return x(d).then(l=>{let P=h.get(l.id);return P||(P=Promise.all([y(`/api/product-lines/${l.id}/modules`),O("/api/parts"),O("/api/surfaces"),O("/api/surface-groups"),O("/api/rules").catch(()=>[])]).then(([I,w,L,R,k])=>be(e,l,{modules:I,parts:w,surfaces:L,surfaceGroups:R,rules:k})),P.catch(()=>h.delete(l.id)),h.set(l.id,P)),P})}a(A,"catalog");let $=null;function _(){return $??=y("/api/showroom/sdk").then(d=>({...d,files:N(e,d.files)})).catch(d=>{throw $=null,d}),$}a(_,"showroom");async function W(d){let l=await y(`/api/saved-configurations/${encodeURIComponent(d)}`),P=[...l.versions??[]].sort((L,R)=>R.versionNumber-L.versionNumber),I=P.find(L=>L.versionNumber===l.currentVersionNumber)??P[0];if(!I)throw new a$1("invalid_state",`Configuration ${d} has no saved version`);let w=JSON.parse(I.configurationJson);return {id:l.id,displayId:l.displayId??null,name:l.name,productLineId:w.productLineId??l.productLineId??null,state:w,...p(l.id)}}a(W,"getConfiguration");async function j(d,l){let P=await y("/api/saved-configurations",{method:"POST",body:{name:l,status:"public",configurationJson:JSON.stringify(d),remoteProductLineId:d.productLineId}});return {id:P.id,displayId:P.displayId??null,...p(P.id)}}a(j,"saveConfiguration");async function K(d,l){let[P,...I]=(l.name??"").trim().split(/\s+/),w=Object.entries(l.extra??{}).filter(([,k])=>k!=null&&k!=="").map(([k,X])=>`${k}: ${X}`),L=[l.message?.trim(),w.join(`
|
|
2
|
+
`)].filter(Boolean).join(`
|
|
3
|
+
|
|
4
|
+
`),R=await y("/api/inquiries",{method:"POST",body:{projectJson:JSON.stringify(d),remoteProductLineId:d.productLineId,contactSnapshot:{email:l.email,...P&&{firstName:P},...I.length>0&&{lastName:I.join(" ")},...l.phone&&{phone:l.phone},...l.company&&{companyName:l.company}},note:L||void 0,state:"submitted"}});return {id:R.id,displayId:R.displayId??null}}a(K,"submitInquiry");async function Z(d){return y("/api/leads",{method:"POST",body:{data:d.data,gateKey:d.gateKey,configId:d.configurationId,locale:o}})}a(Z,"submitLead");async function ee(d){let l,P;if("configuration"in d){let I=await W(d.configuration);if(I.productLineId==null)throw new a$1("invalid_state",`Configuration ${I.id} has no product line`);l=I.state,P=I.productLineId;}else l=d.state,P=d.productLine;return Pe({catalog:await A(P),locale:o,instance:e,module:"module"in d?d.module:void 0,state:l,save:j,submitInquiry:K})}return a(ee,"configurator"),{instance:e,locale:o,productLines:C,productLine:x,catalog:A,configurator:ee,showroom:_,getConfiguration:W,saveConfiguration:j,submitInquiry:K,submitLead:Z}}a(tt,"createKonfigureClient");export{ce as a,fe as b,pe as c,tt as d};
|