"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue");const N={key:0},E={key:1},M={key:2},V={key:3},T={key:4},D={key:5},$={key:6},J={key:7},I={key:8},z={key:9},k=e.defineComponent({__name:"vue-awesome-paginate",props:{totalItems:{type:Number,required:!0},itemsPerPage:{type:Number,default:10,validator:t=>{if(t<=0){const u="itemsPerPage attribute must be greater than 0.";throw console.error(u),new TypeError(u)}return!0}},currentPage:{type:Number,default:1,validator:t=>{const u="currentPage attribute must be greater than 0.";if(t<=0)throw console.error(u),new TypeError(u);return!0}},modelValue:{type:Number,required:!0,validator:t=>{const u="v-model is required and must be greater than 0.";if(t<=0)throw console.error(u),new TypeError(u);return!0}},maxPagesShown:{type:Number,default:5,validator:t=>{const u="maxPagesShown attribute must be greater than 0.";if(t<=0)throw console.error(u),new TypeError(u);return!0}},dir:{type:String,default:"ltr",validator:t=>{const u='dir attribute must be either "ltr" or "rtl".';if(t!=="ltr"&&t!=="rtl")throw console.error(u),new TypeError(u);return!0}},type:{type:String,default:"button",validator:t=>{const u=["link","button"],n="type attribute must be one of the following: "+u.join(", ");if(u.indexOf(t)===-1)throw console.error(n),new TypeError(n);return!0}},onClick:{type:Function,default:()=>{}},locale:{type:String,default:"en",validator:t=>{const u=["en","ar","ir"],n="locale attribute must be one of the following: "+u.join(", ");if(u.indexOf(t)===-1)throw console.error(n),new TypeError(n);return!0}},prevButtonContent:{type:String,default:"<"},nextButtonContent:{type:String,default:">"},hidePrevNext:{type:Boolean,default:!1},hidePrevNextWhenEnds:{type:Boolean,default:!1},showBreakpointButtons:{type:Boolean,default:!0},disableBreakpointButtons:{type:Boolean,default:!1},startingBreakpointContent:{type:String,default:"..."},endingBreakpointButtonContent:{type:String,default:"..."},showJumpButtons:{type:Boolean,default:!1},linkUrl:{type:String,default:"#"},backwardJumpButtonContent:{type:String,default:"<<"},forwardJumpButtonContent:{type:String,default:">>"},disablePagination:{type:Boolean,default:!1},showEndingButtons:{type:Boolean,default:!1},firstPageContent:{type:String,default:"First"},lastPageContent:{type:String,default:"Last"},backButtonClass:{type:String,default:"back-button"},nextButtonClass:{type:String,default:"next-button"},firstButtonClass:{type:String,default:"first-button"},lastButtonClass:{type:String,default:"last-button"},numberButtonsClass:{type:String,default:"number-buttons"},startingBreakpointButtonClass:{type:String,default:"starting-breakpoint-button"},endingBreakPointButtonClass:{type:String,default:"ending-breakpoint-button"},firstPageButtonClass:{type:String,default:"first-page-button"},lastPageButtonClass:{type:String,default:"last-page-button"},paginateButtonsClass:{type:String,default:"paginate-buttons"},disabledPaginateButtonsClass:{type:String,default:"disabled-paginate-buttons"},activePageClass:{type:String,default:"active-page"},paginationContainerClass:{type:String,default:"pagination-container"},disabledBreakPointButtonClass:{type:String,default:"disabled-breakpoint-button"},backwardJumpButtonClass:{type:String,default:"backward-jump-button"},forwardJumpButtonClass:{type:String,default:"forward-jump-button"},disabledBackwardJumpButtonClass:{type:String,default:"disabled-backward-jump-button"},disabledBackButtonClass:{type:String,default:"disabled-back-button"},disabledFirstButtonClass:{type:String,default:"disabled-first-button"},disabledLastButtonClass:{type:String,default:"disabled-last-button"},disabledNextButtonClass:{type:String,default:"disabled-next-button"},disabledForwardJumpButtonClass:{type:String,default:"disabled-forward-jump-button"}},emits:["update:modelValue","click"],setup(t,{emit:u}){const n=t;if(n.currentPage&&!n.modelValue)throw new Error("currentPage/current-page is now deprecated, use v-model instead to set the current page.");if(!n.modelValue)throw new TypeError("v-model is required for the paginate component.");const a=e.toRef(n,"modelValue"),v=u,g=l=>{l!==a.value&&(l>s.value||l<1||n.disablePagination||(v("update:modelValue",l),v("click",l)))},B=l=>{switch(n.locale){case"en":return l;case"ar":return l.toLocaleString("ar-SA");case"ir":return l.toLocaleString("fa-IR");default:return l}},c=l=>n.type!=="link"?"":n.linkUrl.replace("[page]",l.toString()),s=e.computed(()=>Math.ceil(n.totalItems/n.itemsPerPage)),d=e.computed(()=>{let l,o;if(s.value<=n.maxPagesShown)l=1,o=s.value;else{let b=Math.floor(n.maxPagesShown/2),C=Math.ceil(n.maxPagesShown/2)-1;a.value<=b?(l=1,o=n.maxPagesShown):a.value+C>=s.value?(l=s.value-n.maxPagesShown+1,o=s.value):(l=a.value-b,o=a.value+C)}let r=Array.from(Array(o+1-l).keys()).map(b=>l+b);return n.dir==="rtl"&&(r=r.reverse()),{totalItems:n.totalItems,currentPage:a.value,itemsPerPage:n.itemsPerPage,totalPages:s,startPage:l,endPage:o,pages:r}}),i=e.computed(()=>n.dir==="rtl"),h=e.computed(()=>i.value?!n.hidePrevNextWhenEnds||a.value!==s.value:!n.hidePrevNextWhenEnds||a.value!==1),P=e.computed(()=>i.value?!n.hidePrevNextWhenEnds||a.value!==1:!n.hidePrevNextWhenEnds||a.value!==s.value),m=e.computed(()=>i.value?d.value.pages[0]=3),f=e.computed(()=>i.value?d.value.pages[d.value.pages.length-1]>=3:d.value.pages[d.value.pages.length-1]i.value?d.value.pages[0]=2),w=e.computed(()=>i.value?d.value.pages[d.value.pages.length-1]>=2:d.value.pages[d.value.pages.length-1]a.value!==1),x=e.computed(()=>a.value!==s.value);if(n.type==="link"&&n.linkUrl==="#")throw console.error("linkUrl attribute is required if type attribute is 'link'"),new TypeError("linkUrl attribute is required if type attribute is 'link'");if(n.type==="link"&&!n.linkUrl.includes("[page]"))throw console.error("linkUrl attribute must contain '[page]' substring"),new TypeError("linkUrl attribute must contain '[page]' substring");return(l,o)=>(e.openBlock(),e.createElementBlock("ul",{id:"componentContainer",class:e.normalizeClass(t.paginationContainerClass)},[t.showEndingButtons&&S.value?(e.openBlock(),e.createElementBlock("li",N,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?s.value:1),onClick:o[0]||(o[0]=e.withModifiers(r=>g(i.value?s.value:1),["prevent"])),class:e.normalizeClass([t.firstPageButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"first-page-button",{},()=>[e.createTextVNode(e.toDisplayString(t.firstPageContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),t.showJumpButtons&&m.value?(e.openBlock(),e.createElementBlock("li",E,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?a.value+Math.ceil(t.maxPagesShown/2):a.value-Math.ceil(t.maxPagesShown/2)),onClick:o[1]||(o[1]=e.withModifiers(r=>g(i.value?a.value+Math.ceil(t.maxPagesShown/2):a.value-Math.ceil(t.maxPagesShown/2)),["prevent"])),class:e.normalizeClass([t.backwardJumpButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledBackwardJumpButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"backward-jump-button",{},()=>[e.createTextVNode(e.toDisplayString(t.backwardJumpButtonContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),!t.hidePrevNext&&h.value?(e.openBlock(),e.createElementBlock("li",M,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?a.value+1:a.value-1),onClick:o[2]||(o[2]=e.withModifiers(r=>g(i.value?a.value+1:a.value-1),["prevent"])),class:e.normalizeClass([t.backButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledBackButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"prev-button",{},()=>[e.createTextVNode(e.toDisplayString(t.prevButtonContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),t.showBreakpointButtons&&y.value?(e.openBlock(),e.createElementBlock("li",V,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?s.value:1),onClick:o[3]||(o[3]=e.withModifiers(r=>g(i.value?s.value:1),["prevent"])),class:e.normalizeClass([t.firstButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledFirstButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.value?B(s.value):B(1)),1)]),_:1},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),t.showBreakpointButtons&&m.value?(e.openBlock(),e.createElementBlock("li",T,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(t.disableBreakpointButtons?a.value:i.value?a.value+Math.ceil(t.maxPagesShown/2):a.value-Math.ceil(t.maxPagesShown/2)),onClick:o[4]||(o[4]=e.withModifiers(r=>g(t.disableBreakpointButtons?a.value:i.value?a.value+Math.ceil(t.maxPagesShown/2):a.value-Math.ceil(t.maxPagesShown/2)),["prevent"])),disabled:t.disableBreakpointButtons||t.disablePagination,class:e.normalizeClass([t.startingBreakpointButtonClass,t.paginateButtonsClass,t.disableBreakpointButtons||t.disablePagination?`${t.disabledPaginateButtonsClass} ${t.disabledBreakPointButtonClass}`:""])},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"starting-breakpoint-button",{},()=>[e.createTextVNode(e.toDisplayString(t.startingBreakpointContent),1)])]),_:3},8,["href","disabled","class"]))])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value.pages,(r,b)=>(e.openBlock(),e.createElementBlock("li",{key:b},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(r),onClick:e.withModifiers(()=>g(r),["prevent"]),class:e.normalizeClass([t.paginateButtonsClass,t.numberButtonsClass,r===a.value?t.activePageClass:"",t.disablePagination?t.disabledPaginateButtonsClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(B(r)),1)]),_:2},1032,["href","onClick","class","disabled"]))]))),128)),t.showBreakpointButtons&&f.value?(e.openBlock(),e.createElementBlock("li",D,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(t.disableBreakpointButtons?a.value:i.value?a.value-Math.ceil(t.maxPagesShown/2):a.value+Math.ceil(t.maxPagesShown/2)),onClick:o[5]||(o[5]=e.withModifiers(r=>g(t.disableBreakpointButtons?a.value:i.value?a.value-Math.ceil(t.maxPagesShown/2):a.value+Math.ceil(t.maxPagesShown/2)),["prevent"])),disabled:t.disableBreakpointButtons||t.disablePagination,class:e.normalizeClass([t.endingBreakPointButtonClass,t.paginateButtonsClass,t.disableBreakpointButtons||t.disablePagination?`${t.disabledPaginateButtonsClass} ${t.disabledBreakPointButtonClass}`:""])},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"ending-breakpoint-button",{},()=>[e.createTextVNode(e.toDisplayString(t.endingBreakpointButtonContent),1)])]),_:3},8,["href","disabled","class"]))])):e.createCommentVNode("",!0),t.showBreakpointButtons&&w.value?(e.openBlock(),e.createElementBlock("li",$,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?1:s.value),onClick:o[6]||(o[6]=e.withModifiers(r=>g(i.value?1:s.value),["prevent"])),class:e.normalizeClass([t.lastButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledLastButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.value?B(1):B(s.value)),1)]),_:1},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),!t.hidePrevNext&&P.value?(e.openBlock(),e.createElementBlock("li",J,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?a.value-1:a.value+1),onClick:o[7]||(o[7]=e.withModifiers(r=>g(i.value?a.value-1:a.value+1),["prevent"])),class:e.normalizeClass([t.paginateButtonsClass,t.nextButtonClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledNextButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"next-button",{},()=>[e.createTextVNode(e.toDisplayString(t.nextButtonContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),t.showJumpButtons&&f.value?(e.openBlock(),e.createElementBlock("li",I,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?a.value-Math.ceil(t.maxPagesShown/2):a.value+Math.ceil(t.maxPagesShown/2)),onClick:o[8]||(o[8]=e.withModifiers(r=>g(i.value?a.value-Math.ceil(t.maxPagesShown/2):a.value+Math.ceil(t.maxPagesShown/2)),["prevent"])),class:e.normalizeClass([t.forwardJumpButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:"",t.disablePagination?t.disabledForwardJumpButtonClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"forward-jump-button",{},()=>[e.createTextVNode(e.toDisplayString(t.forwardJumpButtonContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0),t.showEndingButtons&&x.value?(e.openBlock(),e.createElementBlock("li",z,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.type==="button"?"button":"a"),{href:c(i.value?1:s.value),onClick:o[9]||(o[9]=e.withModifiers(r=>g(i.value?1:s.value),["prevent"])),class:e.normalizeClass([t.lastPageButtonClass,t.paginateButtonsClass,t.disablePagination?t.disabledPaginateButtonsClass:""]),disabled:t.disablePagination},{default:e.withCtx(()=>[e.renderSlot(l.$slots,"last-page-button",{},()=>[e.createTextVNode(e.toDisplayString(t.lastPageContent),1)])]),_:3},8,["href","class","disabled"]))])):e.createCommentVNode("",!0)],2))}});var j={install:t=>{t.component("VueAwesomePaginate",k)}};exports.VueAwesomePaginate=k;exports.default=j;