import{ArgumentError as e}from"../../ArgumentError.js";import{isBuildingComponentSublayer as r,isBuildingGroupSublayer as t,isKMLSublayer as n,isMapImageSublayer as i,isMapNotesSublayer as s,isSubtypeSublayer as o,isTileLayer as u,isWMSSublayer as a}from"../../utilities/_layers.js";import{checkArg as l}from"../../utilities/checkArg.js";import{BuildingComponentSublayerExtension as y}from"../BuildingComponentSublayerExtension.js";import{BuildingGroupSublayerExtension as p}from"../BuildingGroupSublayerExtension.js";import{KMLSublayerExtension as b}from"../KMLSublayerExtension.js";import{MapImageSublayerExtension as c}from"../MapImageSublayerExtension.js";import{MapNotesSublayerExtension as m}from"../MapNotesSublayerExtension.js";import{SubtypeSublayerExtension as S}from"../SubtypeSublayerExtension.js";import{TileSublayerExtension as f}from"../TileSublayerExtension.js";import{WMSSublayerExtension as w}from"../WMSSublayerExtension.js";export class DefaultSublayerExtensionFactory{static instance=new DefaultSublayerExtensionFactory;constructor(){}create(x,j){l("properties",x).isNotMissing(),l("properties.sublayer",x.sublayer??j).isNotMissing();const E=x.sublayer,M=x.sublayer?.$sublayerType??j;if(i(E))return u(E.layer)?new f(x):new c(x);if(s(E))return new m(x);if(n(E))return new b(x);if(a(E))return new w(x);if(r(E))return new y(x);if(t(E))return new p(x);if(o(E))return new S(x);if(M)switch(M){case"ArcGISMapServiceSublayer":return new c(x);case"ArcGISTiledSublayer":return new f(x);case"WMSSublayer":return new w(x);case"KMLSublayer":return new b(x);case"BuildingComponentSublayer":return new y(x);case"BuildingGroupSublayer":return new p(x);case"SubtypeSublayer":return new S(x);case"MapNotesSublayer":return new m(x);case"WMTSSublayer":return{}}throw new e("properties.sublayer","Unable to determine correct type of sublayer extension to create.")}}