!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";const t=Symbol("isProxy");function e(t){return t.replace(/\B([A-Z])(?=[a-z])/g,"-$1").replace(/\B([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function n(t){return t.replace(/-([a-z])/g,(t=>t[1].toUpperCase()))}function i(t,...e){console.warn(`[Minze warn] ${t}`,...e)}class Minze{static define(t,e){customElements.define(t,e)}static defineAll(t){Array.isArray(t)||(t=Object.values(t)),t.forEach((t=>{const n=e(t.name);customElements.define(n,t)}))}static cast(t,e){dispatchEvent(new CustomEvent(t,{detail:e}))}static listen(t,e){addEventListener(t,e,!0)}static stopListen(t,e){removeEventListener(t,e,!0)}}function o(t,e,n,i){return new(n||(n=Promise))((function(o,r){function a(t){try{c(i.next(t))}catch(e){r(e)}}function s(t){try{c(i.throw(t))}catch(e){r(e)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((i=i.apply(t,e||[])).next())}))}function r(t,e){const n="function"==typeof t?t():t,i=document.createElement("template");i.innerHTML=n,a(i,e),s(i,e)}function a(t,e){const n=t instanceof HTMLTemplateElement?t.content.childNodes:t.childNodes;n.length===e.childNodes.length?Array.from(n).forEach(((t,n)=>{const i=t,o=e.childNodes[n];i.isEqualNode(o)||(o.nodeType===Node.TEXT_NODE||o.nodeType===Node.COMMENT_NODE?o.textContent=i.textContent:o.nodeType===Node.ELEMENT_NODE&&a(i,o))})):e.textContent=t.textContent}function s(t,e){const n=t instanceof HTMLTemplateElement?t.content.children:t.children;n.length===e.children.length?Array.from(n).some(((t,n)=>{const i=t,o=e.children[n];if(!i.isEqualNode(o)){if(i.nodeName!==o.nodeName)return void o.replaceWith(i);Array.from(i.attributes).forEach((t=>{t.value!==o.getAttribute(t.name)&&o.setAttribute(t.name,t.value)})),Array.from(o.attributes).forEach((t=>{i.hasAttribute(t.name)||o.removeAttribute(t.name)})),s(i,o)}})):e.innerHTML=t.innerHTML}Minze.version="1.1.1";class MinzeElement extends HTMLElement{constructor(){super(),this.version="1.1.1",this.cachedTemplate=null,this.attachShadow({mode:"open"})}static get dashName(){return e(this.name)}static define(t){t||(t=e(this.name)),customElements&&customElements.define(t,this)}template(){var t,e,n,i;return`\n      <style>\n        :host { box-sizing: border-box; display: block; }\n        :host([hidden]) { display: none; }\n        * { box-sizing: border-box; }\n        ${null!==(e=null===(t=this.css)||void 0===t?void 0:t.call(this))&&void 0!==e?e:""}\n      </style>\n      ${null!==(i=null===(n=this.html)||void 0===n?void 0:n.call(this))&&void 0!==i?i:"<slot></slot>"}\n    `}render(t){var e,n,i,a;return o(this,void 0,void 0,(function*(){if(this.shadowRoot){const s=this.template();if(s!==this.cachedTemplate||t){const c=this.cachedTemplate;this.cachedTemplate=s,yield null===(e=this.beforeRender)||void 0===e?void 0:e.call(this),null===(n=this.eventListeners)||void 0===n||n.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerEvent(t,"remove")})))),!c||t?this.shadowRoot.innerHTML=s:r(s,this.shadowRoot),null===(i=this.eventListeners)||void 0===i||i.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerEvent(t,"add")})))),null===(a=this.onRender)||void 0===a||a.call(this)}}}))}rerender(t){this.render(t)}select(t){var e;const n=this.shadowRoot;return null!==(e=null==n?void 0:n.querySelector(t))&&void 0!==e?e:null}selectAll(t){var e;const n=this.shadowRoot;return null!==(e=null==n?void 0:n.querySelectorAll(t))&&void 0!==e?e:null}exposeAttr(t,n){const i=e(t);this.setAttribute(i,"object"==typeof n?JSON.stringify(n):String(n))}reactiveChange(t,n,i,r,a,s,c){var d;return o(this,void 0,void 0,(function*(){const i=n,l=e(n);null===(d=this.watch)||void 0===d||d.forEach((([e,n])=>o(this,void 0,void 0,(function*(){(e===i||"attr"===t&&e===l)&&n(s,c,a,r)})))),this.render()}))}makeComplexReactive(e,n,i){const o=e,r=n;i&&this.exposeAttr(o,r);const a=()=>({get:(e,n)=>{if(n===t)return!0;let i=Reflect.get(e,n);return"object"!=typeof i||i[t]||(i=s(i),Reflect.set(e,n,i)),i},set:(t,e,n)=>{const a=Reflect.get(t,e);return a!==n&&(Reflect.set(t,e,n),i&&this.exposeAttr(o,r),this.reactiveChange("complex",o,r,t,e,n,a)),!0}}),s=t=>new Proxy(t,a());this[o]=s(r)}makePrimitiveReactive(t,e,n){const i=t,o=`$minze_stash_prop_${t}`;this[o]=e,n&&this.exposeAttr(t,e),Object.defineProperty(this,t,{get:()=>this[o],set:e=>{const r=this[o];r!==e&&(this[o]=e,n&&this.exposeAttr(t,e),this.reactiveChange("primitive",i,this[o],this,i,e,r))}})}registerProp(t){const e="string"==typeof t?t:t[0],n="string"==typeof t?null:t[1],o="string"==typeof t?void 0:t[2],r=e;r in this?i(`A property with the name "${r}" already exists in this component.`):n&&"object"==typeof n?this.makeComplexReactive(r,n,o):this.makePrimitiveReactive(r,n,o)}registerAttr(t){const e="string"==typeof t?t:t[0],o="string"==typeof t?null:t[1],r=n(e),a=e,s=r,c="object"==typeof o?JSON.stringify(o):String(o);if(r in this)return void i(`A property with the name "${r}" already exists.`);const d=`$minze_stash_attr_${r}`;this[d]=c,Array.isArray(t)&&2===t.length&&!this.getAttribute(a)&&this.setAttribute(a,c),Object.defineProperty(this,r,{get:()=>{const t=this.getAttribute(a);return"undefined"==t?void 0:"null"==t?null:""===t||((null==t?void 0:t.match(/^(true|false)$/))?JSON.parse(t):t)},set:t=>{const e=this[d];e!==t&&(this[d]=t,this.reactiveChange("attr",s,this[d],this,s,t,e))}})}registerEvent(t,e){var n;const[i,o,r]=t;let a;i===window?a=[window]:i instanceof MinzeElement?a=[this]:"string"==typeof i&&(a=null===(n=this.shadowRoot)||void 0===n?void 0:n.querySelectorAll(i)),null==a||a.forEach((t=>{"add"===e?t.addEventListener(o,r,!0):t.removeEventListener(o,r,!0)}))}cast(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}connectedCallback(){var t,e,n,i,r,a,s;return o(this,void 0,void 0,(function*(){null===(t=this.onStart)||void 0===t||t.call(this),null===(e=this.reactive)||void 0===e||e.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerProp(t)})))),null===(n=this.attrs)||void 0===n||n.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerAttr(t)})))),null===(i=this.onReactive)||void 0===i||i.call(this),yield this.render(),(null===(a=null===(r=this.options)||void 0===r?void 0:r.exposeAttrs)||void 0===a?void 0:a.rendered)&&this.setAttribute("rendered",""),null===(s=this.onReady)||void 0===s||s.call(this)}))}disconnectedCallback(){var t,e;return o(this,void 0,void 0,(function*(){null===(t=this.eventListeners)||void 0===t||t.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerEvent(t,"remove")})))),null===(e=this.onDestroy)||void 0===e||e.call(this)}))}adoptedCallback(){var t,e;return o(this,void 0,void 0,(function*(){null===(t=this.eventListeners)||void 0===t||t.forEach((t=>o(this,void 0,void 0,(function*(){return this.registerEvent(t,"remove")})))),null===(e=this.onMove)||void 0===e||e.call(this)}))}attributeChangedCallback(t,e,i){var r,a;return o(this,void 0,void 0,(function*(){yield null===(r=this.beforeAttributeChange)||void 0===r?void 0:r.call(this,t,e,i);const o=n(t);o in this&&i!==e&&(this[o]=i),null===(a=this.onAttributeChange)||void 0===a||a.call(this,t,e,i)}))}}const c=Object.freeze(Object.defineProperty({__proto__:null,MauveLoadingIndicator:class MauveLoadingIndicator extends MinzeElement{constructor(){super(...arguments),this.attrs=["no-style",["exportparts","mauve-loading-indicator"]],this.html=()=>'\n    <div part="mauve-loading-indicator"></div>\n  ',this.css=()=>this.noStyle?"":"\n    :host {\n      display: flex;\n      justify-content: center;\n      align-items: center;\n      grid-column: 1 / -1;\n    }\n\n    [part=mauve-loading-indicator] {\n      pointer-events: none;\n      width: 42px;\n      height: 42px;\n      border: 6px solid transparent;\n      border-color: var(--mauve-loading-indicator-color-bg, rgb(230 230 230));\n      border-top-color: var(--mauve-loading-indicator-color-fg, rgb(20 99 159));\n      border-radius: 50%;\n      animation: spin 1s linear infinite;\n    }\n\n    @keyframes spin {\n      100% {\n        transform: rotate(360deg);\n      }\n    }\n  "}},MauveProduct:class MauveProduct extends MinzeElement{constructor(){super(...arguments),this.reactive=["productData"],this.attrs=["no-style","raw-data",["exportparts","mauve-product__image, mauve-product__caption, mauve-product__name, mauve-product__property, mauve-product__price, mauve-product__suggested-price"]],this.html=()=>{var t,e,n,i,o,r,a,s,c,d,l,u;return`\n    <a\n      href="${null==(t=this.productData)?void 0:t.shopUrl}"\n      target="_blank"\n      part="mauve-product__image"\n    >\n      <img\n        src="${null==(e=this.productData)?void 0:e.listImageUrl}"\n        loading="lazy"\n        width="120"\n        height="120"\n        onerror="this.src = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyNCAyNCIgc3Ryb2tlLXdpZHRoPSIxIiBzdHJva2U9InJnYigyMzAgMjMwIDIzMCkiIGNsYXNzPSJ3LTYgaC02Ij4gPHBhdGggc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkPSJNMi4yNSAxNS43NWw1LjE1OS01LjE1OWEyLjI1IDIuMjUgMCAwMTMuMTgyIDBsNS4xNTkgNS4xNTltLTEuNS0xLjVsMS40MDktMS40MDlhMi4yNSAyLjI1IDAgMDEzLjE4MiAwbDIuOTA5IDIuOTA5bS0xOCAzLjc1aDE2LjVhMS41IDEuNSAwIDAwMS41LTEuNVY2YTEuNSAxLjUgMCAwMC0xLjUtMS41SDMuNzVBMS41IDEuNSAwIDAwMi4yNSA2djEyYTEuNSAxLjUgMCAwMDEuNSAxLjV6bTEwLjUtMTEuMjVoLjAwOHYuMDA4aC0uMDA4VjguMjV6bS4zNzUgMGEuMzc1LjM3NSAwIDExLS43NSAwIC4zNzUuMzc1IDAgMDEuNzUgMHoiIC8+PC9zdmc+'"\n      >\n    </a>\n\n    <div part="mauve-product__caption">\n      Abb. ähnlich\n    </div>\n\n    <a\n      href="${null==(n=this.productData)?void 0:n.shopUrl}"\n      target="_blank"\n      part="mauve-product__name"\n    >\n      ${null==(i=this.productData)?void 0:i.name}\n    </a>\n\n    <div part="mauve-product__property">\n      Artikelnummer: ${null==(o=this.productData)?void 0:o.sku}\n    </div>\n\n    <div part="mauve-product__price">\n      ${this.formatPrice(null==(r=this.productData)?void 0:r.price)}${null==(a=this.productData)?void 0:a.currencySymbol}\n\n      ${(null==(s=this.productData)?void 0:s.suggestedRetailPrice)?`<span part="mauve-product__suggested-price">\n              ${this.formatPrice(null==(c=this.productData)?void 0:c.suggestedRetailPrice)}${null==(d=this.productData)?void 0:d.currencySymbol}\n            </span>`:""}\n    </div>\n\n    ${Number(null==(l=this.productData)?void 0:l.suggestedRetailPrice)>Number(null==(u=this.productData)?void 0:u.price)?'<div part="mauve-product__sale-badge">SALE</div>':""}\n  `},this.css=()=>this.noStyle?"":"\n    :host {\n      display: flex;\n      flex-direction: column;\n      position: relative;\n      background: var(--mauve-product-background, rgb(255 255 255));\n      border: 1px solid var(--mauve-product-border-color, rgb(230 230 230));\n      padding: 20px 15px 15px 15px;\n    }\n\n    [part^=mauve-] {\n      transition: all .125s ease-in-out;\n    }\n\n    [part=mauve-product__image] {\n      display: flex;\n      justify-content: center;\n      width: auto;\n      height: 120px;\n      margin-bottom: 8px;\n    }\n\n    [part=mauve-product__image] img {\n      width: auto;\n      height: 100%;\n      max-width: 100%;\n    }\n\n    [part=mauve-product__image]:hover {\n      opacity: 80%;\n    }\n\n    [part=mauve-product__caption] {\n      color: var(--mauve-product__caption-color, rgb(135 149 161));\n      font-size: 10px;\n      margin-bottom: 12px;\n    }\n\n    [part=mauve-product__name] {\n      display: -webkit-box;\n      color: var(--mauve-product__name-color, rgb(20 99 159));\n      font-size: 15px;\n      font-weight: 700;\n      line-height: 1.5rem;\n      text-decoration: none;\n      overflow: hidden;\n      -webkit-line-clamp: 2;\n      -webkit-box-orient: vertical;\n      margin-bottom: 4px;\n    }\n\n    [part=mauve-product__name]:hover {\n      color: var(--mauve-product__name-color-hover, rgb(135 181 210));\n    }\n\n    [part=mauve-product__property] {\n      color: var(--mauve-product__property-color, rgb(96 111 123));\n      font-size: 11px;\n      margin-top: 4px;\n    }\n\n    [part=mauve-product__price] {\n      color: var(--mauve-product__price-color, rgb(20 20 20));\n      font-size: 15px;\n      font-weight: 700;\n      padding-top: 16px;\n      margin-top: auto;\n    }\n\n    [part=mauve-product__suggested-price] {\n      color: var(--mauve-product__suggested-price-color, rgb(255 0 0));\n      text-decoration: line-through;\n      font-size: 13px;\n      font-weight: 400;\n      margin-left: 4px;\n    }\n\n    [part=mauve-product__sale-badge] {\n      background: var(--mauve-product__sale-badge-background, rgb(255 0 0));\n      color: var(--mauve-product__sale-badge-color, rgb(255 255 255));\n      font-size: 12px;\n      font-weight: 700;\n      padding: 4px 8px;\n      position: absolute;\n      top: 0;\n      left: 0;\n    }\n  "}formatPrice(t){return void 0!==t?t.toFixed(2).replace(".",","):""}async onReactive(){this.rawData&&(this.productData=JSON.parse(this.rawData))}},MauveProducts:class MauveProducts extends MinzeElement{constructor(){super(...arguments),this.reactive=[["products",null]],this.attrs=["no-style",["exportparts","mauve-product"],["columns",[["640px",2],["1024px",3],["1536px",4]]],["key"],["category-id",1],["limit",8]],this.html=()=>{var t;return`${this.products?null==(t=this.products)?void 0:t.map((t=>`\n        <mauve-product\n          raw-data='${JSON.stringify(t)}'\n          ${this.noStyle?"no-style":""}\n        ></mauve-product>\n      `)).join(""):`<mauve-loading-indicator\n        part="mauve-loading-indicator"\n        ${this.noStyle?"no-style":""}\n      ></mauve-loading-indicator>`}`},this.css=()=>`\n    :host {\n      display: -ms-grid;\n      display: grid;\n      -ms-grid-columns: repeat(1, 1fr);\n      grid-template-columns: repeat(1, 1fr);\n      grid-gap: var(--mauve-products-grid-gap, 15px);\n    }\n\n    ${JSON.parse(this.columns).map((([t,e])=>`\n      @media (min-width: ${t}) {\n        :host { grid-template-columns: repeat(${e}, minmax(0, 1fr)); }\n      }\n    `)).join("")}\n  `}get api(){return{key:this.key??"MxkfPYaITzUlaILwRU2EbohHswPoSOob",url:"https://shop.api.mauve.de"}}async getCategory(t,e){const n=`${this.api.url}/categories/${t}/products?limit=${e}`,i=await fetch(n,{method:"GET",headers:{Authorization:`Bearer ${this.api.key}`}});return(await i.json()).products}async onReactive(){try{this.products=await this.getCategory(this.categoryId,this.limit)}catch(t){console.error(t)}}}},Symbol.toStringTag,{value:"Module"}));Minze.defineAll(c)}));
