1import{PageElementBase as a}from"./CdQXFjpm.js";import{TypographyModel as o}from"./C8oKskU6.js";import{G as r}from"./D_6K3OQ2.js";import{z as m,k as d}from"./DeRq26-U.js";import{t as c}from"./CATxlt2j.js";import"./CXTOca8g.js";import"./0xmjySIm.js";import"./WUj_y4n6.js";class l extends a{constructor(e="root",t){super(e,t),this.widgetType="WidgetForm",this.widgetName="Forms",this.component="WidgetForm",this.icon={icon:"form",pack:"cms"},this.pseudoWidgetType="widget",this.title=new o({tag:"h3",font:"primary"}),this.content={formId:""},this.style=new r({theme:"unset"}),this.buildContentFields=()=>[{heading:"Title",toggleable:!0,toggleAttributeKey:["title","show"],options:[{type:"input",attributeKey:["title","content"],placeholder:"Enter Title"}]},{heading:"Select a form",options:[{type:"select",attributeKey:["content","formId"],items:this.fetchFormIds()},{type:"external-selector",attributeKey:["externalLink"],buttonType:"quarternary",label:"Go to forms",link:{type:"internal",value:"forms"},callback:()=>{const i=d();window.location.href=`https://cms.gc.${i.public.servicesURL}/forms`}}]}],this.buildStyleFields=()=>[{heading:"Theme",options:[{type:"radio",subType:"list",attributeKey:["style","theme"],options:[{label:"Light",id:"light"},{label:"Dark",id:"dark"},{label:"Accent",id:"club"}]}]},{heading:"Background",options:[{type:"color-selector",attributeKey:["style","backgroundColor"]}]}],this.getSidebarTabs=()=>[{name:"Content",fields:this.buildContentFields(),default:!0},{name:"Style",fields:this.buildStyleFields()}],t!=null&&t.widgetType&&!("version"in t)?Object.assign(this,this.normalizeLegacyElement(t)):Object.assign(this,c(t))}serializeElement(){return{...super.serializeBaseElement(),title:this.title,content:this.content,position:this.position,style:this.style}}async fetchFormIds(){const{$gc:e}=m(),{idToken:t}=handleCurrentAuth();return((await e().forms.cms(t).getForms()).body||[]).map(i=>({id:i.formID,name:i.name_admin}))}duplicateElement(){return new l(this.parentID,{...this,uuid:void 0})}normalizeLegacyElement(e){var n,s;const t="contents"in e?e.contents:e.content,i=t&&"form"in t?(n=t.form)==null?void 0:n.id:t==null?void 0:t.formId;return{uuid:e.uuid,title:new o({tag:"h3",font:"primary",content:(t==null?void 0:t.formTitle)||""}),content:{formId:i||"",formTitle:t==null?void 0:t.formTitle,formDescription:t==null?void 0:t.formDescription},style:new r({theme:((s=e.style)==null?void 0:s.theme)||"unset"})}}}export{l as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.