import*as t from"lit/directives/style-map.js";import*as e from"lit";import*as a from"@momentum-ui/utils/lib/getColorValue";import*as i from"lit/directives/if-defined.js";import*as r from"lit/directives/class-map.js";import*as o from"mobx";import*as s from"lit/decorators.js";import*as n from"@momentum-ui/icons/data/momentumUiIconsNames.json";var l,p,m={1156(e,a,i){var r,o;e.exports=(r={styleMap:()=>t.styleMap},o={},i.d(o,r),o)},2927(t,a,i){var r,o;t.exports=(r={LitElement:()=>e.LitElement,css:()=>e.css,html:()=>e.html,nothing:()=>e.nothing},o={},i.d(o,r),o)},3496(t,e,i){var r,o;t.exports=(r={default:()=>a.default},o={},i.d(o,r),o)},3517(t,e,a){var r,o;t.exports=(r={ifDefined:()=>i.ifDefined},o={},a.d(o,r),o)},4955(t,e,a){var i,o;t.exports=(i={classMap:()=>r.classMap},o={},a.d(o,i),o)},4980(t,e,a){var i,r;t.exports=(i={action:()=>o.action,observable:()=>o.observable},r={},a.d(r,i),r)},8751(t,e,a){a.d(e,{d:()=>i}),a(5983),a(1821);var i,r=a(9609),o=a(4084),s=a(2927),n=a(8899),l=a(9940),p=function(t,e,a,i){var r,o=arguments.length,s=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,a,i);else for(var n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o<3?r(s):o>3?r(e,a,s):r(e,a))||s);return o>3&&s&&Object.defineProperty(e,a,s),s};!function(t){let e=class extends s.LitElement{constructor(){super(...arguments),this._currentPage=1,this.hasDots=!1,this.onlyDots=!1,this.noNavigation=!1,this.totalPage=0,this.visiblePage=3}get currentPage(){return this._currentPage}set currentPage(t){const e=this._currentPage;this._currentPage=t,this.notifyPageChange(e,t),this.requestUpdate("currentPage",e)}static get styles(){return[o.A,l.A]}computePrevious(t){1!==t&&t!==this.currentPage&&(this.currentPage-=1)}computeNext(t){t<=this.totalPage&&t!==this.currentPage&&(this.currentPage+=1)}computeFirst(){this.currentPage>=1&&(this.currentPage=1)}computeLast(){this.currentPage>=1&&(this.currentPage=this.totalPage)}computeCurrent(t){this.currentPage=t}notifyPageChange(t,e){this.dispatchEvent(new CustomEvent("page-change",{composed:!0,bubbles:!0,detail:{oldPage:t,newPage:e}}))}get hasPreviousPage(){return this.currentPage<=1}get hasNextPage(){return this.currentPage>=this.totalPage}computePageList(t){if(this.totalPage>this.visiblePage&&t){const[t,e,a]=[this.currentPage-1,this.currentPage,this.currentPage+1];let i=[];if(e<=this.visiblePage-1)return i=[...Array(this.visiblePage)].map((t,e)=>1+e),i.push("..."),i.push(this.totalPage),i;if(this.totalPage-e<=this.visiblePage-2){i=[],i.push(1),i.push("...");const t=[...Array(this.visiblePage)].map((t,e)=>this.totalPage-this.visiblePage+1+e);return i.concat(t)}return[1,"...",t,e,a,"...",this.totalPage]}return[...Array(this.totalPage)].map((t,e)=>1+e)}pagesTemplate(t){return this.computePageList(t).map(t=>"..."===t?s.html` <li class="page-ellipsis">${t}</li> `:s.html`
              <li @click=${()=>this.computeCurrent(t)} aria-current=${t===this.currentPage}>
                ${t}
              </li>
            `)}dotsTemplate(t){return this.computePageList(t).map(t=>"..."===t?s.nothing:s.html`
              <li @click=${()=>this.computeCurrent(t)} aria-current=${t===this.currentPage}></li>
            `)}render(){return s.html`
        <nav class="md-pagination" role="navigation" part="pagination">
          ${this.noNavigation?s.nothing:s.html`
                <md-button
                  class="md-pagination-nav"
                  ariaLabel="First Page"
                  ?disabled=${this.hasPreviousPage}
                  @click=${this.computeFirst}
                  part="pagination-first"
                  variant="ghost"
                  size="24"
                  circle
                >
                  <md-icon name="overflow-left-bold" size="16" iconSet="momentumDesign"></md-icon>
                </md-button>
                <md-button
                  class="md-pagination-nav"
                  ariaLabel="Next Page"
                  ?disabled=${this.hasPreviousPage}
                  @click=${()=>this.computePrevious(this.currentPage-1)}
                  part="pagination-prev"
                  variant="ghost"
                  size="24"
                  circle
                >
                  <md-icon name="arrow-left-bold" size="16" iconSet="momentumDesign"></md-icon>
                </md-button>
              `}
          <div class="md-pagination-container">
            ${this.onlyDots?s.html`
                  <ul class="md-pagination-dots" part="pagination-only-dots">
                    ${this.dotsTemplate(!1)}
                  </ul>
                `:s.html`
                  <ul class="md-pagination-list" part=pagination-list">
                    ${this.pagesTemplate(!0)}
                  </ul>
                `}
            ${this.hasDots&&!this.onlyDots?s.html`
                  <ul class="md-pagination-dots" part="pagination-dots">
                    ${this.dotsTemplate(!0)}
                  </ul>
                `:s.nothing}
          </div>
          ${this.noNavigation?s.nothing:s.html`
                <md-button
                  class="md-pagination-nav"
                  ariaLabel="Previous Page"
                  ?disabled=${this.hasNextPage}
                  @click=${()=>this.computeNext(this.currentPage+1)}
                  part="pagination-next"
                  variant="ghost"
                  size="24"
                  circle
                >
                  <md-icon name="arrow-right-bold" size="16" iconSet="momentumDesign"></md-icon>
                </md-button>
                <md-button
                  class="md-pagination-nav"
                  ariaLabel="Last Page"
                  ?disabled=${this.hasNextPage}
                  @click=${this.computeLast}
                  part="pagination-last"
                  variant="ghost"
                  size="24"
                  circle
                >
                  <md-icon name="overflow-right-bold" size="16" iconSet="momentumDesign"></md-icon>
                </md-button>
              `}
        </nav>
      `}};p([(0,n.property)({type:Boolean,attribute:"dots"})],e.prototype,"hasDots",void 0),p([(0,n.property)({type:Boolean,reflect:!0,attribute:"only-dots"})],e.prototype,"onlyDots",void 0),p([(0,n.property)({type:Boolean,reflect:!0,attribute:"no-navigation"})],e.prototype,"noNavigation",void 0),p([(0,n.property)({type:Number,reflect:!0,attribute:"total-page"})],e.prototype,"totalPage",void 0),p([(0,n.property)({type:Number,reflect:!0,attribute:"visible-page"})],e.prototype,"visiblePage",void 0),p([(0,n.property)({type:Number,reflect:!0,attribute:"current-page"})],e.prototype,"currentPage",null),e=p([(0,r.w)("md-pagination")],e),t.ELEMENT=e}(i||(i={}))},8899(t,e,a){var i,r;t.exports=(i={property:()=>s.property,query:()=>s.query,state:()=>s.state},r={},a.d(r,i),r)},9500(t,e,a){var i,r;t.exports=(i={default:()=>n.default},r={},a.d(r,i),r)}},c={};function g(t){var e=c[t];if(void 0!==e)return e.exports;var a=c[t]={exports:{}};return m[t](a,a.exports,g),a.exports}g.m=m,l=[],g.O=(t,e,a,i)=>{if(!e){var r=1/0;for(p=0;p<l.length;p++){for(var[e,a,i]=l[p],o=!0,s=0;s<e.length;s++)(!1&i||r>=i)&&Object.keys(g.O).every(t=>g.O[t](e[s]))?e.splice(s--,1):(o=!1,i<r&&(r=i));if(o){l.splice(p--,1);var n=a();void 0!==n&&(t=n)}}return t}i=i||0;for(var p=l.length;p>0&&l[p-1][2]>i;p--)l[p]=l[p-1];l[p]=[e,a,i]},g.d=(t,e)=>{for(var a in e)g.o(e,a)&&!g.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},g.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{g as __webpack_require__};p={502:0,1745:0,1788:0,4545:0,4928:0,5369:0,6060:0,6920:0,8111:0,8442:0},g.C=t=>{var e,a,{__webpack_esm_ids__:i,__webpack_esm_modules__:r,__webpack_esm_runtime__:o}=t,s=0;for(e in r)g.o(r,e)&&(g.m[e]=r[e]);for(o&&o(g);s<i.length;s++)a=i[s],g.o(p,a)&&p[a]&&p[a][0](),p[i[s]]=0;g.O()},g.O.j=t=>0===p[t];import*as u from"../9609.js";g.C(u);import*as h from"../4084.js";g.C(h);import*as d from"../3305.js";g.C(d);import*as v from"../4739.js";g.C(v);import*as P from"../7154.js";g.C(P);import*as f from"../9773.js";g.C(f);import*as b from"../5983.js";g.C(b);import*as y from"../9488.js";g.C(y);import*as j from"../1821.js";g.C(j);import*as x from"../519.js";g.C(x);import*as _ from"../9940.js";g.C(_);var $=g.O(void 0,[9609,4084,3305,4739,7154,9773,5983,9488,1821,519,9940],()=>g(8751));const C=($=g.O($)).d;export{C as Pagination};