/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const RULENAME="oj-tsx-pageopts-type";const DESCRIPTION="Paging Control with numbers is an antipattern in Redwood. Instead the UX recommendation "+"is to use high-water mark scrolling patterns on pages and collections. The JET collections "+"all support high-water mark scrolling natively without the need for a paging control via "+"the scroll-policy attribute. For teams using paging control in Alta we recommend to begin "+"changing the behavior as it will not be supported in Redwood. The only supported use of "+"<oj-paging-control> is to use page-options={type:\"dots\"}.";const SHORT_DESCRIPTION="Paging Control with numbers is an anti pattern in Redwood";const PAGE_OPTIONS="pageOptions";const DOTS="dots";const NUMBERS="numbers";const JSX_SPREAD_ATTRIBUTE="JSXSpreadAttribute";const SCROLL="Use the scroll property 'loadMoreOnScroll' on the collection";class Rule{getName(){return RULENAME}getDescription(){return DESCRIPTION}getShortDescription(){return SHORT_DESCRIPTION}register(regCtx){this._tsxUtils=regCtx.utils.tsxUtils;return{"Tsx<oj-paging-control>":this._onComp}}_onComp(ruleCtx,tsxComp){let tsxProps,tsxProp,found,i;tsxProps=tsxComp.properties;for(i=0;i<tsxProps.length;i++){tsxProp=tsxProps[i];if(tsxProp.node.type===JSX_SPREAD_ATTRIBUTE){continue}if(tsxProp.name.startsWith(PAGE_OPTIONS)){found=true;let obj=this._tsxUtils.getExpressionObject(tsxProp);if(obj&&obj.type){if(obj.type===DOTS){return}else if(obj.type!==NUMBERS){this._emit(ruleCtx,1,obj.type,tsxProp)}else if(obj.type===NUMBERS){this._emit(ruleCtx,2,null,tsxProp)}}else{this._emit(ruleCtx,3,null,tsxProp)}}}if(!found){this._emit(ruleCtx,4)}}_emit(ruleCtx,id,extra,tsxProp){var msg;switch(id){case 1:msg=`'page-options' - 'type' sub-property '${extra}' is invalid`;break;case 2:msg="'page-options' - 'type' sub-property 'numbers' is deprecated and an anti-pattern in Redwood theme";break;case 3:msg="'page-options' - 'type' sub-property omitted and default value 'numbers' is deprecated and an anti-pattern in Redwood theme";break;case 4:msg="'page-options' omitted and default sub-property type' value 'numbers' is deprecated and an anti-pattern in Redwood theme";break}let issue=new ruleCtx.Issue(`<oj-paging-control>: ${msg}. ${SCROLL}.`);if(id<4){this._tsxUtils.setIssuePropValuePosition(issue,tsxProp);issue.setMsgKey(RULENAME+(id-1?"_"+(id-1):""))}ruleCtx.reporter.addIssue(issue,ruleCtx)}}module.exports=Rule;