@explorer02/cfm-survey-sdk 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var ft=Object.create;var Je=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var q=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ne=(e,o)=>{for(var t in o)Je(e,t,{get:o[t],enumerable:!0})},yt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of mt(o))!pt.call(e,r)&&r!==t&&Je(e,r,{get:()=>o[r],enumerable:!(n=ut(o,r))||n.enumerable});return e};var k=(e,o,t)=>(t=e!=null?ft(gt(e)):{},yt(o||!e||!e.__esModule?Je(t,"default",{value:e,enumerable:!0}):t,e));var a,W=q(()=>{"use strict";a={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"}});var G,Te=q(()=>{"use strict";G=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function bt(e){let o={};for(let t of e)wo[t]&&(o[t]={...wo[t]});return o}function St(e=[],o){return{version:"1.0",instanceId:o,surveyTypes:e,global:{surveyTitle:"Customer Feedback Survey",companyName:"Sprinklr",browserTabTitle:"Customer Feedback Survey",thankYouMessage:"Thank you for your valuable feedback!",logo:{fileName:null,url:null},header:{height:120,logoBoxWidth:120,logoBoxHeight:120,logoPadding:10,logoPlacement:"left",showCompanyName:!0,companyNamePlacement:"left",companyNameFontSize:18,companyNameFontWeight:600,companyNameColor:"#1A1F36",backgroundColor:"#FFFFFF",shadowEnabled:!0,borderBottomColor:"#E5E7EB",contentPaddingX:40},footer:{backgroundColor:"#262626",textColor:"#9CA3AF",linkColor:"#9CA3AF",linkHoverColor:"#FFFFFF",showLogo:!0,logoWidth:120,logoHeight:32,logoPlacement:"left",copyrightText:"\xA9 Company Name",layout:"row",paddingY:24,paddingX:40,links:[]},theme:{pageBackground:"#FFFFFF",cardBackground:"#FFFFFF",cardBorderColor:"#E5E7EB",cardPadding:24,cardShadowEnabled:!0,selectedBackground:"#E8F5FD",zebraRowColor:"rgba(249,250,251,0.8)",rowBandColor:"#F3F4F6",validationBorder:"#333333",validationBackground:"#D9D9D9",tooltipBackground:"#1F2937",progressTrackHeight:12,progressTrackColor:"#E5E7EB",progressFillColor:"#1A1F36",stickyChromePaddingTop:16,stickyChromePaddingBottom:20,languageSelectorBackground:"#FFFFFF",languageSelectorTextColor:"#2563EB",languageSelectorBorderColor:"#2563EB"},layout:{showHeader:!0,showFooter:!0,showProgressBar:!0,showLanguageSwitcher:!1,showNextButton:!0,showBackButton:!0,showQuestionNumbers:!0,showRequiredAsterisk:!0,width:"standard",borderStyle:"rounded",fontStyle:"modern"},buttons:{next:"Next",back:"Back",submit:"Submit"},colorScheme:{...O},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:bt(e),placeholders:{firstName:"Alex",lastName:"Customer",email:"alex@example.com"},customFields:{},debug:{enabled:!1,sampleAnswers:{}},deploy:{target:"aws",autoDeploy:!1}}}function ee(e,o){return{...e,...o??{}}}function _e(e){let o=(e.surveyTypes??[]).filter(c=>G.includes(c)),t=[...new Set([...o,...G])],n=St(t,e.instanceId),r=e.global??{},i=n.global,s={...n.questionTypes};if(e.questionTypes)for(let[c,d]of Object.entries(e.questionTypes))s[c]={...s[c]??{},...d};return{...n,...e,configuredAt:void 0,surveyTypes:o.length?o:n.surveyTypes,global:{...i,...r,header:ee(i.header,r.header),footer:ee(i.footer,r.footer),theme:ee(i.theme,r.theme),layout:ee(i.layout,r.layout),buttons:ee(i.buttons,r.buttons),logo:ee(i.logo,r.logo),colorScheme:ee(i.colorScheme,r.colorScheme),typography:ee(i.typography,r.typography),motion:ee(i.motion,r.motion)},questionTypes:s,placeholders:{...n.placeholders,...e.placeholders??{}},customFields:{...n.customFields,...e.customFields??{}},debug:{enabled:e.debug?.enabled??n.debug?.enabled??!1,sampleAnswers:e.debug?.sampleAnswers??n.debug?.sampleAnswers},deploy:{...n.deploy,...e.deploy??{}}}}var O,wo,Ge=q(()=>{"use strict";Te();O={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},wo={MCQ:{cardStyle:"outlined",selectedAccent:O.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:O.secondary,hoverBorderColor:O.accent},TEXTFIELD:{inputRadius:8,focusRing:O.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:O.secondary,labelColor:O.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:O.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:O.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:O.primary,cellPadding:8,accentColor:O.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:O.accent,cellSize:40,tooltipBg:"#1F2937"},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:O.primary,rowLabelWidth:180,unselectedStarOpacity:.5},SLIDER_MATRIX:{trackColor:O.accent,thumbColor:O.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:O.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:O.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",dragHandleColor:"#9CA3AF",rankBadgeColor:O.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:O.primary,itemPadding:12,itemGap:8}}}});function xo(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let r=n[0].split(":")[0].trim(),i=n[1].trim();o[r]=i}return o}function A(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function To(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function xe(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function $o(e){let o={global:{},questionTypes:{}},t=o.global,n={},r={},i={},s={},c={},d={},g={},w=o.questionTypes;if(e["--cfm-primary"]&&(n.primary=e["--cfm-primary"]),e["--cfm-secondary"]&&(n.secondary=e["--cfm-secondary"]),e["--cfm-accent"]&&(n.accent=e["--cfm-accent"]),e["--cfm-background"]&&(n.background=e["--cfm-background"]),e["--cfm-text"]&&(n.text=e["--cfm-text"]),e["--cfm-button-text"]&&(n.buttonText=e["--cfm-button-text"]),e["--cfm-max-width"]&&bo[e["--cfm-max-width"]]&&(c.width=bo[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&So[e["--cfm-border-radius"]]&&(c.borderStyle=So[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],Co[e["--cfm-font-family"]]&&(c.fontStyle=Co[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=xe(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let B=A(e["--cfm-motion-duration"]);B!==void 0&&(g.durationMs=B,g.enabled=B>0)}e["--cfm-header-height"]&&(r.height=A(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(r.logoBoxWidth=A(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(r.logoBoxHeight=A(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(r.logoPadding=A(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(r.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(r.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(r.companyNameFontSize=A(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(r.companyNameFontWeight=xe(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(r.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(r.contentPaddingX=A(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(i.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(i.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(i.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(i.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(i.logoWidth=A(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(i.logoHeight=A(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(i.paddingY=A(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(i.paddingX=A(e["--cfm-footer-padding-x"])),e["--cfm-background"]&&(s.pageBackground=e["--cfm-background"]),e["--cfm-card-bg"]&&(s.cardBackground=e["--cfm-card-bg"]),e["--cfm-card-border-color"]&&(s.cardBorderColor=e["--cfm-card-border-color"]),e["--cfm-card-padding"]&&(s.cardPadding=A(e["--cfm-card-padding"])),e["--cfm-card-shadow"]&&(s.cardShadowEnabled=e["--cfm-card-shadow"]!=="none"),e["--cfm-selected-bg"]&&(s.selectedBackground=e["--cfm-selected-bg"]),e["--cfm-zebra-row"]&&(s.zebraRowColor=e["--cfm-zebra-row"]),e["--cfm-row-band"]&&(s.rowBandColor=e["--cfm-row-band"]),e["--cfm-validation-border"]&&(s.validationBorder=e["--cfm-validation-border"]),e["--cfm-validation-bg"]&&(s.validationBackground=e["--cfm-validation-bg"]),e["--cfm-tooltip-bg"]&&(s.tooltipBackground=e["--cfm-tooltip-bg"]),e["--cfm-progress-height"]&&(s.progressTrackHeight=A(e["--cfm-progress-height"])),e["--cfm-progress-track"]&&(s.progressTrackColor=e["--cfm-progress-track"]),e["--cfm-progress-fill"]&&(s.progressFillColor=e["--cfm-progress-fill"]),e["--cfm-sticky-pt"]&&(s.stickyChromePaddingTop=A(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=A(e["--cfm-sticky-pb"]));let S={};e["--cfm-mcq-selected-accent"]&&(S.selectedAccent=e["--cfm-mcq-selected-accent"]),e["--cfm-mcq-border-radius"]&&(S.borderRadius=A(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(S.optionGap=A(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(S.cardPadding=A(e["--cfm-mcq-card-padding"])),e["--cfm-mcq-selected-bg"]&&(S.selectedBackground=e["--cfm-mcq-selected-bg"]),e["--cfm-mcq-hover-border"]&&(S.hoverBorderColor=e["--cfm-mcq-hover-border"]),Object.keys(S).length&&(w.MCQ=S);let x={};e["--cfm-input-radius"]&&(x.inputRadius=A(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(x.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(x.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(x.inputPadding=A(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=A(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(w.TEXTFIELD=x);let F={};e["--cfm-nps-selected-fill"]&&(F.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(F.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(F.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(F.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(F.cellSize=A(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(F.cellGap=A(e["--cfm-nps-cell-gap"])),Object.keys(F).length&&(w.NPS_SCALE=F);let E=A(e["--cfm-matrix-row-width"]),R={};E!==void 0&&(R.rowLabelWidth=E),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=To(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&(R.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&(R.cellPadding=A(e["--cfm-matrix-cell-padding"])),Object.keys(R).length&&(w.CFM_MATRIX=R);let f={...R};e["--cfm-csat-accent"]&&(f.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(f.emojiSize=A(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(f.unselectedOpacity=xe(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(f.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(f.cellSize=A(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(f.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(f).length>Object.keys(R).length||e["--cfm-csat-accent"])&&(w.CSAT_MATRIX=f);let y={};e["--cfm-star-color"]&&(y.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(y.badgeColor=e["--cfm-badge-color"]),E!==void 0&&(y.rowLabelWidth=E),e["--cfm-star-unselected-opacity"]&&(y.unselectedStarOpacity=xe(e["--cfm-star-unselected-opacity"])),Object.keys(y).length&&(w.RATING_MATRIX=y);let T={};e["--cfm-slider-track"]&&(T.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(T.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(T.tickColor=e["--cfm-slider-tick"]),E!==void 0&&(T.rowLabelWidth=E),e["--cfm-slider-row-band"]&&(T.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(T.tickBadgeSize=A(e["--cfm-slider-tick-size"])),Object.keys(T).length&&(w.SLIDER_MATRIX=T);let $={};e["--cfm-upload-accent"]&&($.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&($.dropzonePadding=A(e["--cfm-upload-padding"])),Object.keys($).length&&(w.FILE_UPLOAD=$);let h={};e["--cfm-media-max-width"]&&(h.mediaMaxWidth=To(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(h.mediaRadius=A(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(h.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(h.captionSize=A(e["--cfm-media-caption-size"])),Object.keys(h).length&&(w.TEXT_AND_MEDIA=h);let P={};e["--cfm-heatmap-pin"]&&(P.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(P.pinSize=A(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(P.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(P.overlayOpacity=xe(e["--cfm-heatmap-overlay-opacity"])),Object.keys(P).length&&(w.HEATMAP=P);let C={};return e["--cfm-rank-item-bg"]&&(C.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(C.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(C.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(C.itemPadding=A(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(C.itemGap=A(e["--cfm-rank-item-gap"])),Object.keys(C).length&&(w.RANK_ORDER=C),Object.keys(n).length&&(t.colorScheme=n),Object.keys(r).length&&(t.header=r),Object.keys(i).length&&(t.footer=i),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(g).length&&(t.motion=g),o}function ue(e){let o=[$e.join(e,"src","styles","survey-theme.css"),$e.join(e,"src","app","survey-theme.css"),$e.join(e,"src","styles","globals.css"),$e.join(e,"src","app","globals.css")];for(let t of o)if(De.existsSync(t)&&De.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var De,$e,bo,So,Co,Le=q(()=>{"use strict";De=k(require("fs")),$e=k(require("path")),bo={"36rem":"narrow","48rem":"standard","64rem":"wide"},So={"0px":"sharp","12px":"rounded","9999px":"pill"},Co={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});function Tt(e){for(let o of Ct){let t=Ro.join(e,o);if(Me.existsSync(t))return t}return null}function xt(e){let o=e.trim();if(!o||o.startsWith("http")||o.startsWith("data:"))return null;let t=o.split("?")[0];return t.startsWith("/")?t.slice(1):t}function ko(e){let o=Tt(e);if(!o)return null;let t=Me.readFileSync(o,"utf8"),n=t.match(/data-cfm-logo[\s\S]*?src=["']([^"']+)["']/i)??t.match(/src=["']([^"']+)["'][\s\S]*?data-cfm-logo/i);if(n){let s=xt(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let r=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(r)return{mode:"text",label:r[1].trim()};let i=t.match(/data-cfm-company[^>]*>([^<]+)</i);return i&&!n?{mode:"text",label:i[1].trim()}:null}var Me,Ro,Ct,Ao=q(()=>{"use strict";Me=k(require("fs")),Ro=k(require("path")),Ct=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var No={};Ne(No,{logSeedSource:()=>Ke,resolveInitialConfig:()=>ge,writeResolvedUiConfig:()=>Ye});function Qe(e){return e.filter(o=>G.includes(o))}function Eo(e){try{let o=JSON.parse(Q.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function kt(e){let o={global:{}};if(!Q.existsSync(e))return o;let t=Q.readFileSync(e,"utf8"),n=new Set;for(let i of G)t.includes(i)&&n.add(i);n.size&&(o.surveyTypes=[...n]);let r=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(r){let i=r[1].trim(),s=i.match(/company[:\s]+([^,;]+)/i),c=i.match(/title[:\s]+([^,;]+)/i);if(s&&(o.global.companyName=s[1].trim()),c){let d=c[1].trim();o.global.surveyTitle=d,o.global.browserTabTitle=d}}return o}function Io(e,o){let t=oe.join(e,o);if(!Q.existsSync(t))return null;let n=Q.readFileSync(t);if(n.length>$t)return{fileName:o,dataUrl:""};let r=oe.extname(o).toLowerCase(),i=Rt[r]??"application/octet-stream";return{fileName:o,dataUrl:`data:${i};base64,${n.toString("base64")}`}}function Fo(e,o){if(!o)return null;if(o.url&&typeof o.url=="string")return{fileName:o.fileName??null,url:o.url};if(o.fileName){let t=Io(e,o.fileName);if(t)return{fileName:t.fileName,url:t.dataUrl||null}}return o.fileName===null&&o.url===null?{fileName:null,url:null}:null}function Po(e,o){let t=e.global??{},n=o.global??{},r=e.questionTypes??{},i=o.questionTypes??{},s={...r};for(let[c,d]of Object.entries(i))s[c]={...s[c]??{},...d};return{...e,...o,surveyTypes:o.surveyTypes??e.surveyTypes,global:{...t,...n,header:{...t.header,...n.header},footer:{...t.footer,...n.footer},theme:{...t.theme,...n.theme},layout:{...t.layout,...n.layout},buttons:{...t.buttons,...n.buttons},logo:{...t.logo,...n.logo},colorScheme:{...t.colorScheme,...n.colorScheme},typography:{...t.typography,...n.typography},motion:{...t.motion,...n.motion}},questionTypes:s,placeholders:{...e.placeholders,...o.placeholders},customFields:{...e.customFields,...o.customFields},deploy:{...e.deploy,...o.deploy}}}function ge(e){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=oe.join(o,"survey-ui-config.json"),n=oe.join(o,"implementation_plan.md"),r=oe.join(o,"public"),i=Qe(e.surveyTypes),s={},c="defaults",d=ue(o);if(d){let C=Q.readFileSync(d,"utf8"),B=xo(C);Object.keys(B).length>0&&(s=$o(B),c="survey-theme.css")}let g=kt(n);s=Po(s,g);let w=Eo(t);w&&(s=Po(s,w),c="survey-ui-config.json");let S=oe.join(o,"survey-ui-config.final.json"),x=Eo(S),F=!!w?.configuredAt,E=!!x?.configuredAt;if(x&&E&&!F){let C=Fo(r,x.global?.logo);C&&(s.global={...s.global??{},logo:{fileName:C.fileName,url:C.url}})}let R=Fo(r,s.global?.logo),f=ko(o),y=!!w?.configuredAt,T=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),$=f?.mode==="image"?f.fileName:null,h=!y&&T&&$!=null&&R?.fileName!==$;if(R&&!h)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(f?.mode==="image"){let C=Io(r,f.fileName);s.global={...s.global??{},logo:{fileName:f.fileName,url:C?.dataUrl||null}}}else f?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??f.label});return s.surveyTypes=Qe(s.surveyTypes??i),s.surveyTypes?.length||(s.surveyTypes=i),e.instanceId&&(s.instanceId=e.instanceId),{config:_e(s),source:c}}function Ke(e){console.log(e==="survey-ui-config.json"?`${me.dim} Seeding wizard from survey-ui-config.json${me.reset}`:e==="survey-theme.css"?`${me.dim} Seeding wizard from survey-theme.css + defaults${me.reset}`:`${me.dim} Seeding wizard from SDK defaults${me.reset}`)}function Ye(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??Qe(G),{config:n}=ge({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),r=oe.join(o,"survey-ui-config.json");return Q.writeFileSync(r,JSON.stringify(n,null,2),"utf8"),r}var Q,oe,me,$t,Rt,Re=q(()=>{"use strict";Q=k(require("fs")),oe=k(require("path"));W();Ge();Le();Te();Ao();me=a,$t=512e3,Rt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function b(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function l(e,o){return typeof e=="string"&&e.length?e:o}function no(e){return e==="left"?"1":e==="center"?"2":"3"}function Be(e){return e==="left"?"start":e==="center"?"center":"end"}function Mt(e){let o=l(e.logoPlacement,"left"),t=l(e.companyNamePlacement,"left"),n={"--cfm-header-brand-gap":"16px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0"};return o==="left"&&t==="left"?{...n,"--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start","--cfm-header-company-col":"1","--cfm-header-company-justify":"start","--cfm-header-company-margin-left":"calc(var(--cfm-header-logo-width) + var(--cfm-header-brand-gap))"}:o==="right"&&t==="right"?{...n,"--cfm-header-logo-col":"3","--cfm-header-logo-justify":"end","--cfm-header-company-col":"3","--cfm-header-company-justify":"end","--cfm-header-company-margin-right":"calc(var(--cfm-header-logo-width) + var(--cfm-header-brand-gap))"}:{...n,"--cfm-header-logo-col":no(o),"--cfm-header-logo-justify":Be(o),"--cfm-header-company-col":no(t),"--cfm-header-company-justify":Be(t)}}function Ot(e){let o=l(e.logoPlacement,"left"),t=l(e.layout,"row"),n=o==="right"?"1":"3",r=o==="right"?"start":"end";return t==="stack"?{"--cfm-footer-inner-display":"flex","--cfm-footer-inner-direction":"column","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":Be(o),"--cfm-footer-links-col":"1","--cfm-footer-links-justify":"start"}:{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":no(o),"--cfm-footer-logo-justify":Be(o),"--cfm-footer-links-col":n,"--cfm-footer-links-justify":r}}function Ue(e,o){o.numberLabelMode&&(e["--cfm-number-label-mode"]=l(o.numberLabelMode,"traffic")),o.monochromeNumberColor&&(e["--cfm-number-mono-color"]=l(o.monochromeNumberColor,"#9CA3AF"));let t=o.individualNumberColors;Array.isArray(t)&&t.forEach((n,r)=>{typeof n=="string"&&(e[`--cfm-number-color-${r}`]=n)})}function Bt(e,o){o.hintLabelColor&&(e["--cfm-hint-label-color"]=l(o.hintLabelColor,"#6B7280")),o.hintLabelBgColor&&(e["--cfm-hint-label-bg"]=l(o.hintLabelBgColor,"transparent"))}function ze(e,o,t){(t==="matrix"||t==="csat")&&(o.columnLabelColor&&(e["--cfm-matrix-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-matrix-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="csat"&&(o.columnLabelColor&&(e["--cfm-csat-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-csat-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="slider"&&(o.columnLabelColor&&(e["--cfm-slider-tick-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-slider-tick-label-bg"]=l(o.columnLabelBgColor,"transparent")))}function Ut(e,o){let t=l(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${b(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${b(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${b(o.optionPadding??o.cardPadding,12)}px`,e["--cfm-mcq-hover-border"]=l(o.hoverBorderColor,"#00B5AD"),e["--cfm-mcq-option-style"]=t}function zt(e,o){e["--cfm-input-radius"]=`${b(o.inputRadius,8)}px`,e["--cfm-input-border"]=l(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${b(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${b(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=l(o.placeholderColor,"#9CA3AF")}function qt(e,o){e["--cfm-nps-cell-size"]=`${b(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${b(o.cellGap,4)}px`,e["--cfm-nps-button-style"]=l(o.buttonStyle,"standard"),e["--cfm-nps-selected-fill"]=l(o.selectedFill,"#E8F5FD"),e["--cfm-nps-track-bar"]=l(o.trackBarColor,"#F2F2F2"),e["--cfm-nps-track-highlight"]=l(o.trackHighlightColor,"#FBE8F3"),Bt(e,o),Ue(e,o)}function Wt(e,o){e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${b(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${b(o.cellPadding,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=l(o.carouselDotColor,"#2563EB")),ze(e,o,"matrix")}function Xt(e,o){e["--cfm-csat-emoji-size"]=`${b(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(b(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(b(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${b(o.cellSize,40)}px`,e["--cfm-csat-tooltip-bg"]=l(o.tooltipBg,"#1F2937"),e["--cfm-csat-accent"]=l(o.accentColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,ze(e,o,"csat"),Ue(e,o)}function Ht(e,o){e["--cfm-star-color"]=l(o.starColor,"#F59E0B"),e["--cfm-badge-color"]=l(o.badgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-csat-emoji-size"]=`${b(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(b(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(b(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,ze(e,o,"csat"),Ue(e,o)}function Vt(e,o){e["--cfm-slider-track"]=l(o.trackColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-slider-thumb"]=l(o.thumbColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-slider-tick"]=l(o.tickColor,"#9CA3AF"),e["--cfm-matrix-row-width"]=`${b(o.rowLabelWidth,180)}px`,e["--cfm-slider-row-band"]=l(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${b(o.tickBadgeSize,28)}px`,ze(e,o,"slider"),Ue(e,o)}function Jt(e,o){e["--cfm-upload-border-color"]=l(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${b(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=l(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=l(o.dropzoneStyle,"dashed")}function Gt(e,o){e["--cfm-media-max-width"]=`${b(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${b(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=l(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${b(o.captionSize,14)}px`}function Qt(e,o){e["--cfm-heatmap-pin"]=l(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${b(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=l(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(b(o.overlayOpacity,0))}function Kt(e,o){let t=X(o.drag)??o,n=X(o.dropdown)??t;e["--cfm-rank-item-bg"]=l(t.itemBg,"#F9FAFB"),e["--cfm-rank-badge-bg"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-badge-text"]="#ffffff",e["--cfm-rank-badge"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-item-padding"]=`${b(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${b(t.itemGap,8)}px`,e["--cfm-rank-handle"]=l(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=l(n.selectBorderColor,"#E5E7EB")}function qe(e){let o=X(e.global)??{},t=X(o.colorScheme)??{},n=X(o.header)??{},r=X(o.footer)??{},i=X(o.theme)??{},s=X(o.layout)??{},c=X(o.typography)??{},d=X(o.motion)??{},g=e.questionTypes??{},w=l(s.fontStyle,"modern"),S=Bo[w]??l(c.fontFamily,Bo.modern),x=l(s.width,"standard"),F=l(s.borderStyle,"rounded"),E=l(i.cellSelectedColor,l(t.accent,"#00B5AD")),R=l(i.focusRingColor,l(t.accent,"#00B5AD")),f=l(i.selectedBackground,l(t.secondary,"#E8F5FD")),y={"--cfm-primary":l(t.primary,"#1A1F36"),"--cfm-secondary":l(t.secondary,"#E8F5FD"),"--cfm-accent":l(t.accent,"#00B5AD"),"--cfm-background":l(i.pageBackground??t.background,"#FFFFFF"),"--cfm-text":l(t.text,"#1A1F36"),"--cfm-button-text":l(t.buttonText,"#FFFFFF"),"--cfm-max-width":Mo[x]??Mo.standard,"--cfm-border-radius":Oo[F]??Oo.rounded,"--cfm-font-family":S,"--cfm-heading-weight":String(b(c.headingWeight,700)),"--cfm-motion-duration":`${b(d.durationMs,200)}ms`,"--cfm-header-height":`${b(n.height,120)}px`,"--cfm-header-logo-width":`${b(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${b(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${b(n.logoPadding,10)}px`,"--cfm-header-show-company":n.showCompanyName===!1?"0":"1","--cfm-header-bg":l(n.backgroundColor,"#FFFFFF"),"--cfm-header-company-color":l(n.companyNameColor,l(t.text,"#1A1F36")),"--cfm-header-company-size":`${b(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(b(n.companyNameFontWeight,600)),"--cfm-header-border":l(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${b(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",...Mt(n),"--cfm-footer-bg":l(r.backgroundColor,"#262626"),"--cfm-footer-text":l(r.textColor,"#9CA3AF"),"--cfm-footer-link":l(r.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":l(r.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${b(r.logoWidth,120)}px`,"--cfm-footer-logo-height":`${b(r.logoHeight,32)}px`,"--cfm-footer-padding-y":`${b(r.paddingY,24)}px`,"--cfm-footer-padding-x":`${b(r.paddingX,40)}px`,...Ot(r),"--cfm-card-bg":l(i.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(i.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${b(i.cardPadding,24)}px`,"--cfm-card-shadow":i.cardShadowEnabled===!1?"none":"0 1px 3px rgba(0,0,0,0.1)","--cfm-selected-bg":f,"--cfm-mcq-selected-accent":R,"--cfm-mcq-selected-bg":f,"--cfm-matrix-selected":E,"--cfm-csat-ring-color":E,"--cfm-input-focus-ring":R,"--cfm-zebra-row":l(i.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":l(i.rowBandColor,"#F3F4F6"),"--cfm-validation-border":l(i.validationBorder,"#333333"),"--cfm-validation-bg":l(i.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":l(i.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${b(i.progressTrackHeight,12)}px`,"--cfm-progress-track":l(i.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(i.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${b(i.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${b(i.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":l(i.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":l(i.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":l(i.languageSelectorBorderColor,"#2563EB")},T=[["MCQ",Ut],["TEXTFIELD",zt],["NPS_SCALE",qt],["CFM_MATRIX",Wt],["CSAT_MATRIX",Xt],["RATING_MATRIX",Ht],["SLIDER_MATRIX",Vt],["FILE_UPLOAD",Jt],["TEXT_AND_MEDIA",Gt],["HEATMAP",Qt],["RANK_ORDER",Kt]];for(let[$,h]of T){let P=X(g[$]);P&&h(y,P)}return y}function ro(e){let o=e.questionTypes??{},t=X(o.MCQ),n=X(o.NPS_SCALE),r=X(o.FILE_UPLOAD),i={};return i["data-cfm-mcq-style"]=l(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(i["data-cfm-nps-button-style"]=l(n.buttonStyle,"standard")),r?.dropzoneStyle&&(i["data-cfm-dropzone-style"]=l(r.dropzoneStyle,"dashed")),i}var Mo,Oo,Bo,io=q(()=>{"use strict";Mo={narrow:"36rem",standard:"48rem",wide:"64rem"},Oo={sharp:"0px",rounded:"12px",pill:"9999px"},Bo={system:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',inter:"Inter, system-ui, sans-serif",modern:"Inter, sans-serif",roboto:"Roboto, system-ui, sans-serif",openSans:'"Open Sans", system-ui, sans-serif',lato:"Lato, system-ui, sans-serif",poppins:"Poppins, system-ui, sans-serif",montserrat:"Montserrat, system-ui, sans-serif",nunito:"Nunito, system-ui, sans-serif",raleway:"Raleway, system-ui, sans-serif",sourceSans:'"Source Sans 3", system-ui, sans-serif',georgia:'Georgia, "Times New Roman", serif',serif:"Georgia, serif",merriweather:"Merriweather, Georgia, serif",playfair:'"Playfair Display", Georgia, serif'}});function Yt(e){return`:root {
2
+ "use strict";var ft=Object.create;var Je=Object.defineProperty;var ut=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var mt=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var q=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ne=(e,o)=>{for(var t in o)Je(e,t,{get:o[t],enumerable:!0})},yt=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of gt(o))!pt.call(e,r)&&r!==t&&Je(e,r,{get:()=>o[r],enumerable:!(n=ut(o,r))||n.enumerable});return e};var k=(e,o,t)=>(t=e!=null?ft(mt(e)):{},yt(o||!e||!e.__esModule?Je(t,"default",{value:e,enumerable:!0}):t,e));var a,W=q(()=>{"use strict";a={reset:"\x1B[0m",bold:"\x1B[1m",green:"\x1B[32m",red:"\x1B[31m",cyan:"\x1B[36m",yellow:"\x1B[33m",dim:"\x1B[2m"}});var Q,Te=q(()=>{"use strict";Q=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function bt(e){let o={};for(let t of e)wo[t]&&(o[t]={...wo[t]});return o}function St(e=[],o){return{version:"1.0",instanceId:o,surveyTypes:e,global:{surveyTitle:"Customer Feedback Survey",companyName:"Sprinklr",browserTabTitle:"Customer Feedback Survey",thankYouMessage:"Thank you for your valuable feedback!",logo:{fileName:null,url:null},header:{height:120,logoBoxWidth:120,logoBoxHeight:120,logoPadding:10,logoPlacement:"left",showCompanyName:!0,companyNamePlacement:"left",companyNameFontSize:18,companyNameFontWeight:600,companyNameColor:"#1A1F36",backgroundColor:"#FFFFFF",shadowEnabled:!0,borderBottomColor:"#E5E7EB",contentPaddingX:40},footer:{backgroundColor:"#262626",textColor:"#9CA3AF",linkColor:"#9CA3AF",linkHoverColor:"#FFFFFF",showLogo:!0,logoWidth:120,logoHeight:32,logoPlacement:"left",copyrightText:"\xA9 Company Name",layout:"row",paddingY:24,paddingX:40,links:[]},theme:{pageBackground:"#FFFFFF",cardBackground:"#FFFFFF",cardBorderColor:"#E5E7EB",cardPadding:24,cardShadowEnabled:!0,selectedBackground:"#E8F5FD",zebraRowColor:"rgba(249,250,251,0.8)",rowBandColor:"#F3F4F6",validationBorder:"#333333",validationBackground:"#D9D9D9",tooltipBackground:"#1F2937",progressTrackHeight:12,progressTrackColor:"#E5E7EB",progressFillColor:"#1A1F36",stickyChromePaddingTop:16,stickyChromePaddingBottom:20,languageSelectorBackground:"#FFFFFF",languageSelectorTextColor:"#2563EB",languageSelectorBorderColor:"#2563EB"},layout:{showHeader:!0,showFooter:!0,showProgressBar:!0,showLanguageSwitcher:!1,showNextButton:!0,showBackButton:!0,showQuestionNumbers:!0,showRequiredAsterisk:!0,width:"standard",borderStyle:"rounded",fontStyle:"modern"},buttons:{next:"Next",back:"Back",submit:"Submit"},colorScheme:{...M},colorSource:"auto",typography:{fontFamily:"Inter, sans-serif",headingWeight:700},motion:{enabled:!1,durationMs:200}},questionTypes:bt(e),placeholders:{firstName:"Alex",lastName:"Customer",email:"alex@example.com"},customFields:{},debug:{enabled:!1,sampleAnswers:{}},deploy:{target:"aws",autoDeploy:!1}}}function ee(e,o){return{...e,...o??{}}}function _e(e){let o=(e.surveyTypes??[]).filter(c=>Q.includes(c)),t=[...new Set([...o,...Q])],n=St(t,e.instanceId),r=e.global??{},i=n.global,s={...n.questionTypes};if(e.questionTypes)for(let[c,d]of Object.entries(e.questionTypes))s[c]={...s[c]??{},...d};return{...n,...e,configuredAt:void 0,surveyTypes:o.length?o:n.surveyTypes,global:{...i,...r,header:ee(i.header,r.header),footer:ee(i.footer,r.footer),theme:ee(i.theme,r.theme),layout:ee(i.layout,r.layout),buttons:ee(i.buttons,r.buttons),logo:ee(i.logo,r.logo),colorScheme:ee(i.colorScheme,r.colorScheme),typography:ee(i.typography,r.typography),motion:ee(i.motion,r.motion)},questionTypes:s,placeholders:{...n.placeholders,...e.placeholders??{}},customFields:{...n.customFields,...e.customFields??{}},debug:{enabled:e.debug?.enabled??n.debug?.enabled??!1,sampleAnswers:e.debug?.sampleAnswers??n.debug?.sampleAnswers},deploy:{...n.deploy,...e.deploy??{}}}}var M,wo,Qe=q(()=>{"use strict";Te();M={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},wo={MCQ:{cardStyle:"outlined",selectedAccent:M.accent,optionGap:8,borderRadius:8,cardPadding:12,selectedBackground:M.secondary,hoverBorderColor:M.accent},TEXTFIELD:{inputRadius:8,focusRing:M.accent,borderColor:"#E5E7EB",inputPadding:12,inputHeight:44,placeholderColor:"#9CA3AF"},NPS_SCALE:{buttonStyle:"standard",selectedFill:M.secondary,labelColor:M.text,trackBarColor:"#F2F2F2",trackHighlightColor:"#FBE8F3",cellSize:40,cellGap:4},CFM_MATRIX:{rowLabelWidth:180,cellSelectedColor:M.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:"#2563EB",cellPadding:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:M.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:M.primary,cellPadding:8,accentColor:M.accent,emojiSize:24,unselectedOpacity:.5,selectedRingColor:M.accent,cellSize:40,tooltipBg:"#1F2937"},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:M.primary,rowLabelWidth:180,unselectedStarOpacity:.5},SLIDER_MATRIX:{trackColor:M.accent,thumbColor:M.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28},FILE_UPLOAD:{dropzoneStyle:"dashed",accentColor:M.accent,dropzonePadding:24},TEXT_AND_MEDIA:{mediaMaxWidth:100,mediaRadius:8,captionColor:"#6B7280",captionSize:14},HEATMAP:{pinColor:M.accent,pinSize:12,pinBorderColor:"#FFFFFF",overlayOpacity:.3},RANK_ORDER:{drag:{itemBg:"#F9FAFB",dragHandleColor:"#9CA3AF",rankBadgeColor:M.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:M.primary,itemPadding:12,itemGap:8}}}});function xo(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let r=n[0].split(":")[0].trim(),i=n[1].trim();o[r]=i}return o}function E(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function To(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function xe(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function $o(e){let o={global:{},questionTypes:{}},t=o.global,n={},r={},i={},s={},c={},d={},m={},b=o.questionTypes;if(e["--cfm-primary"]&&(n.primary=e["--cfm-primary"]),e["--cfm-secondary"]&&(n.secondary=e["--cfm-secondary"]),e["--cfm-accent"]&&(n.accent=e["--cfm-accent"]),e["--cfm-background"]&&(n.background=e["--cfm-background"]),e["--cfm-text"]&&(n.text=e["--cfm-text"]),e["--cfm-button-text"]&&(n.buttonText=e["--cfm-button-text"]),e["--cfm-max-width"]&&bo[e["--cfm-max-width"]]&&(c.width=bo[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&So[e["--cfm-border-radius"]]&&(c.borderStyle=So[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],Co[e["--cfm-font-family"]]&&(c.fontStyle=Co[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=xe(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let B=E(e["--cfm-motion-duration"]);B!==void 0&&(m.durationMs=B,m.enabled=B>0)}e["--cfm-header-height"]&&(r.height=E(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(r.logoBoxWidth=E(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(r.logoBoxHeight=E(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(r.logoPadding=E(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(r.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(r.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(r.companyNameFontSize=E(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(r.companyNameFontWeight=xe(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(r.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(r.contentPaddingX=E(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(i.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(i.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(i.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(i.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(i.logoWidth=E(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(i.logoHeight=E(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(i.paddingY=E(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(i.paddingX=E(e["--cfm-footer-padding-x"])),e["--cfm-background"]&&(s.pageBackground=e["--cfm-background"]),e["--cfm-card-bg"]&&(s.cardBackground=e["--cfm-card-bg"]),e["--cfm-card-border-color"]&&(s.cardBorderColor=e["--cfm-card-border-color"]),e["--cfm-card-padding"]&&(s.cardPadding=E(e["--cfm-card-padding"])),e["--cfm-card-shadow"]&&(s.cardShadowEnabled=e["--cfm-card-shadow"]!=="none"),e["--cfm-selected-bg"]&&(s.selectedBackground=e["--cfm-selected-bg"]),e["--cfm-zebra-row"]&&(s.zebraRowColor=e["--cfm-zebra-row"]),e["--cfm-row-band"]&&(s.rowBandColor=e["--cfm-row-band"]),e["--cfm-validation-border"]&&(s.validationBorder=e["--cfm-validation-border"]),e["--cfm-validation-bg"]&&(s.validationBackground=e["--cfm-validation-bg"]),e["--cfm-tooltip-bg"]&&(s.tooltipBackground=e["--cfm-tooltip-bg"]),e["--cfm-progress-height"]&&(s.progressTrackHeight=E(e["--cfm-progress-height"])),e["--cfm-progress-track"]&&(s.progressTrackColor=e["--cfm-progress-track"]),e["--cfm-progress-fill"]&&(s.progressFillColor=e["--cfm-progress-fill"]),e["--cfm-sticky-pt"]&&(s.stickyChromePaddingTop=E(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=E(e["--cfm-sticky-pb"]));let S={};e["--cfm-mcq-selected-accent"]&&(S.selectedAccent=e["--cfm-mcq-selected-accent"]),e["--cfm-mcq-border-radius"]&&(S.borderRadius=E(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(S.optionGap=E(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(S.cardPadding=E(e["--cfm-mcq-card-padding"])),e["--cfm-mcq-selected-bg"]&&(S.selectedBackground=e["--cfm-mcq-selected-bg"]),e["--cfm-mcq-hover-border"]&&(S.hoverBorderColor=e["--cfm-mcq-hover-border"]),Object.keys(S).length&&(b.MCQ=S);let x={};e["--cfm-input-radius"]&&(x.inputRadius=E(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(x.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(x.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(x.inputPadding=E(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=E(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(b.TEXTFIELD=x);let F={};e["--cfm-nps-selected-fill"]&&(F.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(F.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(F.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(F.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(F.cellSize=E(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(F.cellGap=E(e["--cfm-nps-cell-gap"])),Object.keys(F).length&&(b.NPS_SCALE=F);let A=E(e["--cfm-matrix-row-width"]),R={};A!==void 0&&(R.rowLabelWidth=A),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=To(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&(R.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&(R.cellPadding=E(e["--cfm-matrix-cell-padding"])),Object.keys(R).length&&(b.CFM_MATRIX=R);let f={...R};e["--cfm-csat-accent"]&&(f.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(f.emojiSize=E(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(f.unselectedOpacity=xe(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(f.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(f.cellSize=E(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(f.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(f).length>Object.keys(R).length||e["--cfm-csat-accent"])&&(b.CSAT_MATRIX=f);let y={};e["--cfm-star-color"]&&(y.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(y.badgeColor=e["--cfm-badge-color"]),A!==void 0&&(y.rowLabelWidth=A),e["--cfm-star-unselected-opacity"]&&(y.unselectedStarOpacity=xe(e["--cfm-star-unselected-opacity"])),Object.keys(y).length&&(b.RATING_MATRIX=y);let T={};e["--cfm-slider-track"]&&(T.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(T.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(T.tickColor=e["--cfm-slider-tick"]),A!==void 0&&(T.rowLabelWidth=A),e["--cfm-slider-row-band"]&&(T.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(T.tickBadgeSize=E(e["--cfm-slider-tick-size"])),Object.keys(T).length&&(b.SLIDER_MATRIX=T);let $={};e["--cfm-upload-accent"]&&($.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&($.dropzonePadding=E(e["--cfm-upload-padding"])),Object.keys($).length&&(b.FILE_UPLOAD=$);let w={};e["--cfm-media-max-width"]&&(w.mediaMaxWidth=To(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(w.mediaRadius=E(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(w.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(w.captionSize=E(e["--cfm-media-caption-size"])),Object.keys(w).length&&(b.TEXT_AND_MEDIA=w);let P={};e["--cfm-heatmap-pin"]&&(P.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(P.pinSize=E(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(P.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(P.overlayOpacity=xe(e["--cfm-heatmap-overlay-opacity"])),Object.keys(P).length&&(b.HEATMAP=P);let C={};return e["--cfm-rank-item-bg"]&&(C.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(C.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(C.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(C.itemPadding=E(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(C.itemGap=E(e["--cfm-rank-item-gap"])),Object.keys(C).length&&(b.RANK_ORDER=C),Object.keys(n).length&&(t.colorScheme=n),Object.keys(r).length&&(t.header=r),Object.keys(i).length&&(t.footer=i),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(m).length&&(t.motion=m),o}function ue(e){let o=[$e.join(e,"src","styles","survey-theme.css"),$e.join(e,"src","app","survey-theme.css"),$e.join(e,"src","styles","globals.css"),$e.join(e,"src","app","globals.css")];for(let t of o)if(De.existsSync(t)&&De.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var De,$e,bo,So,Co,Le=q(()=>{"use strict";De=k(require("fs")),$e=k(require("path")),bo={"36rem":"narrow","48rem":"standard","64rem":"wide"},So={"0px":"sharp","12px":"rounded","9999px":"pill"},Co={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});function Tt(e){for(let o of Ct){let t=Ro.join(e,o);if(Oe.existsSync(t))return t}return null}function xt(e){let o=e.trim();if(!o||o.startsWith("http")||o.startsWith("data:"))return null;let t=o.split("?")[0];return t.startsWith("/")?t.slice(1):t}function ko(e){let o=Tt(e);if(!o)return null;let t=Oe.readFileSync(o,"utf8"),n=t.match(/data-cfm-logo[\s\S]*?src=["']([^"']+)["']/i)??t.match(/src=["']([^"']+)["'][\s\S]*?data-cfm-logo/i);if(n){let s=xt(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let r=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(r)return{mode:"text",label:r[1].trim()};let i=t.match(/data-cfm-company[^>]*>([^<]+)</i);return i&&!n?{mode:"text",label:i[1].trim()}:null}var Oe,Ro,Ct,Eo=q(()=>{"use strict";Oe=k(require("fs")),Ro=k(require("path")),Ct=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var No={};Ne(No,{logSeedSource:()=>Ke,resolveInitialConfig:()=>me,writeResolvedUiConfig:()=>Ye});function Ge(e){return e.filter(o=>Q.includes(o))}function Ao(e){try{let o=JSON.parse(G.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function kt(e){let o={global:{}};if(!G.existsSync(e))return o;let t=G.readFileSync(e,"utf8"),n=new Set;for(let i of Q)t.includes(i)&&n.add(i);n.size&&(o.surveyTypes=[...n]);let r=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(r){let i=r[1].trim(),s=i.match(/company[:\s]+([^,;]+)/i),c=i.match(/title[:\s]+([^,;]+)/i);if(s&&(o.global.companyName=s[1].trim()),c){let d=c[1].trim();o.global.surveyTitle=d,o.global.browserTabTitle=d}}return o}function Io(e,o){let t=oe.join(e,o);if(!G.existsSync(t))return null;let n=G.readFileSync(t);if(n.length>$t)return{fileName:o,dataUrl:""};let r=oe.extname(o).toLowerCase(),i=Rt[r]??"application/octet-stream";return{fileName:o,dataUrl:`data:${i};base64,${n.toString("base64")}`}}function Fo(e,o){if(!o)return null;if(o.url&&typeof o.url=="string")return{fileName:o.fileName??null,url:o.url};if(o.fileName){let t=Io(e,o.fileName);if(t)return{fileName:t.fileName,url:t.dataUrl||null}}return o.fileName===null&&o.url===null?{fileName:null,url:null}:null}function Po(e,o){let t=e.global??{},n=o.global??{},r=e.questionTypes??{},i=o.questionTypes??{},s={...r};for(let[c,d]of Object.entries(i))s[c]={...s[c]??{},...d};return{...e,...o,surveyTypes:o.surveyTypes??e.surveyTypes,global:{...t,...n,header:{...t.header,...n.header},footer:{...t.footer,...n.footer},theme:{...t.theme,...n.theme},layout:{...t.layout,...n.layout},buttons:{...t.buttons,...n.buttons},logo:{...t.logo,...n.logo},colorScheme:{...t.colorScheme,...n.colorScheme},typography:{...t.typography,...n.typography},motion:{...t.motion,...n.motion}},questionTypes:s,placeholders:{...e.placeholders,...o.placeholders},customFields:{...e.customFields,...o.customFields},deploy:{...e.deploy,...o.deploy}}}function me(e){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=oe.join(o,"survey-ui-config.json"),n=oe.join(o,"implementation_plan.md"),r=oe.join(o,"public"),i=Ge(e.surveyTypes),s={},c="defaults",d=ue(o);if(d){let C=G.readFileSync(d,"utf8"),B=xo(C);Object.keys(B).length>0&&(s=$o(B),c="survey-theme.css")}let m=kt(n);s=Po(s,m);let b=Ao(t);b&&(s=Po(s,b),c="survey-ui-config.json");let S=oe.join(o,"survey-ui-config.final.json"),x=Ao(S),F=!!b?.configuredAt,A=!!x?.configuredAt;if(x&&A&&!F){let C=Fo(r,x.global?.logo);C&&(s.global={...s.global??{},logo:{fileName:C.fileName,url:C.url}})}let R=Fo(r,s.global?.logo),f=ko(o),y=!!b?.configuredAt,T=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),$=f?.mode==="image"?f.fileName:null,w=!y&&T&&$!=null&&R?.fileName!==$;if(R&&!w)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(f?.mode==="image"){let C=Io(r,f.fileName);s.global={...s.global??{},logo:{fileName:f.fileName,url:C?.dataUrl||null}}}else f?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??f.label});return s.surveyTypes=Ge(s.surveyTypes??i),s.surveyTypes?.length||(s.surveyTypes=i),e.instanceId&&(s.instanceId=e.instanceId),{config:_e(s),source:c}}function Ke(e){console.log(e==="survey-ui-config.json"?`${ge.dim} Seeding wizard from survey-ui-config.json${ge.reset}`:e==="survey-theme.css"?`${ge.dim} Seeding wizard from survey-theme.css + defaults${ge.reset}`:`${ge.dim} Seeding wizard from SDK defaults${ge.reset}`)}function Ye(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??Ge(Q),{config:n}=me({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),r=oe.join(o,"survey-ui-config.json");return G.writeFileSync(r,JSON.stringify(n,null,2),"utf8"),r}var G,oe,ge,$t,Rt,Re=q(()=>{"use strict";G=k(require("fs")),oe=k(require("path"));W();Qe();Le();Te();Eo();ge=a,$t=512e3,Rt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function X(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function h(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function l(e,o){return typeof e=="string"&&e.length?e:o}function no(e){return e==="left"?"1":e==="center"?"2":"3"}function Be(e){return e==="left"?"start":e==="center"?"center":"end"}function Ot(e){let o=l(e.logoPlacement,"left"),t=l(e.companyNamePlacement,"left"),n={"--cfm-header-brand-gap":"16px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0"};return o==="left"&&t==="left"?{...n,"--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start","--cfm-header-company-col":"1","--cfm-header-company-justify":"start","--cfm-header-company-margin-left":"calc(var(--cfm-header-logo-width) + var(--cfm-header-brand-gap))"}:o==="right"&&t==="right"?{...n,"--cfm-header-logo-col":"3","--cfm-header-logo-justify":"end","--cfm-header-company-col":"3","--cfm-header-company-justify":"end","--cfm-header-company-margin-right":"calc(var(--cfm-header-logo-width) + var(--cfm-header-brand-gap))"}:{...n,"--cfm-header-logo-col":no(o),"--cfm-header-logo-justify":Be(o),"--cfm-header-company-col":no(t),"--cfm-header-company-justify":Be(t)}}function Mt(e){let o=l(e.logoPlacement,"left"),t=l(e.layout,"row"),n=o==="right"?"1":"3",r=o==="right"?"start":"end";return t==="stack"?{"--cfm-footer-inner-display":"flex","--cfm-footer-inner-direction":"column","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":Be(o),"--cfm-footer-links-col":"1","--cfm-footer-links-justify":"start"}:{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":no(o),"--cfm-footer-logo-justify":Be(o),"--cfm-footer-links-col":n,"--cfm-footer-links-justify":r}}function Ue(e,o){o.numberLabelMode&&(e["--cfm-number-label-mode"]=l(o.numberLabelMode,"traffic")),o.monochromeNumberColor&&(e["--cfm-number-mono-color"]=l(o.monochromeNumberColor,"#9CA3AF"));let t=o.individualNumberColors;Array.isArray(t)&&t.forEach((n,r)=>{typeof n=="string"&&(e[`--cfm-number-color-${r}`]=n)})}function Bt(e,o){o.hintLabelColor&&(e["--cfm-hint-label-color"]=l(o.hintLabelColor,"#6B7280")),o.hintLabelBgColor&&(e["--cfm-hint-label-bg"]=l(o.hintLabelBgColor,"transparent"))}function ze(e,o,t){(t==="matrix"||t==="csat")&&(o.columnLabelColor&&(e["--cfm-matrix-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-matrix-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="csat"&&(o.columnLabelColor&&(e["--cfm-csat-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-csat-column-label-bg"]=l(o.columnLabelBgColor,"transparent"))),t==="slider"&&(o.columnLabelColor&&(e["--cfm-slider-tick-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-slider-tick-label-bg"]=l(o.columnLabelBgColor,"transparent")))}function Ut(e,o){let t=l(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${h(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${h(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${h(o.optionPadding??o.cardPadding,12)}px`,e["--cfm-mcq-hover-border"]=l(o.hoverBorderColor,"#00B5AD"),e["--cfm-mcq-option-style"]=t,o.filledOptionBg&&(e["--cfm-mcq-filled-bg"]=l(o.filledOptionBg,"#F9FAFB"))}function zt(e,o){e["--cfm-input-radius"]=`${h(o.inputRadius,8)}px`,e["--cfm-input-border"]=l(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${h(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${h(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=l(o.placeholderColor,"#9CA3AF")}function qt(e,o){e["--cfm-nps-cell-size"]=`${h(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${h(o.cellGap,4)}px`,e["--cfm-nps-button-style"]=l(o.buttonStyle,"standard"),e["--cfm-nps-selected-fill"]=l(o.selectedFill,"#E8F5FD"),e["--cfm-nps-track-bar"]=l(o.trackBarColor,"#F2F2F2"),e["--cfm-nps-track-highlight"]=l(o.trackHighlightColor,"#FBE8F3"),Bt(e,o),Ue(e,o)}function Wt(e,o){e["--cfm-matrix-row-width"]=`${h(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${h(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${h(o.cellPadding,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=l(o.carouselDotColor,"#2563EB")),ze(e,o,"matrix")}function Xt(e,o){e["--cfm-csat-emoji-size"]=`${h(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(h(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(h(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${h(o.cellSize,40)}px`,e["--cfm-csat-tooltip-bg"]=l(o.tooltipBg,"#1F2937"),e["--cfm-csat-accent"]=l(o.accentColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-matrix-row-width"]=`${h(o.rowLabelWidth,180)}px`,ze(e,o,"csat"),Ue(e,o)}function Ht(e,o){e["--cfm-star-color"]=l(o.starColor,"#F59E0B"),e["--cfm-badge-color"]=l(o.badgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-csat-emoji-size"]=`${h(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(h(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(h(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${h(o.rowLabelWidth,180)}px`,ze(e,o,"csat"),Ue(e,o)}function Vt(e,o){e["--cfm-slider-track"]=l(o.trackColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-slider-thumb"]=l(o.thumbColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-slider-tick"]=l(o.tickColor,"#9CA3AF"),e["--cfm-matrix-row-width"]=`${h(o.rowLabelWidth,180)}px`,e["--cfm-slider-row-band"]=l(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${h(o.tickBadgeSize,28)}px`,ze(e,o,"slider"),Ue(e,o)}function Jt(e,o){e["--cfm-upload-border-color"]=l(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${h(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=l(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=l(o.dropzoneStyle,"dashed")}function Qt(e,o){e["--cfm-media-max-width"]=`${h(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${h(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=l(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${h(o.captionSize,14)}px`}function Gt(e,o){e["--cfm-heatmap-pin"]=l(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${h(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=l(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(h(o.overlayOpacity,0))}function Kt(e,o){let t=X(o.drag)??o,n=X(o.dropdown)??t;e["--cfm-rank-item-bg"]=l(t.itemBg,"#F9FAFB"),e["--cfm-rank-badge-bg"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-badge-text"]="#ffffff",e["--cfm-rank-badge"]=l(t.rankBadgeColor,e["--cfm-primary"]??"#1A1F36"),e["--cfm-rank-item-padding"]=`${h(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${h(t.itemGap,8)}px`,e["--cfm-rank-handle"]=l(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=l(n.selectBorderColor,"#E5E7EB")}function qe(e){let o=X(e.global)??{},t=X(o.colorScheme)??{},n=X(o.header)??{},r=X(o.footer)??{},i=X(o.theme)??{},s=X(o.layout)??{},c=X(o.typography)??{},d=X(o.motion)??{},m=e.questionTypes??{},b=l(s.fontStyle,"modern"),S=Bo[b]??l(c.fontFamily,Bo.modern),x=l(s.width,"standard"),F=l(s.borderStyle,"rounded"),A=l(i.cellSelectedColor,l(t.accent,"#00B5AD")),R=l(i.focusRingColor,l(t.accent,"#00B5AD")),f=l(i.selectedBackground,l(t.secondary,"#E8F5FD")),y={"--cfm-primary":l(t.primary,"#1A1F36"),"--cfm-secondary":l(t.secondary,"#E8F5FD"),"--cfm-accent":l(t.accent,"#00B5AD"),"--cfm-background":l(i.pageBackground??t.background,"#FFFFFF"),"--cfm-text":l(t.text,"#1A1F36"),"--cfm-button-text":l(t.buttonText,"#FFFFFF"),"--cfm-max-width":Oo[x]??Oo.standard,"--cfm-border-radius":Mo[F]??Mo.rounded,"--cfm-font-family":S,"--cfm-heading-weight":String(h(c.headingWeight,700)),"--cfm-motion-duration":`${h(d.durationMs,200)}ms`,"--cfm-header-height":`${h(n.height,120)}px`,"--cfm-header-logo-width":`${h(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${h(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${h(n.logoPadding,10)}px`,"--cfm-header-show-company":n.showCompanyName===!1?"0":"1","--cfm-header-bg":l(n.backgroundColor,"#FFFFFF"),"--cfm-header-company-color":l(n.companyNameColor,l(t.text,"#1A1F36")),"--cfm-header-company-size":`${h(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(h(n.companyNameFontWeight,600)),"--cfm-header-border":l(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${h(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",...Ot(n),"--cfm-footer-bg":l(r.backgroundColor,"#262626"),"--cfm-footer-text":l(r.textColor,"#9CA3AF"),"--cfm-footer-link":l(r.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":l(r.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${h(r.logoWidth,120)}px`,"--cfm-footer-logo-height":`${h(r.logoHeight,32)}px`,"--cfm-footer-padding-y":`${h(r.paddingY,24)}px`,"--cfm-footer-padding-x":`${h(r.paddingX,40)}px`,...Mt(r),"--cfm-card-bg":l(i.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(i.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${h(i.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":i.cardShadowEnabled===!1?"none":`0 ${h(i.cardShadowOffsetY,1)}px ${h(i.cardShadowBlur,3)}px ${l(i.cardShadowColor,"rgba(0,0,0,0.1)")}`,"--cfm-selected-bg":f,"--cfm-mcq-selected-accent":R,"--cfm-mcq-selected-bg":f,"--cfm-matrix-selected":A,"--cfm-csat-ring-color":A,"--cfm-input-focus-ring":R,"--cfm-zebra-row":l(i.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":l(i.rowBandColor,"#F3F4F6"),"--cfm-validation-border":l(i.validationBorder,"#333333"),"--cfm-validation-bg":l(i.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":l(i.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${h(i.progressTrackHeight,12)}px`,"--cfm-progress-track":l(i.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(i.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${h(i.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${h(i.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":l(i.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":l(i.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":l(i.languageSelectorBorderColor,"#2563EB")},T=[["MCQ",Ut],["TEXTFIELD",zt],["NPS_SCALE",qt],["CFM_MATRIX",Wt],["CSAT_MATRIX",Xt],["RATING_MATRIX",Ht],["SLIDER_MATRIX",Vt],["FILE_UPLOAD",Jt],["TEXT_AND_MEDIA",Qt],["HEATMAP",Gt],["RANK_ORDER",Kt]];for(let[$,w]of T){let P=X(m[$]);P&&w(y,P)}return y}function ro(e){let o=e.questionTypes??{},t=X(o.MCQ),n=X(o.NPS_SCALE),r=X(o.FILE_UPLOAD),i={};return i["data-cfm-mcq-style"]=l(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(i["data-cfm-nps-button-style"]=l(n.buttonStyle,"standard")),r?.dropzoneStyle&&(i["data-cfm-dropzone-style"]=l(r.dropzoneStyle,"dashed")),i}var Oo,Mo,Bo,io=q(()=>{"use strict";Oo={narrow:"36rem",standard:"48rem",wide:"64rem"},Mo={sharp:"0px",rounded:"12px",pill:"9999px"},Bo={system:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',inter:"Inter, system-ui, sans-serif",modern:"Inter, sans-serif",roboto:"Roboto, system-ui, sans-serif",openSans:'"Open Sans", system-ui, sans-serif',lato:"Lato, system-ui, sans-serif",poppins:"Poppins, system-ui, sans-serif",montserrat:"Montserrat, system-ui, sans-serif",nunito:"Nunito, system-ui, sans-serif",raleway:"Raleway, system-ui, sans-serif",sourceSans:'"Source Sans 3", system-ui, sans-serif',georgia:'Georgia, "Times New Roman", serif',serif:"Georgia, serif",merriweather:"Merriweather, Georgia, serif",playfair:'"Playfair Display", Georgia, serif'}});function Yt(e){return`:root {
3
3
  ${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>` ${t}: ${n};`).join(`
4
4
  `)}
5
5
  }`}function Zt(e,o){let t=qe(e),n=Yt(t),r=o.match(/:root\s*\{[\s\S]*?\n\}/);return r?o.replace(r[0],n):`${n}
6
6
 
7
7
  ${o}`}function en(e){let o=ce.join(e,"src","styles","survey-theme.css");if(te.existsSync(ce.dirname(o)))return o;let t=ce.join(e,"src","app","survey-theme.css");return te.existsSync(ce.dirname(t))?t:(te.mkdirSync(ce.dirname(o),{recursive:!0}),o)}function Uo(e,o,t){let n=te.readFileSync(t,"utf8"),r=en(e),i=Zt(o,n);return te.writeFileSync(r,i,"utf8"),r}var te,ce,zo=q(()=>{"use strict";te=k(require("fs")),ce=k(require("path"));io()});function qo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Wo(e,o){return JSON.stringify(e)===JSON.stringify(o)}function ye(e){return typeof e=="string"&&e.startsWith("data:")&&e.length>80?`${e.slice(0,48)}\u2026 (${e.length} chars)`:e}function Xo(e,o,t,n){if(Wo(e,o)){n.unchangedCount+=1;return}if(e===void 0&&o!==void 0){n.added.push({path:t,before:void 0,after:ye(o)});return}if(e!==void 0&&o===void 0){n.removed.push({path:t,before:ye(e),after:void 0});return}if(Array.isArray(e)&&Array.isArray(o)){Wo(e,o)?n.unchangedCount+=1:n.changed.push({path:t,before:ye(e),after:ye(o)});return}if(qo(e)&&qo(o)){let r=new Set([...Object.keys(e),...Object.keys(o)]);for(let i of r){if(on.has(i)&&t==="")continue;let s=t?`${t}.${i}`:i;Xo(e[i],o[i],s,n)}return}n.changed.push({path:t,before:ye(e),after:ye(o)})}function so(e,o){let t={changed:[],added:[],removed:[],unchangedCount:0};return Xo(e,o,"",t),t}function We(e){let o=["# UI Config Diff (seed \u2192 final)","",`**Changed:** ${e.changed.length} \xB7 **Added:** ${e.added.length} \xB7 **Removed:** ${e.removed.length}`,"","> Review only \u2014 run `npx cfm-sdk confirm-ui-config` to apply final config to the project.",""],t=(n,r)=>{if(r.length){o.push(`## ${n}`,"");for(let i of r)o.push(`### \`${i.path}\``),o.push(`- **Before:** \`${JSON.stringify(i.before)}\``),o.push(`- **After:** \`${JSON.stringify(i.after)}\``),o.push("")}};return t("Changed",e.changed),t("Added",e.added),t("Removed",e.removed),!e.changed.length&&!e.added.length&&!e.removed.length&&o.push("_No differences \u2014 final config matches seed._",""),o.join(`
8
- `)}function ne(e){return{seedPath:we.join(e,"survey-ui-config.seed.json"),finalPath:we.join(e,"survey-ui-config.final.json"),diffJsonPath:we.join(e,"survey-ui-config.diff.json"),diffMdPath:we.join(e,"survey-ui-config.diff.md"),activeConfigPath:we.join(e,"survey-ui-config.json")}}function Xe(e,o,t){let n=ne(e),r=so(o,t);return he.writeFileSync(n.seedPath,JSON.stringify(o,null,2),"utf8"),he.writeFileSync(n.finalPath,JSON.stringify(t,null,2),"utf8"),he.writeFileSync(n.diffJsonPath,JSON.stringify(r,null,2),"utf8"),he.writeFileSync(n.diffMdPath,We(r),"utf8"),he.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),r}var he,we,on,ke=q(()=>{"use strict";he=k(require("fs")),we=k(require("path")),on=new Set(["configuredAt","instanceId"])});function Vo(e){return Ho[e]?Ho[e]:/individualNumberColors\.\d+/.test(e)||e.startsWith("questionTypes.")&&e.includes("columnLabel")||e.startsWith("questionTypes.")&&e.includes("hintLabel")||e.startsWith("questionTypes.")&&e.includes("numberLabel")?"css":e.startsWith("customFields.")||e.startsWith("placeholders.")?"runtime":"unknown"}var Ho,Jo=q(()=>{"use strict";Ho={"global.colorScheme.primary":"css","global.colorScheme.secondary":"css","global.colorScheme.accent":"css","global.colorScheme.background":"css","global.colorScheme.text":"css","global.colorScheme.buttonText":"css","global.theme.pageBackground":"css","global.theme.cardBackground":"css","global.theme.cardBorderColor":"css","global.theme.cardPadding":"css","global.theme.cardShadowEnabled":"css","global.theme.cellSelectedColor":"css","global.theme.focusRingColor":"css","global.theme.selectedBackground":"css","global.theme.zebraRowColor":"css","global.theme.rowBandColor":"css","global.theme.validationBorder":"css","global.theme.validationBackground":"css","global.theme.tooltipBackground":"css","global.theme.progressTrackHeight":"css","global.theme.progressTrackColor":"css","global.theme.progressFillColor":"css","global.theme.stickyChromePaddingTop":"css","global.theme.stickyChromePaddingBottom":"css","global.theme.languageSelectorBackground":"css","global.theme.languageSelectorTextColor":"css","global.theme.languageSelectorBorderColor":"css","global.header.height":"css","global.header.logoBoxWidth":"css","global.header.logoBoxHeight":"css","global.header.logoPadding":"css","global.header.logoPlacement":"css","global.header.showCompanyName":"css","global.header.companyNamePlacement":"css","global.header.companyNameFontSize":"css","global.header.companyNameFontWeight":"css","global.header.companyNameColor":"css","global.header.backgroundColor":"css","global.header.shadowEnabled":"css","global.header.borderBottomColor":"css","global.header.contentPaddingX":"css","global.footer.backgroundColor":"css","global.footer.textColor":"css","global.footer.linkColor":"css","global.footer.linkHoverColor":"css","global.footer.showLogo":"layout","global.footer.logoWidth":"css","global.footer.logoHeight":"css","global.footer.logoPlacement":"css","global.footer.copyrightText":"content","global.footer.layout":"css","global.footer.paddingY":"css","global.footer.paddingX":"css","global.footer.links":"content","global.layout.showHeader":"layout","global.layout.showFooter":"layout","global.layout.showProgressBar":"layout","global.layout.showLanguageSwitcher":"layout","global.layout.showNextButton":"layout","global.layout.showBackButton":"layout","global.layout.showQuestionNumbers":"layout","global.layout.showRequiredAsterisk":"layout","global.layout.width":"css","global.layout.borderStyle":"css","global.layout.fontStyle":"css","global.typography.fontFamily":"css","global.typography.headingWeight":"css","global.motion.durationMs":"css","global.motion.enabled":"css","global.surveyTitle":"content","global.companyName":"content","global.browserTabTitle":"content","global.thankYouMessage":"content","global.buttons.next":"content","global.buttons.back":"content","global.buttons.submit":"content","global.logo.fileName":"content","global.logo.url":"runtime","questionTypes.MCQ.optionStyle":"dom","questionTypes.MCQ.cardStyle":"dom","questionTypes.MCQ.optionGap":"css","questionTypes.MCQ.borderRadius":"css","questionTypes.MCQ.optionPadding":"css","questionTypes.MCQ.cardPadding":"css","questionTypes.MCQ.hoverBorderColor":"css","questionTypes.TEXTFIELD.inputRadius":"css","questionTypes.TEXTFIELD.borderColor":"css","questionTypes.TEXTFIELD.inputPadding":"css","questionTypes.TEXTFIELD.inputHeight":"css","questionTypes.TEXTFIELD.placeholderColor":"css","questionTypes.TEXTFIELD.defaultPlaceholder":"runtime","questionTypes.NPS_SCALE.buttonStyle":"dom","questionTypes.NPS_SCALE.trackBarColor":"css","questionTypes.NPS_SCALE.trackHighlightColor":"css","questionTypes.NPS_SCALE.cellSize":"css","questionTypes.NPS_SCALE.cellGap":"css","questionTypes.NPS_SCALE.hintMinText":"runtime","questionTypes.NPS_SCALE.hintMaxText":"runtime","questionTypes.NPS_SCALE.hintLabelColor":"css","questionTypes.NPS_SCALE.hintLabelBgColor":"css","questionTypes.NPS_SCALE.numberLabelMode":"css","questionTypes.NPS_SCALE.monochromeNumberColor":"css","questionTypes.CFM_MATRIX.rowLabelWidth":"css","questionTypes.CFM_MATRIX.bipolarColumnWidthPercent":"css","questionTypes.CFM_MATRIX.cellPadding":"css","questionTypes.CFM_MATRIX.columnLabelColor":"css","questionTypes.CFM_MATRIX.columnLabelBgColor":"css","questionTypes.CSAT_MATRIX.emojiSize":"css","questionTypes.CSAT_MATRIX.unselectedOpacity":"css","questionTypes.CSAT_MATRIX.cellSize":"css","questionTypes.CSAT_MATRIX.tooltipBg":"css","questionTypes.CSAT_MATRIX.rowLabelWidth":"css","questionTypes.RATING_MATRIX.unselectedStarOpacity":"css","questionTypes.RATING_MATRIX.emojiSize":"css","questionTypes.RATING_MATRIX.rowLabelWidth":"css","questionTypes.RATING_MATRIX.starColor":"css","questionTypes.RATING_MATRIX.badgeColor":"css","questionTypes.SLIDER_MATRIX.trackColor":"css","questionTypes.SLIDER_MATRIX.thumbColor":"css","questionTypes.SLIDER_MATRIX.tickColor":"css","questionTypes.SLIDER_MATRIX.rowLabelWidth":"css","questionTypes.SLIDER_MATRIX.rowBandColor":"css","questionTypes.SLIDER_MATRIX.tickBadgeSize":"css","questionTypes.FILE_UPLOAD.dropzoneStyle":"dom","questionTypes.FILE_UPLOAD.borderColor":"css","questionTypes.FILE_UPLOAD.dropzoneFillColor":"css","questionTypes.FILE_UPLOAD.dropzonePadding":"css","questionTypes.TEXT_AND_MEDIA.mediaMaxWidth":"css","questionTypes.TEXT_AND_MEDIA.mediaRadius":"css","questionTypes.TEXT_AND_MEDIA.captionColor":"css","questionTypes.TEXT_AND_MEDIA.captionSize":"css","questionTypes.HEATMAP.pinColor":"css","questionTypes.HEATMAP.pinSize":"css","questionTypes.HEATMAP.pinBorderColor":"css","questionTypes.HEATMAP.overlayOpacity":"css","questionTypes.RANK_ORDER.drag.itemBg":"css","questionTypes.RANK_ORDER.drag.rankBadgeColor":"css","questionTypes.RANK_ORDER.drag.dragHandleColor":"css","questionTypes.RANK_ORDER.drag.itemPadding":"css","questionTypes.RANK_ORDER.drag.itemGap":"css","questionTypes.RANK_ORDER.dropdown.itemBg":"css","questionTypes.RANK_ORDER.dropdown.rankBadgeColor":"css","questionTypes.RANK_ORDER.dropdown.selectBorderColor":"css","questionTypes.RANK_ORDER.dropdown.itemPadding":"css","questionTypes.RANK_ORDER.dropdown.itemGap":"css","placeholders.firstName":"runtime","placeholders.lastName":"runtime","placeholders.email":"runtime",customFields:"runtime","debug.enabled":"runtime","deploy.target":"runtime","deploy.autoDeploy":"runtime"}});var Ae={};Ne(Ae,{runApplyUiConfig:()=>dn});function nn(e,o){if(o&&_.existsSync(o))return o;let t=L.join(e,"survey-ui-config.json");if(_.existsSync(t))return t;let n=ne(e).finalPath;if(_.existsSync(n))return n;throw new Error("No survey-ui-config.json found. Complete the wizard or run confirm-ui-config first.")}function rn(e,o){let t=L.relative(L.dirname(o),o),n=(o.includes(`${L.sep}styles${L.sep}`),"./survey-theme.css"),r=[L.join(e,"src","app","globals.css"),L.join(e,"src","styles","globals.css")];for(let i of r){if(!_.existsSync(i))continue;let s=_.readFileSync(i,"utf8"),c=`@import '${n}';`;if(s.includes("survey-theme.css"))return;s.includes(c)||(s=`${c}
8
+ `)}function ne(e){return{seedPath:we.join(e,"survey-ui-config.seed.json"),finalPath:we.join(e,"survey-ui-config.final.json"),diffJsonPath:we.join(e,"survey-ui-config.diff.json"),diffMdPath:we.join(e,"survey-ui-config.diff.md"),activeConfigPath:we.join(e,"survey-ui-config.json")}}function Xe(e,o,t){let n=ne(e),r=so(o,t);return he.writeFileSync(n.seedPath,JSON.stringify(o,null,2),"utf8"),he.writeFileSync(n.finalPath,JSON.stringify(t,null,2),"utf8"),he.writeFileSync(n.diffJsonPath,JSON.stringify(r,null,2),"utf8"),he.writeFileSync(n.diffMdPath,We(r),"utf8"),he.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),r}var he,we,on,ke=q(()=>{"use strict";he=k(require("fs")),we=k(require("path")),on=new Set(["configuredAt","instanceId"])});function Vo(e){return Ho[e]?Ho[e]:/individualNumberColors\.\d+/.test(e)||e.startsWith("questionTypes.")&&e.includes("columnLabel")||e.startsWith("questionTypes.")&&e.includes("hintLabel")||e.startsWith("questionTypes.")&&e.includes("numberLabel")?"css":e.startsWith("customFields.")||e.startsWith("placeholders.")?"runtime":"unknown"}var Ho,Jo=q(()=>{"use strict";Ho={"global.colorScheme.primary":"css","global.colorScheme.secondary":"css","global.colorScheme.accent":"css","global.colorScheme.background":"css","global.colorScheme.text":"css","global.colorScheme.buttonText":"css","global.theme.pageBackground":"css","global.theme.cardBackground":"css","global.theme.cardBorderColor":"css","global.theme.cardPadding":"css","global.theme.cardShadowEnabled":"css","global.theme.cardShadowColor":"css","global.theme.cardShadowBlur":"css","global.theme.cardShadowOffsetY":"css","global.theme.cellSelectedColor":"css","global.theme.focusRingColor":"css","global.theme.selectedBackground":"css","global.theme.zebraRowColor":"css","global.theme.rowBandColor":"css","global.theme.validationBorder":"css","global.theme.validationBackground":"css","global.theme.tooltipBackground":"css","global.theme.progressTrackHeight":"css","global.theme.progressTrackColor":"css","global.theme.progressFillColor":"css","global.theme.stickyChromePaddingTop":"css","global.theme.stickyChromePaddingBottom":"css","global.theme.languageSelectorBackground":"css","global.theme.languageSelectorTextColor":"css","global.theme.languageSelectorBorderColor":"css","global.header.height":"css","global.header.logoBoxWidth":"css","global.header.logoBoxHeight":"css","global.header.logoPadding":"css","global.header.logoPlacement":"css","global.header.showCompanyName":"css","global.header.companyNamePlacement":"css","global.header.companyNameFontSize":"css","global.header.companyNameFontWeight":"css","global.header.companyNameColor":"css","global.header.backgroundColor":"css","global.header.shadowEnabled":"css","global.header.borderBottomColor":"css","global.header.contentPaddingX":"css","global.footer.backgroundColor":"css","global.footer.textColor":"css","global.footer.linkColor":"css","global.footer.linkHoverColor":"css","global.footer.showLogo":"layout","global.footer.logoWidth":"css","global.footer.logoHeight":"css","global.footer.logoPlacement":"css","global.footer.copyrightText":"content","global.footer.layout":"css","global.footer.paddingY":"css","global.footer.paddingX":"css","global.footer.links":"content","global.layout.showHeader":"layout","global.layout.showFooter":"layout","global.layout.showProgressBar":"layout","global.layout.showLanguageSwitcher":"layout","global.layout.showNextButton":"layout","global.layout.showBackButton":"layout","global.layout.showQuestionNumbers":"layout","global.layout.showRequiredAsterisk":"layout","global.layout.width":"css","global.layout.borderStyle":"css","global.layout.fontStyle":"css","global.typography.fontFamily":"css","global.typography.headingWeight":"css","global.motion.durationMs":"css","global.motion.enabled":"css","global.surveyTitle":"content","global.companyName":"content","global.browserTabTitle":"content","global.thankYouMessage":"content","global.buttons.next":"content","global.buttons.back":"content","global.buttons.submit":"content","global.logo.fileName":"content","global.logo.url":"runtime","questionTypes.MCQ.optionStyle":"dom","questionTypes.MCQ.cardStyle":"dom","questionTypes.MCQ.optionGap":"css","questionTypes.MCQ.borderRadius":"css","questionTypes.MCQ.optionPadding":"css","questionTypes.MCQ.cardPadding":"css","questionTypes.MCQ.hoverBorderColor":"css","questionTypes.MCQ.filledOptionBg":"css","questionTypes.TEXTFIELD.inputRadius":"css","questionTypes.TEXTFIELD.borderColor":"css","questionTypes.TEXTFIELD.inputPadding":"css","questionTypes.TEXTFIELD.inputHeight":"css","questionTypes.TEXTFIELD.placeholderColor":"css","questionTypes.TEXTFIELD.defaultPlaceholder":"runtime","questionTypes.NPS_SCALE.buttonStyle":"dom","questionTypes.NPS_SCALE.trackBarColor":"css","questionTypes.NPS_SCALE.trackHighlightColor":"css","questionTypes.NPS_SCALE.cellSize":"css","questionTypes.NPS_SCALE.cellGap":"css","questionTypes.NPS_SCALE.hintMinText":"runtime","questionTypes.NPS_SCALE.hintMaxText":"runtime","questionTypes.NPS_SCALE.hintLabelColor":"css","questionTypes.NPS_SCALE.hintLabelBgColor":"css","questionTypes.NPS_SCALE.numberLabelMode":"css","questionTypes.NPS_SCALE.monochromeNumberColor":"css","questionTypes.CFM_MATRIX.rowLabelWidth":"css","questionTypes.CFM_MATRIX.bipolarColumnWidthPercent":"css","questionTypes.CFM_MATRIX.cellPadding":"css","questionTypes.CFM_MATRIX.columnLabelColor":"css","questionTypes.CFM_MATRIX.columnLabelBgColor":"css","questionTypes.CSAT_MATRIX.emojiSize":"css","questionTypes.CSAT_MATRIX.unselectedOpacity":"css","questionTypes.CSAT_MATRIX.cellSize":"css","questionTypes.CSAT_MATRIX.tooltipBg":"css","questionTypes.CSAT_MATRIX.rowLabelWidth":"css","questionTypes.RATING_MATRIX.unselectedStarOpacity":"css","questionTypes.RATING_MATRIX.emojiSize":"css","questionTypes.RATING_MATRIX.rowLabelWidth":"css","questionTypes.RATING_MATRIX.starColor":"css","questionTypes.RATING_MATRIX.badgeColor":"css","questionTypes.SLIDER_MATRIX.trackColor":"css","questionTypes.SLIDER_MATRIX.thumbColor":"css","questionTypes.SLIDER_MATRIX.tickColor":"css","questionTypes.SLIDER_MATRIX.rowLabelWidth":"css","questionTypes.SLIDER_MATRIX.rowBandColor":"css","questionTypes.SLIDER_MATRIX.tickBadgeSize":"css","questionTypes.FILE_UPLOAD.dropzoneStyle":"dom","questionTypes.FILE_UPLOAD.borderColor":"css","questionTypes.FILE_UPLOAD.dropzoneFillColor":"css","questionTypes.FILE_UPLOAD.dropzonePadding":"css","questionTypes.TEXT_AND_MEDIA.mediaMaxWidth":"css","questionTypes.TEXT_AND_MEDIA.mediaRadius":"css","questionTypes.TEXT_AND_MEDIA.captionColor":"css","questionTypes.TEXT_AND_MEDIA.captionSize":"css","questionTypes.HEATMAP.pinColor":"css","questionTypes.HEATMAP.pinSize":"css","questionTypes.HEATMAP.pinBorderColor":"css","questionTypes.HEATMAP.overlayOpacity":"css","questionTypes.RANK_ORDER.drag.itemBg":"css","questionTypes.RANK_ORDER.drag.rankBadgeColor":"css","questionTypes.RANK_ORDER.drag.dragHandleColor":"css","questionTypes.RANK_ORDER.drag.itemPadding":"css","questionTypes.RANK_ORDER.drag.itemGap":"css","questionTypes.RANK_ORDER.dropdown.itemBg":"css","questionTypes.RANK_ORDER.dropdown.rankBadgeColor":"css","questionTypes.RANK_ORDER.dropdown.selectBorderColor":"css","questionTypes.RANK_ORDER.dropdown.itemHoverBg":"css","questionTypes.RANK_ORDER.dropdown.itemPadding":"css","questionTypes.RANK_ORDER.dropdown.itemGap":"css","placeholders.firstName":"runtime","placeholders.lastName":"runtime","placeholders.email":"runtime",customFields:"runtime","debug.enabled":"runtime","deploy.target":"runtime","deploy.autoDeploy":"runtime"}});var Ee={};Ne(Ee,{runApplyUiConfig:()=>dn});function nn(e,o){if(o&&_.existsSync(o))return o;let t=L.join(e,"survey-ui-config.json");if(_.existsSync(t))return t;let n=ne(e).finalPath;if(_.existsSync(n))return n;throw new Error("No survey-ui-config.json found. Complete the wizard or run confirm-ui-config first.")}function rn(e,o){let t=L.relative(L.dirname(o),o),n=(o.includes(`${L.sep}styles${L.sep}`),"./survey-theme.css"),r=[L.join(e,"src","app","globals.css"),L.join(e,"src","styles","globals.css")];for(let i of r){if(!_.existsSync(i))continue;let s=_.readFileSync(i,"utf8"),c=`@import '${n}';`;if(s.includes("survey-theme.css"))return;s.includes(c)||(s=`${c}
9
9
  ${s}`,_.writeFileSync(i,s,"utf8"));return}}function sn(e,o){let t=ro(o),n=L.join(e,"src","lib");_.mkdirSync(n,{recursive:!0});let r=L.join(n,"surveyUiDomAttributes.ts"),s=`/**
10
10
  * Runtime DOM attributes for wizard style modes (MCQ / NPS / upload).
11
11
  * Auto-generated by \`npx cfm-sdk apply-ui-config\` \u2014 do not edit manually.
@@ -16,7 +16,7 @@ export function applySurveyUiDomAttributes(): void {
16
16
  ${Object.entries(t).map(([c,d])=>` root.setAttribute('${c}', ${JSON.stringify(d)});`).join(`
17
17
  `)}
18
18
  }
19
- `;return _.writeFileSync(r,s,"utf8"),r}function cn(e){let o=L.join(e,"src","components");_.mkdirSync(o,{recursive:!0});let t=L.join(o,"SurveyUiConfigInit.tsx");return _.existsSync(t)||_.writeFileSync(t,tn,"utf8"),t}function an(e,o){let t=L.join(e,"src","lib","uiConfig.ts");if(_.existsSync(t))return;let n=L.join(o,"docs","templates","uiConfig.ts");_.existsSync(n)&&(_.mkdirSync(L.dirname(t),{recursive:!0}),_.copyFileSync(n,t))}function ln(e,o){let t=e.replace(/\.json$/,".diff.json");if(_.existsSync(t))try{let n=JSON.parse(_.readFileSync(t,"utf8")),r=[...(n.changed??[]).map(i=>i.path),...(n.added??[]).map(i=>i.path),...(n.removed??[]).map(i=>i.path)];for(let i of r)Vo(i)==="unknown"&&o.push(`Unmapped config path (verify manually): ${i}`)}catch{}}function dn(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=nn(o,e.configPath),n=L.join(__dirname,"..",".."),r=L.join(n,"templates","survey-theme.css"),i=L.join(n,"templates"),s=[],c=JSON.parse(_.readFileSync(t,"utf8")),d=[...new Set([...c.surveyTypes??[],...G])],g=_e({...c,surveyTypes:d}),w=Uo(o,g,r);rn(o,w),an(o,i),sn(o,g);let S;e.skipInitComponent||(S=cn(o));let x=qe(g),F=ro(g);ln(t,s),console.log(`${K.green}\u2705 Applied UI config \u2192 ${w}${K.reset}`),console.log(`${K.dim} ${Object.keys(x).length} CSS variables regenerated${K.reset}`),console.log(`${K.dim} DOM attrs: ${Object.entries(F).map(([E,R])=>`${E}=${R}`).join(", ")}${K.reset}`),S&&console.log(`${K.dim} Runtime init: ${S} (mount in layout if not already)${K.reset}`);for(let E of s)console.log(`${K.yellow} \u26A0 ${E}${K.reset}`);return{configPath:t,themeCssPath:w,cssVarCount:Object.keys(x).length,domAttributes:F,initComponentPath:S,warnings:s}}var _,L,K,tn,Ee=q(()=>{"use strict";_=k(require("fs")),L=k(require("path"));W();Ge();io();zo();ke();Jo();Te();K=a,tn=`'use client';
19
+ `;return _.writeFileSync(r,s,"utf8"),r}function cn(e){let o=L.join(e,"src","components");_.mkdirSync(o,{recursive:!0});let t=L.join(o,"SurveyUiConfigInit.tsx");return _.existsSync(t)||_.writeFileSync(t,tn,"utf8"),t}function an(e,o){let t=L.join(e,"src","lib","uiConfig.ts");if(_.existsSync(t))return;let n=L.join(o,"docs","templates","uiConfig.ts");_.existsSync(n)&&(_.mkdirSync(L.dirname(t),{recursive:!0}),_.copyFileSync(n,t))}function ln(e,o){let t=e.replace(/\.json$/,".diff.json");if(_.existsSync(t))try{let n=JSON.parse(_.readFileSync(t,"utf8")),r=[...(n.changed??[]).map(i=>i.path),...(n.added??[]).map(i=>i.path),...(n.removed??[]).map(i=>i.path)];for(let i of r)Vo(i)==="unknown"&&o.push(`Unmapped config path (verify manually): ${i}`)}catch{}}function dn(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=nn(o,e.configPath),n=L.join(__dirname,"..",".."),r=L.join(n,"templates","survey-theme.css"),i=L.join(n,"templates"),s=[],c=JSON.parse(_.readFileSync(t,"utf8")),d=[...new Set([...c.surveyTypes??[],...Q])],m=_e({...c,surveyTypes:d}),b=Uo(o,m,r);rn(o,b),an(o,i),sn(o,m);let S;e.skipInitComponent||(S=cn(o));let x=qe(m),F=ro(m);ln(t,s),console.log(`${K.green}\u2705 Applied UI config \u2192 ${b}${K.reset}`),console.log(`${K.dim} ${Object.keys(x).length} CSS variables regenerated${K.reset}`),console.log(`${K.dim} DOM attrs: ${Object.entries(F).map(([A,R])=>`${A}=${R}`).join(", ")}${K.reset}`),S&&console.log(`${K.dim} Runtime init: ${S} (mount in layout if not already)${K.reset}`);for(let A of s)console.log(`${K.yellow} \u26A0 ${A}${K.reset}`);return{configPath:t,themeCssPath:b,cssVarCount:Object.keys(x).length,domAttributes:F,initComponentPath:S,warnings:s}}var _,L,K,tn,Ae=q(()=>{"use strict";_=k(require("fs")),L=k(require("path"));W();Qe();io();zo();ke();Jo();Te();K=a,tn=`'use client';
20
20
 
21
21
  /**
22
22
  * Applies wizard DOM attributes from survey-ui-config.json at runtime.
@@ -32,9 +32,9 @@ export function SurveyUiConfigInit() {
32
32
  }, []);
33
33
  return null;
34
34
  }
35
- `});function He(e){if(!e.config)return null;let o=JSON.parse(JSON.stringify(e.config)),n=o.global?.logo;return e.logoUrl&&n&&(n.url=e.logoUrl),o}function Zo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?ot:et).get(n,i=>{if((i.statusCode??500)>=400){t(new Error(`Logo download failed HTTP ${i.statusCode}`));return}let s=[];i.on("data",c=>s.push(c)),i.on("end",()=>o(Buffer.concat(s)))}).on("error",t)})}async function gn(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?ot:et).request(r,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",g=>d+=g),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}async function le(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:r,apiBase:i,surveyId:s}=e,c=ao.join(o,"public");ae.existsSync(c)||ae.mkdirSync(c,{recursive:!0});let d=ao.join(c,t);if(n){let g=await Zo(n);return ae.writeFileSync(d,g),d}if(r&&i&&s){let g=await gn(`${i.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${r}`}}),w=await Zo(g.downloadUrl);return ae.writeFileSync(d,w),d}throw new Error("Logo download requires logoUrl from wizard poll or CFM_INSTANCE_ID + CFM_DEPLOY_API_BASE")}var ae,et,ot,ao,Ve=q(()=>{"use strict";ae=k(require("fs")),et=k(require("http")),ot=k(require("https")),ao=k(require("path"))});var st={};Ne(st,{runConfirmUiConfig:()=>Sn});function bn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function Sn(e={}){let o=process.env.INIT_CWD??process.cwd(),t=ne(o);if(!Y.existsSync(t.finalPath))throw new Error(`Missing ${t.finalPath}. Run customize-ui with --review and complete the wizard first.`);let n=JSON.parse(Y.readFileSync(Y.existsSync(t.seedPath)?t.seedPath:t.activeConfigPath,"utf8")),r=JSON.parse(Y.readFileSync(t.finalPath,"utf8")),i=so(n,r);if(console.log(`
35
+ `});function He(e){if(!e.config)return null;let o=JSON.parse(JSON.stringify(e.config)),n=o.global?.logo;return e.logoUrl&&n&&(n.url=e.logoUrl),o}function Zo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?ot:et).get(n,i=>{if((i.statusCode??500)>=400){t(new Error(`Logo download failed HTTP ${i.statusCode}`));return}let s=[];i.on("data",c=>s.push(c)),i.on("end",()=>o(Buffer.concat(s)))}).on("error",t)})}async function mn(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?ot:et).request(r,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",m=>d+=m),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}async function le(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:r,apiBase:i,surveyId:s}=e,c=ao.join(o,"public");ae.existsSync(c)||ae.mkdirSync(c,{recursive:!0});let d=ao.join(c,t);if(n){let m=await Zo(n);return ae.writeFileSync(d,m),d}if(r&&i&&s){let m=await mn(`${i.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${r}`}}),b=await Zo(m.downloadUrl);return ae.writeFileSync(d,b),d}throw new Error("Logo download requires logoUrl from wizard poll or CFM_INSTANCE_ID + CFM_DEPLOY_API_BASE")}var ae,et,ot,ao,Ve=q(()=>{"use strict";ae=k(require("fs")),et=k(require("http")),ot=k(require("https")),ao=k(require("path"))});var st={};Ne(st,{runConfirmUiConfig:()=>Sn});function bn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function Sn(e={}){let o=process.env.INIT_CWD??process.cwd(),t=ne(o);if(!Y.existsSync(t.finalPath))throw new Error(`Missing ${t.finalPath}. Run customize-ui with --review and complete the wizard first.`);let n=JSON.parse(Y.readFileSync(Y.existsSync(t.seedPath)?t.seedPath:t.activeConfigPath,"utf8")),r=JSON.parse(Y.readFileSync(t.finalPath,"utf8")),i=so(n,r);if(console.log(`
36
36
  ${J.bold}${J.cyan}\u{1F4CB} UI config review${J.reset}
37
- `),console.log(We(i)),e.diffOnly){Y.writeFileSync(t.diffJsonPath,JSON.stringify(i,null,2),"utf8"),Y.writeFileSync(t.diffMdPath,We(i),"utf8"),console.log(`${J.dim} Updated ${t.diffMdPath}${J.reset}`);return}Y.writeFileSync(t.activeConfigPath,JSON.stringify(r,null,2),"utf8"),console.log(`${J.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${J.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(Ee(),Ae));s({projectRoot:o,configPath:t.activeConfigPath});let c=r.global?.logo;if(!c?.fileName)return;let d=process.env.CFM_INSTANCE_ID,g=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),w=d?bn(d):null;try{await le({projectRoot:o,fileName:c.fileName,logoUrl:c.url,jwt:d??void 0,apiBase:g||void 0,surveyId:w??void 0}),console.log(`${J.green} Logo saved to public/${c.fileName}${J.reset}`),c.url&&console.log(`${J.dim} Public logo URL: ${c.url}${J.reset}`)}catch(S){console.log(`${J.yellow} Logo not downloaded \u2014 ${S instanceof Error?S.message:String(S)}${J.reset}`)}}var Y,J,ct=q(()=>{"use strict";Y=k(require("fs"));W();ke();Ve();J=a});var at={};Ne(at,{runFetchUiConfig:()=>Rn});async function xn(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?Tn:Cn).request(r,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",g=>d+=g),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}function $n(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function Rn(e={}){let o=process.env.CFM_INSTANCE_ID,t=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),n=e.sessionId??process.env.CFM_WIZARD_SESSION_ID;if(!o)throw new Error("CFM_INSTANCE_ID (JWT) is required");if(!t)throw new Error("CFM_DEPLOY_API_BASE is required");if(!n)throw new Error("CFM_WIZARD_SESSION_ID or --session= is required");let r=$n(o);if(!r)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let i=process.env.INIT_CWD??process.cwd(),s=ne(i),c=Ie.existsSync(s.seedPath)?s.seedPath:s.activeConfigPath;if(!Ie.existsSync(c))throw new Error(`Missing seed config at ${c}. Run customize-ui --review first.`);let d=await xn(`${t}/wizard/config/${encodeURIComponent(r)}?sessionId=${encodeURIComponent(n)}`,{headers:{Authorization:`Bearer ${o}`}});if(d.status!=="ready"||!d.config)throw new Error(`Wizard not complete yet (status: ${d.status})`);let g=He(d)??d.config,w=JSON.parse(Ie.readFileSync(c,"utf8")),S=Xe(i,w,g),x=g.global?.logo;if(x?.fileName)try{await le({projectRoot:i,fileName:x.fileName,logoUrl:d.logoUrl,jwt:o,apiBase:t,surveyId:r}),console.log(`${H.green} Logo saved to public/${x.fileName}${H.reset}`)}catch(F){console.warn(`${H.yellow} Logo download failed: ${F}${H.reset}`)}console.log(`
37
+ `),console.log(We(i)),e.diffOnly){Y.writeFileSync(t.diffJsonPath,JSON.stringify(i,null,2),"utf8"),Y.writeFileSync(t.diffMdPath,We(i),"utf8"),console.log(`${J.dim} Updated ${t.diffMdPath}${J.reset}`);return}Y.writeFileSync(t.activeConfigPath,JSON.stringify(r,null,2),"utf8"),console.log(`${J.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${J.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(Ae(),Ee));s({projectRoot:o,configPath:t.activeConfigPath});let c=r.global?.logo;if(!c?.fileName)return;let d=process.env.CFM_INSTANCE_ID,m=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),b=d?bn(d):null;try{await le({projectRoot:o,fileName:c.fileName,logoUrl:c.url,jwt:d??void 0,apiBase:m||void 0,surveyId:b??void 0}),console.log(`${J.green} Logo saved to public/${c.fileName}${J.reset}`),c.url&&console.log(`${J.dim} Public logo URL: ${c.url}${J.reset}`)}catch(S){console.log(`${J.yellow} Logo not downloaded \u2014 ${S instanceof Error?S.message:String(S)}${J.reset}`)}}var Y,J,ct=q(()=>{"use strict";Y=k(require("fs"));W();ke();Ve();J=a});var at={};Ne(at,{runFetchUiConfig:()=>Rn});async function xn(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?Tn:Cn).request(r,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",m=>d+=m),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),s.end()})}function $n(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function Rn(e={}){let o=process.env.CFM_INSTANCE_ID,t=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),n=e.sessionId??process.env.CFM_WIZARD_SESSION_ID;if(!o)throw new Error("CFM_INSTANCE_ID (JWT) is required");if(!t)throw new Error("CFM_DEPLOY_API_BASE is required");if(!n)throw new Error("CFM_WIZARD_SESSION_ID or --session= is required");let r=$n(o);if(!r)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let i=process.env.INIT_CWD??process.cwd(),s=ne(i),c=Ie.existsSync(s.seedPath)?s.seedPath:s.activeConfigPath;if(!Ie.existsSync(c))throw new Error(`Missing seed config at ${c}. Run customize-ui --review first.`);let d=await xn(`${t}/wizard/config/${encodeURIComponent(r)}?sessionId=${encodeURIComponent(n)}`,{headers:{Authorization:`Bearer ${o}`}});if(d.status!=="ready"||!d.config)throw new Error(`Wizard not complete yet (status: ${d.status})`);let m=He(d)??d.config,b=JSON.parse(Ie.readFileSync(c,"utf8")),S=Xe(i,b,m),x=m.global?.logo;if(x?.fileName)try{await le({projectRoot:i,fileName:x.fileName,logoUrl:d.logoUrl,jwt:o,apiBase:t,surveyId:r}),console.log(`${H.green} Logo saved to public/${x.fileName}${H.reset}`)}catch(F){console.warn(`${H.yellow} Logo download failed: ${F}${H.reset}`)}console.log(`
38
38
  ${H.green}\u2705 Fetched final config (review mode)${H.reset}`),console.log(`${H.green} Final: ${s.finalPath}${H.reset}`),console.log(`${H.green} Diff: ${s.diffMdPath}${H.reset}`),console.log(`${H.yellow} ${S.changed.length} changed, ${S.added.length} added, ${S.removed.length} removed${H.reset}`),console.log(`${H.dim} Apply when ready: npx cfm-sdk confirm-ui-config${H.reset}`)}var Ie,Cn,Tn,H,lt=q(()=>{"use strict";Ie=k(require("fs")),Cn=k(require("http")),Tn=k(require("https"));W();ke();Ve();H=a});W();W();var Se=require("child_process");function de(e){try{let o=process.platform==="win32"?`where ${e}`:`command -v ${e}`;return(0,Se.execSync)(o,{stdio:"ignore"}),!0}catch{return!1}}var ht={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function Ce(e,o){try{let t=`${e} ${o.join(" ")}`;return(0,Se.execSync)(t,ht),!0}catch{return!1}}function je(e,o){return new Promise(t=>{(0,Se.spawn)(e,o,{stdio:"inherit",shell:!0}).on("close",r=>{t(r)})})}var fo=k(require("readline/promises")),ve=require("process");async function fe(e){let o=fo.default.createInterface({input:ve.stdin,output:ve.stdout});try{return(await o.question(e)).trim()}finally{o.close()}}async function uo(){let e=parseInt(process.version.slice(1).split(".")[0],10);if(console.log(`${a.dim}Step 1/4: Checking Node.js version (current: ${process.version})...${a.reset}`),e<18){console.log(`\u26A0\uFE0F ${a.yellow}Outdated Node.js version detected. v18.0.0 or higher is required.${a.reset}`),console.log(`${a.dim}Note: If you already have a higher version installed via nvm, please run 'nvm use <version>' first.${a.reset}
39
39
  `);let o=await fe("Would you like to install/upgrade Node.js v18+ automatically? (y/N): ");o.toLowerCase()==="y"||o.toLowerCase()==="yes"||(console.log(`
40
40
  \u274C ${a.red}Aborted. Please manually upgrade Node.js to v18+ and try again.${a.reset}
@@ -54,18 +54,18 @@ ${H.green}\u2705 Fetched final config (review mode)${H.reset}`),console.log(`${H
54
54
  \u274C ${a.red}Homebrew package manager (brew) is not installed on this system.${a.reset}`),console.log(`${a.bold}\u{1F449} To proceed, please either:${a.reset}`),console.log(" 1. Install Homebrew by running the following command in your terminal:"),console.log(` ${a.cyan}/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"${a.reset}`),console.log(` 2. Or manually download and install Node.js (v18+) from: https://nodejs.org/
55
55
  `),process.exit(1)):(console.log(`
56
56
  \u274C ${a.red}Please install or update Node.js to v18+ using your system's package manager.${a.reset}
57
- `),process.exit(1))}else console.log(`\u2714 ${a.green}Node.js version (v${e}) is sufficient.${a.reset}`)}W();async function mo(){console.log(`
57
+ `),process.exit(1))}else console.log(`\u2714 ${a.green}Node.js version (v${e}) is sufficient.${a.reset}`)}W();async function go(){console.log(`
58
58
  ${a.dim}Step 2/4: Checking Vercel CLI...${a.reset}`);let e="vercel",o=!1;if(de("vercel"))console.log(`\u2714 ${a.green}Vercel CLI is installed!${a.reset}`);else{console.log(`\u2753 ${a.yellow}Vercel CLI was not found on your system.${a.reset}`);let t=await fe("\u{1F449} Would you like to install Vercel CLI globally? (Y/n): ");t.toLowerCase()==="y"||t===""?(console.log(`
59
59
  \u{1F4E5} ${a.cyan}Installing Vercel CLI globally... (npm install -g vercel)${a.reset}`),Ce("npm",["install","-g","vercel"])&&de("vercel")?console.log(`\u2714 ${a.green}Vercel CLI installed successfully!${a.reset}`):(console.log(`
60
- \u26A0\uFE0F ${a.yellow}Global installation failed or permissions restricted.${a.reset}`),console.log(`\u2139 ${a.dim}Falling back: Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)):(console.log(`\u2139 ${a.dim}Skipping global installation. Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)}return{vercelCmd:e,useNpx:o}}var go=require("child_process");W();var wt={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function po(e){console.log(`
61
- ${a.dim}Step 3/4: Checking Vercel Login...${a.reset}`);let o=!!process.env.VERCEL_TOKEN,t=!1;if(o)console.log(`\u2714 ${a.green}VERCEL_TOKEN environment variable detected. Skipping login check.${a.reset}`),t=!0;else try{(0,go.execSync)(e?"npx --yes vercel whoami":"vercel whoami",wt),t=!0,console.log(`\u2714 ${a.green}Logged in!${a.reset}`)}catch{t=!1}if(!t){console.log(`\u{1F511} ${a.yellow}Not logged in to Vercel.${a.reset}`),await fe("\u{1F449} Press [Enter] to login to Vercel... ");let n=["login"],r=e?"npx":"vercel",i=e?["--yes","vercel",...n]:n;if(await je(r,i)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
60
+ \u26A0\uFE0F ${a.yellow}Global installation failed or permissions restricted.${a.reset}`),console.log(`\u2139 ${a.dim}Falling back: Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)):(console.log(`\u2139 ${a.dim}Skipping global installation. Running Vercel dynamically via npx.${a.reset}`),e="npx --yes vercel",o=!0)}return{vercelCmd:e,useNpx:o}}var mo=require("child_process");W();var wt={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function po(e){console.log(`
61
+ ${a.dim}Step 3/4: Checking Vercel Login...${a.reset}`);let o=!!process.env.VERCEL_TOKEN,t=!1;if(o)console.log(`\u2714 ${a.green}VERCEL_TOKEN environment variable detected. Skipping login check.${a.reset}`),t=!0;else try{(0,mo.execSync)(e?"npx --yes vercel whoami":"vercel whoami",wt),t=!0,console.log(`\u2714 ${a.green}Logged in!${a.reset}`)}catch{t=!1}if(!t){console.log(`\u{1F511} ${a.yellow}Not logged in to Vercel.${a.reset}`),await fe("\u{1F449} Press [Enter] to login to Vercel... ");let n=["login"],r=e?"npx":"vercel",i=e?["--yes","vercel",...n]:n;if(await je(r,i)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
62
62
  \u2714 ${a.green}Logged in successfully!${a.reset}`)}return o}W();async function yo(e,o){console.log(`
63
63
  ${a.dim}Step 4/4: Deploying project to production...${a.reset}`);let t=["--prod","--yes"];o&&t.push("--token",process.env.VERCEL_TOKEN);let n=e?"npx":"vercel",r=e?["--yes","vercel",...t]:t;if(console.log(`${a.cyan}\u26A1 Running deployment in: ${process.cwd()}${a.reset}
64
64
  `),await je(n,r)!==0)throw new Error("Vercel deployment failed.");console.log(`
65
65
  ${a.bold}${a.green}\u{1F389} Deployment completed successfully!${a.reset}
66
66
  `)}async function ho(){console.log(`
67
67
  ${a.bold}${a.cyan}\u{1F680} Starting CFM Vercel Deployment...${a.reset}
68
- `),await uo();let{vercelCmd:e,useNpx:o}=await mo(),t=await po(o);await yo(o,t)}var Pe=k(require("http")),I=k(require("fs")),M=k(require("path"));W();function z(e){return e instanceof Error?e.message:String(e)}Re();var v=k(require("fs")),j=k(require("path"));W();Le();var m=k(require("fs")),u=k(require("path")),jo=require("child_process");Le();function se(e,o){if(m.existsSync(e)){m.mkdirSync(o,{recursive:!0});for(let t of m.readdirSync(e,{withFileTypes:!0})){let n=u.join(e,t.name),r=u.join(o,t.name);t.isDirectory()?se(n,r):m.copyFileSync(n,r)}}}function Ze(e){let o=[],t=e;for(let n=0;n<6;n++){let r=u.join(t,"node_modules");m.existsSync(r)&&o.push(r);let i=u.dirname(t);if(i===t)break;t=i}return o}function At(e,o){let t=Ze(e);for(let n of t)for(let r of["@explorer02/cfm-survey-sdk","@repo/sdk"])for(let i of["mjs","js"]){let s=u.join(n,r,"dist",`index.${i}`);if(m.existsSync(s))return s}for(let n of["mjs","js"]){let r=u.join(o,"dist",`index.${n}`);if(m.existsSync(r))return r}throw new Error("Could not resolve @explorer02/cfm-survey-sdk for preview build")}function Et(e,o){let t=[...Ze(o).map(n=>u.join(n,"vite","bin","vite.js")),u.join(e,"node_modules","vite","bin","vite.js")];for(let n of t)if(m.existsSync(n))return n;throw new Error("Vite is required for agent preview builds. Install vite in the project or SDK package.")}function Ft(e){let o=u.join(e,"src","components");if(!m.existsSync(u.join(o,"Question.tsx")))throw new Error(`Missing src/components/Question.tsx in ${e}. Build the survey UI before export-previews.`);let t=u.join(e,"src","lib"),n=u.join(e,"public");return{componentsDir:o,libDir:m.existsSync(t)?t:void 0,publicDir:m.existsSync(n)?n:void 0}}function Pt(e,o){let t=u.join(e,"templates","docs","templates"),n=u.join(o,"agent","src","components"),r=u.join(o,"agent","src","lib","surveyUi");m.mkdirSync(r,{recursive:!0});let i=["Question.tsx","RatingScale.tsx","LikertMatrixScale.tsx","CsatMatrixScale.tsx","SliderMatrixScale.tsx","CustomSliderTrack.tsx","MatrixDropdown.tsx","FileUploadScale.tsx","HeatmapScale.tsx","RankOrderScale.tsx","surveyUiScaleUtils.ts","surveyUiIcons.tsx","Header.tsx","ProgressBar.tsx","Footer.tsx","LanguageSelector.tsx","SurveyStickyChrome.tsx"];for(let d of i){let g=u.join(t,d);m.existsSync(g)&&m.copyFileSync(g,u.join(n,d))}let s=["selectionStyles.ts","labelStyles.ts","heatmapCoords.ts"];for(let d of s){let g=u.join(t,d);m.existsSync(g)&&m.copyFileSync(g,u.join(r,d))}let c=u.join(t,"heatmapCoords.ts");m.existsSync(c)&&m.copyFileSync(c,u.join(n,"heatmapCoords.ts"))}function It(e){let o=`import React from 'react';
68
+ `),await uo();let{vercelCmd:e,useNpx:o}=await go(),t=await po(o);await yo(o,t)}var Pe=k(require("http")),I=k(require("fs")),O=k(require("path"));W();function z(e){return e instanceof Error?e.message:String(e)}Re();var v=k(require("fs")),j=k(require("path"));W();Le();var g=k(require("fs")),u=k(require("path")),jo=require("child_process");Le();function se(e,o){if(g.existsSync(e)){g.mkdirSync(o,{recursive:!0});for(let t of g.readdirSync(e,{withFileTypes:!0})){let n=u.join(e,t.name),r=u.join(o,t.name);t.isDirectory()?se(n,r):g.copyFileSync(n,r)}}}function Ze(e){let o=[],t=e;for(let n=0;n<6;n++){let r=u.join(t,"node_modules");g.existsSync(r)&&o.push(r);let i=u.dirname(t);if(i===t)break;t=i}return o}function Et(e,o){let t=Ze(e);for(let n of t)for(let r of["@explorer02/cfm-survey-sdk","@repo/sdk"])for(let i of["mjs","js"]){let s=u.join(n,r,"dist",`index.${i}`);if(g.existsSync(s))return s}for(let n of["mjs","js"]){let r=u.join(o,"dist",`index.${n}`);if(g.existsSync(r))return r}throw new Error("Could not resolve @explorer02/cfm-survey-sdk for preview build")}function At(e,o){let t=[...Ze(o).map(n=>u.join(n,"vite","bin","vite.js")),u.join(e,"node_modules","vite","bin","vite.js")];for(let n of t)if(g.existsSync(n))return n;throw new Error("Vite is required for agent preview builds. Install vite in the project or SDK package.")}function Ft(e){let o=u.join(e,"src","components");if(!g.existsSync(u.join(o,"Question.tsx")))throw new Error(`Missing src/components/Question.tsx in ${e}. Build the survey UI before export-previews.`);let t=u.join(e,"src","lib"),n=u.join(e,"public");return{componentsDir:o,libDir:g.existsSync(t)?t:void 0,publicDir:g.existsSync(n)?n:void 0}}function Pt(e,o){let t=u.join(e,"templates","docs","templates"),n=u.join(o,"agent","src","components"),r=u.join(o,"agent","src","lib","surveyUi");g.mkdirSync(r,{recursive:!0});let i=["Question.tsx","RatingScale.tsx","LikertMatrixScale.tsx","CsatMatrixScale.tsx","SliderMatrixScale.tsx","CustomSliderTrack.tsx","MatrixDropdown.tsx","FileUploadScale.tsx","HeatmapScale.tsx","RankOrderScale.tsx","surveyUiScaleUtils.ts","surveyUiIcons.tsx","Header.tsx","ProgressBar.tsx","Footer.tsx","LanguageSelector.tsx","SurveyStickyChrome.tsx"];for(let d of i){let m=u.join(t,d);g.existsSync(m)&&g.copyFileSync(m,u.join(n,d))}let s=["selectionStyles.ts","labelStyles.ts","heatmapCoords.ts"];for(let d of s){let m=u.join(t,d);g.existsSync(m)&&g.copyFileSync(m,u.join(r,d))}let c=u.join(t,"heatmapCoords.ts");g.existsSync(c)&&g.copyFileSync(c,u.join(n,"heatmapCoords.ts"))}function It(e){let o=`import React from 'react';
69
69
  import { mountPreview } from '../mount';
70
70
  `;switch(e){case"header":return`${o}import Header from '@/components/Header';
71
71
  import ProgressBar from '@/components/ProgressBar';
@@ -86,7 +86,7 @@ mountPreview(<Footer />);`;default:return`${o}import { QuestionPreview } from '.
86
86
  import { PREVIEW_FIXTURES } from '../fixtures/questions';
87
87
  const question = PREVIEW_FIXTURES[${JSON.stringify(e)}];
88
88
  if (!question) throw new Error('Missing fixture for ${e}');
89
- mountPreview(<QuestionPreview question={question} />);`}}function Nt(e,o,t,n){let r=At(o,t),i=n.map(c=>` '${c}': path.resolve(workDir, '${c}', 'index.html'),`).join(`
89
+ mountPreview(<QuestionPreview question={question} />);`}}function Nt(e,o,t,n){let r=Et(o,t),i=n.map(c=>` '${c}': path.resolve(workDir, '${c}', 'index.html'),`).join(`
90
90
  `),s=`import path from 'path';
91
91
  import { fileURLToPath } from 'url';
92
92
  import { defineConfig } from 'vite';
@@ -121,9 +121,9 @@ ${i}
121
121
  },
122
122
  },
123
123
  });
124
- `;m.writeFileSync(u.join(e,"vite.config.mjs"),s)}function jt(e,o){let t=m.readFileSync(e,"utf8");if(t.includes("preview-bridge.inline"))return;let n=`<script>${o}</script>`;t=t.includes("</body>")?t.replace("</body>",`${n}
124
+ `;g.writeFileSync(u.join(e,"vite.config.mjs"),s)}function jt(e,o){let t=g.readFileSync(e,"utf8");if(t.includes("preview-bridge.inline"))return;let n=`<script>${o}</script>`;t=t.includes("</body>")?t.replace("</body>",`${n}
125
125
  </body>`):`${t}
126
- ${n}`,m.writeFileSync(e,t)}function vt(e){return e.replace(/_/g," ")}async function vo(e){let{projectRoot:o,outputDir:t,keys:n}=e,r=u.join(__dirname,"..",".."),i=u.join(r,"templates","preview-harness","vite-app");if(!m.existsSync(i))throw new Error(`Missing Vite preview harness template at ${i}`);let s=Ft(o),c=u.join(t,".preview-vite-work");m.existsSync(c)&&m.rmSync(c,{recursive:!0,force:!0}),se(i,c),m.mkdirSync(u.join(c,"agent","src"),{recursive:!0}),se(s.componentsDir,u.join(c,"agent","src","components")),s.libDir&&se(s.libDir,u.join(c,"agent","src","lib")),s.publicDir&&se(s.publicDir,u.join(c,"agent","public")),Pt(r,c);let d=u.join(o,"survey-ui-config.json");m.existsSync(d)&&m.copyFileSync(d,u.join(c,"agent","survey-ui-config.json"));let g=ue(o),w=u.join(c,"src","survey-theme.css");m.writeFileSync(w,g?m.readFileSync(g,"utf8"):m.readFileSync(u.join(r,"templates","survey-theme.css"),"utf8")),m.mkdirSync(u.join(c,"src","entries"),{recursive:!0});for(let T of n)m.mkdirSync(u.join(c,T),{recursive:!0}),m.writeFileSync(u.join(c,T,"index.html"),`<!DOCTYPE html>
126
+ ${n}`,g.writeFileSync(e,t)}function vt(e){return e.replace(/_/g," ")}async function vo(e){let{projectRoot:o,outputDir:t,keys:n}=e,r=u.join(__dirname,"..",".."),i=u.join(r,"templates","preview-harness","vite-app");if(!g.existsSync(i))throw new Error(`Missing Vite preview harness template at ${i}`);let s=Ft(o),c=u.join(t,".preview-vite-work");g.existsSync(c)&&g.rmSync(c,{recursive:!0,force:!0}),se(i,c),g.mkdirSync(u.join(c,"agent","src"),{recursive:!0}),se(s.componentsDir,u.join(c,"agent","src","components")),s.libDir&&se(s.libDir,u.join(c,"agent","src","lib")),s.publicDir&&se(s.publicDir,u.join(c,"agent","public")),Pt(r,c);let d=u.join(o,"survey-ui-config.json");g.existsSync(d)&&g.copyFileSync(d,u.join(c,"agent","survey-ui-config.json"));let m=ue(o),b=u.join(c,"src","survey-theme.css");g.writeFileSync(b,m?g.readFileSync(m,"utf8"):g.readFileSync(u.join(r,"templates","survey-theme.css"),"utf8")),g.mkdirSync(u.join(c,"src","entries"),{recursive:!0});for(let T of n)g.mkdirSync(u.join(c,T),{recursive:!0}),g.writeFileSync(u.join(c,T,"index.html"),`<!DOCTYPE html>
127
127
  <html lang="en">
128
128
  <head>
129
129
  <meta charset="UTF-8" />
@@ -134,21 +134,21 @@ ${n}`,m.writeFileSync(e,t)}function vt(e){return e.replace(/_/g," ")}async funct
134
134
  <div id="root"></div>
135
135
  <script type="module" src="../src/entries/${T}.tsx"></script>
136
136
  </body>
137
- </html>`),m.writeFileSync(u.join(c,"src","entries",`${T}.tsx`),It(T));m.writeFileSync(u.join(c,"tsconfig.json"),JSON.stringify({compilerOptions:{target:"ES2020",lib:["ES2020","DOM","DOM.Iterable"],module:"ESNext",moduleResolution:"bundler",jsx:"react-jsx",strict:!0,skipLibCheck:!0,paths:{"@/*":["./agent/src/*"]}},include:["src","agent/src","stubs"]},null,2)),Nt(c,o,r,n);let S=Et(r,o),x=Ze(o).join(u.delimiter);(0,jo.execSync)(`node "${S}" build --config "${u.join(c,"vite.config.mjs")}"`,{cwd:c,stdio:"inherit",env:{...process.env,NODE_PATH:x}});let F=u.join(t,"previews");m.mkdirSync(F,{recursive:!0});let E=u.join(c,"dist"),R=m.readFileSync(u.join(r,"templates","preview-harness","preview-bridge.inline.js"),"utf8");for(let T of n){let $=u.join(E,T),h=u.join(F,T);if(!m.existsSync(u.join($,"index.html")))throw new Error(`Vite build did not produce ${T}/index.html`);m.existsSync(h)&&m.rmSync(h,{recursive:!0,force:!0}),se($,h),jt(u.join(h,"index.html"),R)}let f=u.join(E,"assets");m.existsSync(f)&&se(f,u.join(F,"assets"));let y=u.join(c,"agent","public");if(m.existsSync(y))for(let T of m.readdirSync(y)){let $=u.join(y,T);m.statSync($).isFile()&&m.copyFileSync($,u.join(F,T))}m.rmSync(c,{recursive:!0,force:!0})}var eo=k(require("fs")),oo=k(require("path"));function Oe(e){if(e)return e;let o=process.cwd();if(eo.existsSync(oo.join(o,"src","components","Question.tsx")))return o;let t=process.env.INIT_CWD;return t&&eo.existsSync(oo.join(t,"src","components","Question.tsx"))?t:o}var _o=["header","footer","survey_page"],Do={MCQ:["MCQ_single","MCQ_multiple"],TEXTFIELD:["TEXTFIELD_short","TEXTFIELD_long"],NPS_SCALE:["NPS_SCALE"],CFM_MATRIX:["CFM_likert","CFM_bipolar","CFM_transpose","CFM_carousel","CFM_dropdown"],TEXT_AND_MEDIA:["TEXT_AND_MEDIA"],CSAT_MATRIX:["CSAT_emoji","CSAT_star","CSAT_numbered","CSAT_graphics","CSAT_carousel","CSAT_dropdown"],RATING_MATRIX:["RATING_star","RATING_numbered","RATING_radio","RATING_emoji","RATING_graphics","RATING_slider"],SLIDER_MATRIX:["SLIDER_matrix"],FILE_UPLOAD:["FILE_UPLOAD"],HEATMAP:["HEATMAP"],RANK_ORDER:["RANK_drag","RANK_dropdown"]},ur=[..._o,...Object.values(Do).flat()];function Lo(e){let o=new Set(_o);for(let t of e)for(let n of Do[t]??[])o.add(n);return[...o]}var U=a;function _t(){return j.join(__dirname,"..","..","templates")}function Dt(e){let o=v.readFileSync(e,"utf8"),t=new Set,n=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];for(let r of n)o.includes(r)&&t.add(r);return t.size?[...t]:n}function Lt(e,o){let t=new Set(Lo(o));return e.filter(n=>t.has(n))}function to(e,o,t){if(v.existsSync(e))for(let n of v.readdirSync(e)){let r=j.join(e,n),i=j.posix.join(o,n);if(v.statSync(r).isDirectory())to(r,i,t);else{let s=j.extname(n).toLowerCase(),c=s===".html"?"text/html":s===".css"?"text/css":s===".js"?"application/javascript":s===".json"?"application/json":s===".svg"?"image/svg+xml":s===".jpg"||s===".jpeg"?"image/jpeg":s===".png"?"image/png":"application/octet-stream";t.push({path:i,contentType:c,sizeBytes:v.statSync(r).size})}}}async function pe(e={}){let o=Oe(e.projectRoot),t=e.outputDir??j.join(o,"out"),n=_t(),r=j.join(n,"preview-harness");e.useTemplatesOnly&&console.log(`${U.dim} Using SDK template preview harness only (--use-templates-only)${U.reset}`);let i=j.join(r,"previewPages.js"),{PREVIEW_PAGE_DEFS:s,buildPreviewHtml:c,PREVIEW_KEYS:d}=require(i),g=(()=>{let f=ue(o);return f?(console.log(`${U.dim} Using project theme: ${j.relative(o,f)}${U.reset}`),v.readFileSync(f,"utf8")):v.readFileSync(j.join(n,"survey-theme.css"),"utf8")})(),w=v.readFileSync(j.join(r,"preview-bridge.inline.js"),"utf8"),S=e.surveyTypes;if(!S){let f=j.join(o,"implementation_plan.md");S=v.existsSync(f)?Dt(f):["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]}let x=Lt(d,S),F=j.join(t,"previews");if(v.existsSync(F)&&(v.rmSync(F,{recursive:!0,force:!0}),console.log(`${U.dim} Cleared previous preview output${U.reset}`)),v.mkdirSync(F,{recursive:!0}),!e.useTemplatesOnly)try{console.log(`${U.dim} Building previews from agent components (Vite)\u2026${U.reset}`),await vo({projectRoot:o,outputDir:t,keys:x});let f={};for(let T of x)f[T]=`previews/${T}/index.html`;v.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(f,null,2));let y=[];return to(j.join(t,"previews"),"previews",y),console.log(`${U.green}\u2705 Exported ${x.length} agent component previews \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:y,surveyTypes:S}}catch(f){console.warn(`${U.yellow}\u26A0 Agent Vite preview build failed; falling back to template harness.${U.reset}`),console.warn(`${U.dim} ${z(f)}${U.reset}`)}for(let f of s){if(!x.includes(f.key))continue;let y=j.join(t,"previews",f.key);v.mkdirSync(y,{recursive:!0}),v.writeFileSync(j.join(y,"index.html"),c(f,g,w))}let E={};for(let f of x)E[f]=`previews/${f}/index.html`;v.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(E,null,2));let R=[];return to(j.join(t,"previews"),"previews",R),console.log(`${U.green}\u2705 Exported ${x.length} preview pages \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:R,surveyTypes:S}}var N=a,Fe=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];function Ko(e){return new Promise(o=>{let t=Pe.createServer();t.listen(e,()=>{t.close(()=>o(e))}),t.on("error",()=>o(Ko(e+1)))})}function Go(e){return new Promise((o,t)=>{let n="";e.on("data",r=>n+=r),e.on("end",()=>o(n)),e.on("error",t)})}function fn(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function Qo(e){let o=M.extname(e).toLowerCase();return{".html":"text/html",".js":"application/javascript",".css":"text/css",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".woff2":"font/woff2",".ico":"image/x-icon"}[o]??"application/octet-stream"}function un(e){let o=new Set,t,n=e.match(/\*\*instanceId:\*\*\s*(.+)/i);if(n){let i=n[1].replace(/[()[\]]/g,"").trim();i&&!i.startsWith("(")&&i!=="JWT"&&(t=i)}for(let i of Fe)e.includes(i)&&o.add(i);let r=e.matchAll(/\|\s*`([A-Z_]+)`\s*\|/g);for(let i of r)Fe.includes(i[1])&&o.add(i[1]);return{surveyTypes:o.size>0?[...o]:[...Fe],instanceId:t}}async function mn(e){return new Promise(o=>{try{let t=Pe.get(e,n=>{o((n.statusCode??500)<500),n.resume()});t.on("error",()=>o(!1)),t.setTimeout(2e3,()=>{t.destroy(),o(!1)})}catch{o(!1)}})}function co(e){let o=M.join(e,"out","previews");I.existsSync(o)&&(I.rmSync(o,{recursive:!0,force:!0}),console.log(`${N.dim} Removed local preview files: out/previews/${N.reset}`))}async function Yo(){let e=process.env.INIT_CWD||process.cwd(),o=M.join(e,"public"),t=M.join(e,"survey-ui-config.json"),n=M.join(e,"implementation_plan.md"),r=M.join(__dirname,"..","..","templates"),i=M.join(r,"wizard-dist"),s=process.env.CFM_PREVIEW_URL??"http://localhost:3000",c={},d=M.join(e,"out","previews"),g=M.join(d,"manifest.json");console.log(`${N.dim} Exporting component previews for local wizard\u2026${N.reset}`),await pe({projectRoot:e,surveyTypes:[...Fe]}),I.existsSync(g)&&(c=JSON.parse(I.readFileSync(g,"utf8")));let w=await Ko(4200),S=`http://localhost:${w}`;return new Promise((x,F)=>{let E=Pe.createServer(async(f,y)=>{try{let T=f.url??"/";if(f.method==="GET"&&T==="/api/inventory"){let $;if(I.existsSync(n)){let C=I.readFileSync(n,"utf8");$=un(C).instanceId}if(I.existsSync(t))try{let C=JSON.parse(I.readFileSync(t,"utf8"));C.instanceId&&($=C.instanceId)}catch{}let h=[...Fe],{config:P}=ge({projectRoot:e,surveyTypes:h,instanceId:$});y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({surveyTypes:h,instanceId:$,previewUrl:s,initialConfig:P,previewManifest:Object.fromEntries(Object.keys(c).map(C=>[C,`${S}/previews/${C}/index.html`]))}));return}if(f.method==="GET"&&T==="/api/preview-url"){let $=await mn(s);y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({url:s,connected:$}));return}if(f.method==="POST"&&T.split("?")[0]==="/api/wizard-quit"){co(e),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({ok:!0,deleted:"out/previews"})),setTimeout(()=>{E.close(()=>{F(new Error("Client quit the wizard without saving. Local preview garbage collection complete (out/previews removed)."))})},300);return}if(f.method==="POST"&&T==="/api/upload-logo"){let $=await Go(f),h=JSON.parse($);I.existsSync(o)||I.mkdirSync(o,{recursive:!0});let P=h.base64.replace(/^data:image\/\w+;base64,/,""),C=Buffer.from(P,"base64"),B=M.extname(h.filename),V=M.basename(h.filename,B).toLowerCase().replace(/[^a-z0-9_-]/g,""),ie=`logo_${Date.now()}_${V}${B||".png"}`;I.writeFileSync(M.join(o,ie),C),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({fileName:ie}));return}if(f.method==="POST"&&T==="/api/save-config"){let $=await Go(f),h=JSON.parse($);h.configuredAt=new Date().toISOString();let P=h.global?.logo;P?.url?.startsWith("data:")&&(P.url=null),I.writeFileSync(t,JSON.stringify(h,null,2),"utf8"),console.log(`
138
- ${N.green}\u2705 UI configuration saved to ${t}${N.reset}`);try{let{runApplyUiConfig:C}=await Promise.resolve().then(()=>(Ee(),Ae));C({projectRoot:e,configPath:t})}catch(C){console.log(`${N.yellow} CSS apply skipped: ${C instanceof Error?C.message:String(C)}${N.reset}`)}co(e),console.log(`${N.dim} Local preview garbage collection complete (out/previews removed)${N.reset}`),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({ok:!0})),setTimeout(()=>{E.close(()=>x())},500);return}if(f.method==="GET"){let $=T.split("?")[0];if($==="/"&&($="/index.html"),$.startsWith("/previews/")&&I.existsSync(d)){let C=$.replace(/^\/previews\//,""),B=M.join(d,C),V=M.normalize(B);if(V.startsWith(d)&&I.existsSync(V)&&I.statSync(V).isFile()){let ie=I.readFileSync(V);y.writeHead(200,{"Content-Type":Qo(V)}),y.end(ie);return}}let h=I.existsSync(i),P=h?M.join(i,$):M.join(r,"wizard.html");if(h&&I.existsSync(P)&&I.statSync(P).isFile()){let C=I.readFileSync(P);y.writeHead(200,{"Content-Type":Qo(P)}),y.end(C);return}if(!h&&$==="/index.html"){let C=I.readFileSync(M.join(r,"wizard.html"),"utf8");y.writeHead(200,{"Content-Type":"text/html"}),y.end(C);return}}y.writeHead(404,{"Content-Type":"text/plain"}),y.end("Not found")}catch(T){y.writeHead(500,{"Content-Type":"text/plain"}),y.end(`Server error: ${z(T)}`)}});E.listen(w,()=>{let f=S;console.log(`
139
- ${N.bold}${N.cyan}\u{1F3A8} Survey UI Customization Wizard${N.reset}`),console.log(`${N.bold}\u{1F517} Client wizard link \u2014 share this URL only:${N.reset}`),console.log(` ${N.green}${f}${N.reset}`),console.log(`${N.dim} Port ${w} (auto-selected if 4200 was in use)${N.reset}`),console.log(`${N.dim} Live previews: ${N.reset}${Object.keys(c).length} components`),console.log(`${N.dim} Preview target: ${N.reset}${s}`),console.log(`${N.dim} Default wizard \u2014 saves directly to survey-ui-config.json when client clicks Review & Build${N.reset}
140
- `),fn(f)}),E.on("error",F);let R=()=>{co(e),E.close(()=>process.exit(130))};process.once("SIGINT",R),process.once("SIGTERM",R)})}var be=k(require("fs")),tt=k(require("path")),nt=k(require("http")),rt=k(require("https"));W();Te();Re();ke();Ve();var p=a;function pn(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function yn(e){return new Promise(o=>setTimeout(o,e))}async function lo(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?rt:nt).request(r,{method:o.method??"GET",headers:o.headers??{}},c=>{let d="";c.on("data",g=>d+=g),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),o.body&&s.write(o.body),s.end()})}async function hn(e,o,t,n){return new Promise((r,i)=>{let s=new URL(e),c=s.protocol==="https:"?rt:nt,d={"Content-Type":t,"Content-Length":o.length};n&&(d["X-Wizard-Session"]=n.sessionSecret,d["X-Wizard-Session-Id"]=n.sessionId);let g=c.request(s,{method:"PUT",headers:d},w=>{if((w.statusCode??500)>=400){let S="";w.on("data",x=>S+=x),w.on("end",()=>i(new Error(`PUT failed ${w.statusCode}: ${S}`)));return}w.resume(),r()});g.on("error",i),g.write(o),g.end()})}function wn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function it(e={}){let o=e.wait!==!1,t=e.pollIntervalMs??Number(process.env.CFM_WIZARD_POLL_MS??3e3),n=e.timeoutMs??Number(process.env.CFM_WIZARD_TIMEOUT_MS??72e5),r=process.env.CFM_INSTANCE_ID,i=(process.env.CFM_DEPLOY_API_BASE??"http://localhost:3000").replace(/\/$/,"");if(!r)throw new Error("CFM_INSTANCE_ID (JWT) is required");let s=wn(r);if(!s)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let c=Oe(),d=ne(c),g=d.activeConfigPath,w=e.apply?!1:e.review!==!1;console.log(`
137
+ </html>`),g.writeFileSync(u.join(c,"src","entries",`${T}.tsx`),It(T));g.writeFileSync(u.join(c,"tsconfig.json"),JSON.stringify({compilerOptions:{target:"ES2020",lib:["ES2020","DOM","DOM.Iterable"],module:"ESNext",moduleResolution:"bundler",jsx:"react-jsx",strict:!0,skipLibCheck:!0,paths:{"@/*":["./agent/src/*"]}},include:["src","agent/src","stubs"]},null,2)),Nt(c,o,r,n);let S=At(r,o),x=Ze(o).join(u.delimiter);(0,jo.execSync)(`node "${S}" build --config "${u.join(c,"vite.config.mjs")}"`,{cwd:c,stdio:"inherit",env:{...process.env,NODE_PATH:x}});let F=u.join(t,"previews");g.mkdirSync(F,{recursive:!0});let A=u.join(c,"dist"),R=g.readFileSync(u.join(r,"templates","preview-harness","preview-bridge.inline.js"),"utf8");for(let T of n){let $=u.join(A,T),w=u.join(F,T);if(!g.existsSync(u.join($,"index.html")))throw new Error(`Vite build did not produce ${T}/index.html`);g.existsSync(w)&&g.rmSync(w,{recursive:!0,force:!0}),se($,w),jt(u.join(w,"index.html"),R)}let f=u.join(A,"assets");g.existsSync(f)&&se(f,u.join(F,"assets"));let y=u.join(c,"agent","public");if(g.existsSync(y))for(let T of g.readdirSync(y)){let $=u.join(y,T);g.statSync($).isFile()&&g.copyFileSync($,u.join(F,T))}g.rmSync(c,{recursive:!0,force:!0})}var eo=k(require("fs")),oo=k(require("path"));function Me(e){if(e)return e;let o=process.cwd();if(eo.existsSync(oo.join(o,"src","components","Question.tsx")))return o;let t=process.env.INIT_CWD;return t&&eo.existsSync(oo.join(t,"src","components","Question.tsx"))?t:o}var _o=["header","footer","survey_page"],Do={MCQ:["MCQ_single","MCQ_multiple"],TEXTFIELD:["TEXTFIELD_short","TEXTFIELD_long"],NPS_SCALE:["NPS_SCALE"],CFM_MATRIX:["CFM_likert","CFM_bipolar"],TEXT_AND_MEDIA:["TEXT_AND_MEDIA"],CSAT_MATRIX:["CSAT_emoji","CSAT_star","CSAT_numbered","CSAT_graphics"],RATING_MATRIX:["RATING_star","RATING_numbered","RATING_radio","RATING_emoji","RATING_graphics"],SLIDER_MATRIX:["SLIDER_matrix"],FILE_UPLOAD:["FILE_UPLOAD"],HEATMAP:["HEATMAP"],RANK_ORDER:["RANK_drag","RANK_dropdown"]},ur=[..._o,...Object.values(Do).flat()];function Lo(e){let o=new Set(_o);for(let t of e)for(let n of Do[t]??[])o.add(n);return[...o]}var U=a;function _t(){return j.join(__dirname,"..","..","templates")}function Dt(e){let o=v.readFileSync(e,"utf8"),t=new Set,n=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];for(let r of n)o.includes(r)&&t.add(r);return t.size?[...t]:n}function Lt(e,o){let t=new Set(Lo(o));return e.filter(n=>t.has(n))}function to(e,o,t){if(v.existsSync(e))for(let n of v.readdirSync(e)){let r=j.join(e,n),i=j.posix.join(o,n);if(v.statSync(r).isDirectory())to(r,i,t);else{let s=j.extname(n).toLowerCase(),c=s===".html"?"text/html":s===".css"?"text/css":s===".js"?"application/javascript":s===".json"?"application/json":s===".svg"?"image/svg+xml":s===".jpg"||s===".jpeg"?"image/jpeg":s===".png"?"image/png":"application/octet-stream";t.push({path:i,contentType:c,sizeBytes:v.statSync(r).size})}}}async function pe(e={}){let o=Me(e.projectRoot),t=e.outputDir??j.join(o,"out"),n=_t(),r=j.join(n,"preview-harness");e.useTemplatesOnly&&console.log(`${U.dim} Using SDK template preview harness only (--use-templates-only)${U.reset}`);let i=j.join(r,"previewPages.js"),{PREVIEW_PAGE_DEFS:s,buildPreviewHtml:c,PREVIEW_KEYS:d}=require(i),m=(()=>{let f=ue(o);return f?(console.log(`${U.dim} Using project theme: ${j.relative(o,f)}${U.reset}`),v.readFileSync(f,"utf8")):v.readFileSync(j.join(n,"survey-theme.css"),"utf8")})(),b=v.readFileSync(j.join(r,"preview-bridge.inline.js"),"utf8"),S=e.surveyTypes;if(!S){let f=j.join(o,"implementation_plan.md");S=v.existsSync(f)?Dt(f):["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]}let x=Lt(d,S),F=j.join(t,"previews");if(v.existsSync(F)&&(v.rmSync(F,{recursive:!0,force:!0}),console.log(`${U.dim} Cleared previous preview output${U.reset}`)),v.mkdirSync(F,{recursive:!0}),!e.useTemplatesOnly)try{console.log(`${U.dim} Building previews from agent components (Vite)\u2026${U.reset}`),await vo({projectRoot:o,outputDir:t,keys:x});let f={};for(let T of x)f[T]=`previews/${T}/index.html`;v.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(f,null,2));let y=[];return to(j.join(t,"previews"),"previews",y),console.log(`${U.green}\u2705 Exported ${x.length} agent component previews \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:y,surveyTypes:S}}catch(f){console.warn(`${U.yellow}\u26A0 Agent Vite preview build failed; falling back to template harness.${U.reset}`),console.warn(`${U.dim} ${z(f)}${U.reset}`)}for(let f of s){if(!x.includes(f.key))continue;let y=j.join(t,"previews",f.key);v.mkdirSync(y,{recursive:!0}),v.writeFileSync(j.join(y,"index.html"),c(f,m,b))}let A={};for(let f of x)A[f]=`previews/${f}/index.html`;v.writeFileSync(j.join(t,"previews","manifest.json"),JSON.stringify(A,null,2));let R=[];return to(j.join(t,"previews"),"previews",R),console.log(`${U.green}\u2705 Exported ${x.length} preview pages \u2192 ${t}${U.reset}`),{outputDir:t,manifestPath:j.join(t,"previews","manifest.json"),files:R,surveyTypes:S}}var N=a,Fe=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];function Ko(e){return new Promise(o=>{let t=Pe.createServer();t.listen(e,()=>{t.close(()=>o(e))}),t.on("error",()=>o(Ko(e+1)))})}function Qo(e){return new Promise((o,t)=>{let n="";e.on("data",r=>n+=r),e.on("end",()=>o(n)),e.on("error",t)})}function fn(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function Go(e){let o=O.extname(e).toLowerCase();return{".html":"text/html",".js":"application/javascript",".css":"text/css",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".woff2":"font/woff2",".ico":"image/x-icon"}[o]??"application/octet-stream"}function un(e){let o=new Set,t,n=e.match(/\*\*instanceId:\*\*\s*(.+)/i);if(n){let i=n[1].replace(/[()[\]]/g,"").trim();i&&!i.startsWith("(")&&i!=="JWT"&&(t=i)}for(let i of Fe)e.includes(i)&&o.add(i);let r=e.matchAll(/\|\s*`([A-Z_]+)`\s*\|/g);for(let i of r)Fe.includes(i[1])&&o.add(i[1]);return{surveyTypes:o.size>0?[...o]:[...Fe],instanceId:t}}async function gn(e){return new Promise(o=>{try{let t=Pe.get(e,n=>{o((n.statusCode??500)<500),n.resume()});t.on("error",()=>o(!1)),t.setTimeout(2e3,()=>{t.destroy(),o(!1)})}catch{o(!1)}})}function co(e){let o=O.join(e,"out","previews");I.existsSync(o)&&(I.rmSync(o,{recursive:!0,force:!0}),console.log(`${N.dim} Removed local preview files: out/previews/${N.reset}`))}async function Yo(){let e=process.env.INIT_CWD||process.cwd(),o=O.join(e,"public"),t=O.join(e,"survey-ui-config.json"),n=O.join(e,"implementation_plan.md"),r=O.join(__dirname,"..","..","templates"),i=O.join(r,"wizard-dist"),s=process.env.CFM_PREVIEW_URL??"http://localhost:3000",c={},d=O.join(e,"out","previews"),m=O.join(d,"manifest.json");console.log(`${N.dim} Exporting component previews for local wizard\u2026${N.reset}`),await pe({projectRoot:e,surveyTypes:[...Fe]}),I.existsSync(m)&&(c=JSON.parse(I.readFileSync(m,"utf8")));let b=await Ko(4200),S=`http://localhost:${b}`;return new Promise((x,F)=>{let A=Pe.createServer(async(f,y)=>{try{let T=f.url??"/";if(f.method==="GET"&&T==="/api/inventory"){let $;if(I.existsSync(n)){let C=I.readFileSync(n,"utf8");$=un(C).instanceId}if(I.existsSync(t))try{let C=JSON.parse(I.readFileSync(t,"utf8"));C.instanceId&&($=C.instanceId)}catch{}let w=[...Fe],{config:P}=me({projectRoot:e,surveyTypes:w,instanceId:$});y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({surveyTypes:w,instanceId:$,previewUrl:s,initialConfig:P,previewManifest:Object.fromEntries(Object.keys(c).map(C=>[C,`${S}/previews/${C}/index.html`]))}));return}if(f.method==="GET"&&T==="/api/preview-url"){let $=await gn(s);y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({url:s,connected:$}));return}if(f.method==="POST"&&T.split("?")[0]==="/api/wizard-quit"){co(e),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({ok:!0,deleted:"out/previews"})),setTimeout(()=>{A.close(()=>{F(new Error("Client quit the wizard without saving. Local preview garbage collection complete (out/previews removed)."))})},300);return}if(f.method==="POST"&&T==="/api/upload-logo"){let $=await Qo(f),w=JSON.parse($);I.existsSync(o)||I.mkdirSync(o,{recursive:!0});let P=w.base64.replace(/^data:image\/\w+;base64,/,""),C=Buffer.from(P,"base64"),B=O.extname(w.filename),V=O.basename(w.filename,B).toLowerCase().replace(/[^a-z0-9_-]/g,""),ie=`logo_${Date.now()}_${V}${B||".png"}`;I.writeFileSync(O.join(o,ie),C),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({fileName:ie}));return}if(f.method==="POST"&&T==="/api/save-config"){let $=await Qo(f),w=JSON.parse($);w.configuredAt=new Date().toISOString();let P=w.global?.logo;P?.url?.startsWith("data:")&&(P.url=null),I.writeFileSync(t,JSON.stringify(w,null,2),"utf8"),console.log(`
138
+ ${N.green}\u2705 UI configuration saved to ${t}${N.reset}`);try{let{runApplyUiConfig:C}=await Promise.resolve().then(()=>(Ae(),Ee));C({projectRoot:e,configPath:t})}catch(C){console.log(`${N.yellow} CSS apply skipped: ${C instanceof Error?C.message:String(C)}${N.reset}`)}co(e),console.log(`${N.dim} Local preview garbage collection complete (out/previews removed)${N.reset}`),y.writeHead(200,{"Content-Type":"application/json"}),y.end(JSON.stringify({ok:!0})),setTimeout(()=>{A.close(()=>x())},500);return}if(f.method==="GET"){let $=T.split("?")[0];if($==="/"&&($="/index.html"),$.startsWith("/previews/")&&I.existsSync(d)){let C=$.replace(/^\/previews\//,""),B=O.join(d,C),V=O.normalize(B);if(V.startsWith(d)&&I.existsSync(V)&&I.statSync(V).isFile()){let ie=I.readFileSync(V);y.writeHead(200,{"Content-Type":Go(V)}),y.end(ie);return}}let w=I.existsSync(i),P=w?O.join(i,$):O.join(r,"wizard.html");if(w&&I.existsSync(P)&&I.statSync(P).isFile()){let C=I.readFileSync(P);y.writeHead(200,{"Content-Type":Go(P)}),y.end(C);return}if(!w&&$==="/index.html"){let C=I.readFileSync(O.join(r,"wizard.html"),"utf8");y.writeHead(200,{"Content-Type":"text/html"}),y.end(C);return}}y.writeHead(404,{"Content-Type":"text/plain"}),y.end("Not found")}catch(T){y.writeHead(500,{"Content-Type":"text/plain"}),y.end(`Server error: ${z(T)}`)}});A.listen(b,()=>{let f=S;console.log(`
139
+ ${N.bold}${N.cyan}\u{1F3A8} Survey UI Customization Wizard${N.reset}`),console.log(`${N.bold}\u{1F517} Client wizard link \u2014 share this URL only:${N.reset}`),console.log(` ${N.green}${f}${N.reset}`),console.log(`${N.dim} Port ${b} (auto-selected if 4200 was in use)${N.reset}`),console.log(`${N.dim} Live previews: ${N.reset}${Object.keys(c).length} components`),console.log(`${N.dim} Preview target: ${N.reset}${s}`),console.log(`${N.dim} Default wizard \u2014 saves directly to survey-ui-config.json when client clicks Review & Build${N.reset}
140
+ `),fn(f)}),A.on("error",F);let R=()=>{co(e),A.close(()=>process.exit(130))};process.once("SIGINT",R),process.once("SIGTERM",R)})}var be=k(require("fs")),tt=k(require("path")),nt=k(require("http")),rt=k(require("https"));W();Te();Re();ke();Ve();var p=a;function pn(e){let{exec:o}=require("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function yn(e){return new Promise(o=>setTimeout(o,e))}async function lo(e,o={}){return new Promise((t,n)=>{let r=new URL(e),s=(r.protocol==="https:"?rt:nt).request(r,{method:o.method??"GET",headers:o.headers??{}},c=>{let d="";c.on("data",m=>d+=m),c.on("end",()=>{if((c.statusCode??500)>=400){n(new Error(`HTTP ${c.statusCode}: ${d}`));return}try{t(JSON.parse(d))}catch{n(new Error(`Invalid JSON: ${d.slice(0,200)}`))}})});s.on("error",n),o.body&&s.write(o.body),s.end()})}async function hn(e,o,t,n){return new Promise((r,i)=>{let s=new URL(e),c=s.protocol==="https:"?rt:nt,d={"Content-Type":t,"Content-Length":o.length};n&&(d["X-Wizard-Session"]=n.sessionSecret,d["X-Wizard-Session-Id"]=n.sessionId);let m=c.request(s,{method:"PUT",headers:d},b=>{if((b.statusCode??500)>=400){let S="";b.on("data",x=>S+=x),b.on("end",()=>i(new Error(`PUT failed ${b.statusCode}: ${S}`)));return}b.resume(),r()});m.on("error",i),m.write(o),m.end()})}function wn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function it(e={}){let o=e.wait!==!1,t=e.pollIntervalMs??Number(process.env.CFM_WIZARD_POLL_MS??3e3),n=e.timeoutMs??Number(process.env.CFM_WIZARD_TIMEOUT_MS??72e5),r=process.env.CFM_INSTANCE_ID,i=(process.env.CFM_DEPLOY_API_BASE??"http://localhost:3000").replace(/\/$/,"");if(!r)throw new Error("CFM_INSTANCE_ID (JWT) is required");let s=wn(r);if(!s)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let c=Me(),d=ne(c),m=d.activeConfigPath,b=e.apply?!1:e.review!==!1;console.log(`
141
141
  ${p.bold}${p.cyan}\u{1F3A8} CFM UI Customization (AWS)${p.reset}
142
- `),w&&(console.log(`${p.dim} Review mode: seed kept in survey-ui-config.json; final + diff written on complete.${p.reset}`),console.log(`${p.dim} Apply later with: npx cfm-sdk confirm-ui-config${p.reset}
143
- `));let S=[...G],{outputDir:x,files:F}=await pe({projectRoot:c,useTemplatesOnly:e.useTemplatesOnly,surveyTypes:S}),E=F.map(h=>({path:h.path,contentType:h.contentType,sizeBytes:h.sizeBytes})),{config:R,source:f}=ge({projectRoot:c,surveyTypes:S,instanceId:s});R.surveyTypes=S,Ke(f),w&&(be.writeFileSync(d.seedPath,JSON.stringify(R,null,2),"utf8"),be.writeFileSync(g,JSON.stringify(R,null,2),"utf8"),console.log(`${p.dim} Seed snapshot \u2192 survey-ui-config.json (+ .seed.json)${p.reset}`));let y=await lo(`${i}/wizard/session/start`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({files:E,surveyTypes:S,initialConfig:R})});console.log(`${p.dim} Uploading ${E.length} preview files\u2026${p.reset}`);for(let h of y.uploads){let P=tt.join(x,h.path),C=be.readFileSync(P),B=E.find(V=>V.path===h.path)?.contentType??"application/octet-stream";await hn(h.uploadUrl,C,B,{sessionId:y.sessionId,sessionSecret:y.sessionSecret})}if(await lo(`${i}/wizard/previews/upload/complete`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:y.sessionId})}),console.log(`${p.green}\u2705 Previews uploaded${p.reset}`),console.log(`${p.dim} ${E.length} component preview page(s) \u2192 EC2 local server (disk)${p.reset}`),console.log(`
142
+ `),b&&(console.log(`${p.dim} Review mode: seed kept in survey-ui-config.json; final + diff written on complete.${p.reset}`),console.log(`${p.dim} Apply later with: npx cfm-sdk confirm-ui-config${p.reset}
143
+ `));let S=[...Q],{outputDir:x,files:F}=await pe({projectRoot:c,useTemplatesOnly:e.useTemplatesOnly,surveyTypes:S}),A=F.map(w=>({path:w.path,contentType:w.contentType,sizeBytes:w.sizeBytes})),{config:R,source:f}=me({projectRoot:c,surveyTypes:S,instanceId:s});R.surveyTypes=S,Ke(f),b&&(be.writeFileSync(d.seedPath,JSON.stringify(R,null,2),"utf8"),be.writeFileSync(m,JSON.stringify(R,null,2),"utf8"),console.log(`${p.dim} Seed snapshot \u2192 survey-ui-config.json (+ .seed.json)${p.reset}`));let y=await lo(`${i}/wizard/session/start`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({files:A,surveyTypes:S,initialConfig:R})});console.log(`${p.dim} Uploading ${A.length} preview files\u2026${p.reset}`);for(let w of y.uploads){let P=tt.join(x,w.path),C=be.readFileSync(P),B=A.find(V=>V.path===w.path)?.contentType??"application/octet-stream";await hn(w.uploadUrl,C,B,{sessionId:y.sessionId,sessionSecret:y.sessionSecret})}if(await lo(`${i}/wizard/previews/upload/complete`,{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:y.sessionId})}),console.log(`${p.green}\u2705 Previews uploaded${p.reset}`),console.log(`${p.dim} ${A.length} component preview page(s) \u2192 EC2 local server (disk)${p.reset}`),console.log(`
144
144
  ${p.bold}${p.cyan}\u{1F517} Client wizard link \u2014 share with the client:${p.reset}`),console.log(`${p.green} ${y.wizardUrl}${p.reset}`),console.log(`${p.dim} (Deployed on EC2 \u2014 client customizes here; agent keeps CLI open until submit)${p.reset}
145
- `),pn(y.wizardUrl),!o){console.log(`${p.yellow}--no-wait: wizard URL (not polling):${p.reset}`),console.log(y.wizardUrl),w&&console.log(`${p.dim} When wizard completes, poll manually or re-run without --no-wait to capture final + diff.${p.reset}`);return}let T=Date.now()+n,$=0;for(;Date.now()<T;){$+=1,process.stdout.write(`\r${p.dim}Waiting for client to finish wizard\u2026 (poll ${$})${p.reset}`);let h=await lo(`${i}/wizard/config/${encodeURIComponent(s)}?sessionId=${y.sessionId}`,{headers:{Authorization:`Bearer ${r}`}});if(h.status==="abandoned")throw console.log(`
146
- ${p.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${p.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(h.status==="ready"&&h.config){let P=He(h)??h.config;if(console.log(`
147
- ${p.green}\u2705 Configuration ready${p.reset}`),h.logoUrl&&console.log(`${p.dim} Logo URL: ${h.logoUrl}${p.reset}`),w){let V=Xe(c,R,P);console.log(`${p.green} Seed (unchanged active): ${g}${p.reset}`),console.log(`${p.green} Final: ${d.finalPath}${p.reset}`),console.log(`${p.green} Diff: ${d.diffMdPath}${p.reset}`),console.log(`${p.yellow} ${V.changed.length} changed, ${V.added.length} added, ${V.removed.length} removed${p.reset}`);let ie=P.global?.logo;if(ie?.fileName)try{await le({projectRoot:c,fileName:ie.fileName,logoUrl:h.logoUrl,jwt:r,apiBase:i,surveyId:s}),console.log(`${p.green} Logo saved to public/${ie.fileName}${p.reset}`)}catch(dt){console.warn(`${p.yellow} Logo download deferred: ${z(dt)}${p.reset}`)}console.log(`${p.dim} Apply when ready: npx cfm-sdk confirm-ui-config (promotes JSON + regenerates survey-theme.css)${p.reset}`);return}be.writeFileSync(g,JSON.stringify(P,null,2),"utf8"),console.log(`${p.green} Written ${g}${p.reset}`);let{runApplyUiConfig:C}=await Promise.resolve().then(()=>(Ee(),Ae));C({projectRoot:c,configPath:g});let B=P.global?.logo;B?.fileName&&(await le({projectRoot:c,fileName:B.fileName,logoUrl:h.logoUrl,jwt:r,apiBase:i,surveyId:s}),console.log(`${p.green} Logo saved to public/${B.fileName}${p.reset}`));return}await yn(t)}throw new Error("Timed out waiting for wizard completion")}Re();W();var D=a,re=process.argv.slice(2),Z=re[0];async function kn(){if(Z==="customize"||Z==="init"){Z==="init"&&console.log(`${D.yellow}\u26A0 cfm-sdk init is deprecated. Use \`cfm-sdk customize\` instead.${D.reset}
145
+ `),pn(y.wizardUrl),!o){console.log(`${p.yellow}--no-wait: wizard URL (not polling):${p.reset}`),console.log(y.wizardUrl),b&&console.log(`${p.dim} When wizard completes, poll manually or re-run without --no-wait to capture final + diff.${p.reset}`);return}let T=Date.now()+n,$=0;for(;Date.now()<T;){$+=1,process.stdout.write(`\r${p.dim}Waiting for client to finish wizard\u2026 (poll ${$})${p.reset}`);let w=await lo(`${i}/wizard/config/${encodeURIComponent(s)}?sessionId=${y.sessionId}`,{headers:{Authorization:`Bearer ${r}`}});if(w.status==="abandoned")throw console.log(`
146
+ ${p.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${p.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(w.status==="ready"&&w.config){let P=He(w)??w.config;if(console.log(`
147
+ ${p.green}\u2705 Configuration ready${p.reset}`),w.logoUrl&&console.log(`${p.dim} Logo URL: ${w.logoUrl}${p.reset}`),b){let V=Xe(c,R,P);console.log(`${p.green} Seed (unchanged active): ${m}${p.reset}`),console.log(`${p.green} Final: ${d.finalPath}${p.reset}`),console.log(`${p.green} Diff: ${d.diffMdPath}${p.reset}`),console.log(`${p.yellow} ${V.changed.length} changed, ${V.added.length} added, ${V.removed.length} removed${p.reset}`);let ie=P.global?.logo;if(ie?.fileName)try{await le({projectRoot:c,fileName:ie.fileName,logoUrl:w.logoUrl,jwt:r,apiBase:i,surveyId:s}),console.log(`${p.green} Logo saved to public/${ie.fileName}${p.reset}`)}catch(dt){console.warn(`${p.yellow} Logo download deferred: ${z(dt)}${p.reset}`)}console.log(`${p.dim} Apply when ready: npx cfm-sdk confirm-ui-config (promotes JSON + regenerates survey-theme.css)${p.reset}`);return}be.writeFileSync(m,JSON.stringify(P,null,2),"utf8"),console.log(`${p.green} Written ${m}${p.reset}`);let{runApplyUiConfig:C}=await Promise.resolve().then(()=>(Ae(),Ee));C({projectRoot:c,configPath:m});let B=P.global?.logo;B?.fileName&&(await le({projectRoot:c,fileName:B.fileName,logoUrl:w.logoUrl,jwt:r,apiBase:i,surveyId:s}),console.log(`${p.green} Logo saved to public/${B.fileName}${p.reset}`));return}await yn(t)}throw new Error("Timed out waiting for wizard completion")}Re();W();var D=a,re=process.argv.slice(2),Z=re[0];async function kn(){if(Z==="customize"||Z==="init"){Z==="init"&&console.log(`${D.yellow}\u26A0 cfm-sdk init is deprecated. Use \`cfm-sdk customize\` instead.${D.reset}
148
148
  `);try{await Yo()}catch(e){console.error(`
149
149
  ${D.red}\u274C Error: ${z(e)}${D.reset}`),process.exit(1)}}else if(Z==="customize-ui"){let e=re.includes("--use-templates-only"),o=re.includes("--no-wait"),t=re.includes("--apply"),n=re.includes("--no-review")?!1:!t;try{await it({useTemplatesOnly:e,wait:!o,review:n,apply:t})}catch(r){console.error(`
150
150
  ${D.red}\u274C Error: ${z(r)}${D.reset}`),process.exit(1)}}else if(Z==="confirm-ui-config"){let e=re.includes("--diff-only");try{let{runConfirmUiConfig:o}=await Promise.resolve().then(()=>(ct(),st));await o({diffOnly:e})}catch(o){console.error(`
151
- ${D.red}\u274C Error: ${z(o)}${D.reset}`),process.exit(1)}}else if(Z==="apply-ui-config")try{let{runApplyUiConfig:e}=await Promise.resolve().then(()=>(Ee(),Ae));e({})}catch(e){console.error(`
151
+ ${D.red}\u274C Error: ${z(o)}${D.reset}`),process.exit(1)}}else if(Z==="apply-ui-config")try{let{runApplyUiConfig:e}=await Promise.resolve().then(()=>(Ae(),Ee));e({})}catch(e){console.error(`
152
152
  ${D.red}\u274C Error: ${z(e)}${D.reset}`),process.exit(1)}else if(Z==="fetch-ui-config"){let o=re.find(t=>t.startsWith("--session="))?.split("=")[1];try{let{runFetchUiConfig:t}=await Promise.resolve().then(()=>(lt(),at));await t({sessionId:o})}catch(t){console.error(`
153
153
  ${D.red}\u274C Error: ${z(t)}${D.reset}`),process.exit(1)}}else if(Z==="export-previews"){let e=re.includes("--use-templates-only");try{await pe({useTemplatesOnly:e})}catch(o){console.error(`
154
154
  ${D.red}\u274C Error: ${z(o)}${D.reset}`),process.exit(1)}}else if(Z==="resolve-ui-config"){let e=re.includes("--write");try{if(e){let o=Ye();console.log(`${D.green}\u2705 Wrote ${o}${D.reset}`)}else{let{resolveInitialConfig:o}=await Promise.resolve().then(()=>(Re(),No)),{config:t,source:n}=o({surveyTypes:[]});console.log(JSON.stringify({source:n,config:t},null,2))}}catch(o){console.error(`