@explorer02/cfm-survey-sdk 0.4.1 → 0.4.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 +44 -40
- package/dist/cli/index.mjs +42 -38
- package/package.json +1 -1
- package/templates/docs/templates/CsatMatrixScale.tsx +30 -34
- package/templates/docs/templates/LikertMatrixScale.tsx +6 -3
- package/templates/docs/templates/RatingScale.tsx +8 -25
- package/templates/docs/templates/SliderMatrixScale.tsx +2 -1
- package/templates/docs/templates/labelStyles.ts +17 -0
- package/templates/docs/templates/selectionStyles.ts +58 -0
- package/templates/docs/templates/surveyUiIcons.tsx +6 -1
- package/templates/preview-harness/preview-bridge.inline.js +13 -0
- package/templates/preview-harness/preview-google-fonts.html +6 -0
- package/templates/preview-harness/previewPages.js +3 -2
- package/templates/preview-harness/vite-app/src/PreviewConfigContext.tsx +29 -10
- package/templates/preview-harness/vite-app/src/globals.css +4 -3
- package/templates/preview-harness/vite-app/src/mergePreviewQuestion.ts +24 -2
- package/templates/preview-harness/vite-app/src/preview-live-overrides.css +5 -0
- package/templates/previewBridge.ts +14 -0
- package/templates/survey-theme.css +2 -0
- package/templates/wizard-dist/assets/{PreviewMock-MsONyaq9.js → PreviewMock-DkCiCfU3.js} +1 -1
- package/templates/wizard-dist/assets/TypePanel-CUani1B7.js +1 -0
- package/templates/wizard-dist/assets/index-COdmy8Xp.js +34 -0
- package/templates/wizard-dist/index.html +1 -1
- package/templates/wizard-dist/assets/TypePanel-D24BxbHk.js +0 -1
- package/templates/wizard-dist/assets/index-C7RSJr09.js +0 -34
package/dist/cli/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var rt=Object.defineProperty;var Ie=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,o)=>()=>(e&&(o=e(e=0)),o);var je=(e,o)=>{for(var t in o)rt(e,t,{get:o[t],enumerable:!0})};var a,q=z(()=>{"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,Ce=z(()=>{"use strict";G=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function pt(e){let o={};for(let t of e)go[t]&&(o[t]={...go[t]});return o}function gt(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:21,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:pt(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=gt(t,e.instanceId),i=e.global??{},r=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:{...r,...i,header:ee(r.header,i.header),footer:ee(r.footer,i.footer),theme:ee(r.theme,i.theme),layout:ee(r.layout,i.layout),buttons:ee(r.buttons,i.buttons),logo:ee(r.logo,i.logo),colorScheme:ee(r.colorScheme,i.colorScheme),typography:ee(r.typography,i.typography),motion:ee(r.motion,i.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,go,Xe=z(()=>{"use strict";Ce();M={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},go={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",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:M.primary,rowLabelWidth:180,unselectedStarOpacity:.5,graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.primary},SLIDER_MATRIX:{trackColor:M.accent,thumbColor:M.primary,tickColor:"#9CA3AF",rowLabelWidth:180,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},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",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:M.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:M.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});import*as ve from"fs";import*as xe from"path";function bo(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let i=n[0].split(":")[0].trim(),r=n[1].trim();o[i]=r}return o}function E(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function wo(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function Te(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function So(e){let o={global:{},questionTypes:{}},t=o.global,n={},i={},r={},s={},c={},d={},h={},m=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"]&&mo[e["--cfm-max-width"]]&&(c.width=mo[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&yo[e["--cfm-border-radius"]]&&(c.borderStyle=yo[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],ho[e["--cfm-font-family"]]&&(c.fontStyle=ho[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=Te(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let $=E(e["--cfm-motion-duration"]);$!==void 0&&(h.durationMs=$,h.enabled=$>0)}e["--cfm-header-height"]&&(i.height=E(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(i.logoBoxWidth=E(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(i.logoBoxHeight=E(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(i.logoPadding=E(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(i.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(i.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(i.companyNameFontSize=E(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(i.companyNameFontWeight=Te(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(i.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(i.contentPaddingX=E(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(r.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(r.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(r.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(r.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(r.logoWidth=E(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(r.logoHeight=E(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(r.paddingY=E(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(r.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&&(m.MCQ=S);let T={};e["--cfm-input-radius"]&&(T.inputRadius=E(e["--cfm-input-radius"])),e["--cfm-input-focus-ring"]&&(T.focusRing=e["--cfm-input-focus-ring"]),e["--cfm-input-border"]&&(T.borderColor=e["--cfm-input-border"]),e["--cfm-input-padding"]&&(T.inputPadding=E(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(T.inputHeight=E(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(T.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(T).length&&(m.TEXTFIELD=T);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&&(m.NPS_SCALE=F);let k=E(e["--cfm-matrix-row-width"]),R={};k!==void 0&&(R.rowLabelWidth=k),e["--cfm-matrix-selected"]&&(R.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&(R.bipolarColumnWidthPercent=wo(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&&(m.CFM_MATRIX=R);let p={...R};e["--cfm-csat-accent"]&&(p.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(p.emojiSize=E(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(p.unselectedOpacity=Te(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(p.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(p.cellSize=E(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(p.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(p).length>Object.keys(R).length||e["--cfm-csat-accent"])&&(m.CSAT_MATRIX=p);let g={};e["--cfm-star-color"]&&(g.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(g.badgeColor=e["--cfm-badge-color"]),k!==void 0&&(g.rowLabelWidth=k),e["--cfm-star-unselected-opacity"]&&(g.unselectedStarOpacity=Te(e["--cfm-star-unselected-opacity"])),Object.keys(g).length&&(m.RATING_MATRIX=g);let C={};e["--cfm-slider-track"]&&(C.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(C.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(C.tickColor=e["--cfm-slider-tick"]),k!==void 0&&(C.rowLabelWidth=k),e["--cfm-slider-row-band"]&&(C.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(C.tickBadgeSize=E(e["--cfm-slider-tick-size"])),Object.keys(C).length&&(m.SLIDER_MATRIX=C);let L={};e["--cfm-upload-accent"]&&(L.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&(L.dropzonePadding=E(e["--cfm-upload-padding"])),Object.keys(L).length&&(m.FILE_UPLOAD=L);let y={};e["--cfm-media-max-width"]&&(y.mediaMaxWidth=wo(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(y.mediaRadius=E(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(y.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(y.captionSize=E(e["--cfm-media-caption-size"])),Object.keys(y).length&&(m.TEXT_AND_MEDIA=y);let A={};e["--cfm-heatmap-pin"]&&(A.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(A.pinSize=E(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(A.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(A.overlayOpacity=Te(e["--cfm-heatmap-overlay-opacity"])),Object.keys(A).length&&(m.HEATMAP=A);let x={};return e["--cfm-rank-item-bg"]&&(x.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(x.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(x.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(x.itemPadding=E(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(x.itemGap=E(e["--cfm-rank-item-gap"])),Object.keys(x).length&&(m.RANK_ORDER=x),Object.keys(n).length&&(t.colorScheme=n),Object.keys(i).length&&(t.header=i),Object.keys(r).length&&(t.footer=r),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(h).length&&(t.motion=h),o}function ue(e){let o=[xe.join(e,"src","styles","survey-theme.css"),xe.join(e,"src","app","survey-theme.css"),xe.join(e,"src","styles","globals.css"),xe.join(e,"src","app","globals.css")];for(let t of o)if(ve.existsSync(t)&&ve.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var mo,yo,ho,De=z(()=>{"use strict";mo={"36rem":"narrow","48rem":"standard","64rem":"wide"},yo={"0px":"sharp","12px":"rounded","9999px":"pill"},ho={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});import*as Le from"fs";import*as Co from"path";function yt(e){for(let o of mt){let t=Co.join(e,o);if(Le.existsSync(t))return t}return null}function ht(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 To(e){let o=yt(e);if(!o)return null;let t=Le.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=ht(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let i=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(i)return{mode:"text",label:i[1].trim()};let r=t.match(/data-cfm-company[^>]*>([^<]+)</i);return r&&!n?{mode:"text",label:r[1].trim()}:null}var mt,xo=z(()=>{"use strict";mt=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var ko={};je(ko,{logSeedSource:()=>Ve,resolveInitialConfig:()=>ge,writeResolvedUiConfig:()=>Je});import*as Q from"fs";import*as oe from"path";function He(e){return e.filter(o=>G.includes(o))}function $o(e){try{let o=JSON.parse(Q.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function St(e){let o={global:{}};if(!Q.existsSync(e))return o;let t=Q.readFileSync(e,"utf8"),n=new Set;for(let r of G)t.includes(r)&&n.add(r);n.size&&(o.surveyTypes=[...n]);let i=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(i){let r=i[1].trim(),s=r.match(/company[:\s]+([^,;]+)/i),c=r.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 Eo(e,o){let t=oe.join(e,o);if(!Q.existsSync(t))return null;let n=Q.readFileSync(t);if(n.length>wt)return{fileName:o,dataUrl:""};let i=oe.extname(o).toLowerCase(),r=bt[i]??"application/octet-stream";return{fileName:o,dataUrl:`data:${r};base64,${n.toString("base64")}`}}function Ro(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=Eo(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 Ao(e,o){let t=e.global??{},n=o.global??{},i=e.questionTypes??{},r=o.questionTypes??{},s={...i};for(let[c,d]of Object.entries(r))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"),i=oe.join(o,"public"),r=He(e.surveyTypes),s={},c="defaults",d=ue(o);if(d){let x=Q.readFileSync(d,"utf8"),$=bo(x);Object.keys($).length>0&&(s=So($),c="survey-theme.css")}let h=St(n);s=Ao(s,h);let m=$o(t);m&&(s=Ao(s,m),c="survey-ui-config.json");let S=oe.join(o,"survey-ui-config.final.json"),T=$o(S),F=!!m?.configuredAt,k=!!T?.configuredAt;if(T&&k&&!F){let x=Ro(i,T.global?.logo);x&&(s.global={...s.global??{},logo:{fileName:x.fileName,url:x.url}})}let R=Ro(i,s.global?.logo),p=To(o),g=!!m?.configuredAt,C=R?.fileName!=null&&/^logo_\d+_/i.test(R.fileName),L=p?.mode==="image"?p.fileName:null,y=!g&&C&&L!=null&&R?.fileName!==L;if(R&&!y)s.global={...s.global??{},logo:{fileName:R.fileName,url:R.url}};else if(p?.mode==="image"){let x=Eo(i,p.fileName);s.global={...s.global??{},logo:{fileName:p.fileName,url:x?.dataUrl||null}}}else p?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??p.label});return s.surveyTypes=He(s.surveyTypes??r),s.surveyTypes?.length||(s.surveyTypes=r),e.instanceId&&(s.instanceId=e.instanceId),{config:_e(s),source:c}}function Ve(e){console.log(e==="survey-ui-config.json"?`${pe.dim} Seeding wizard from survey-ui-config.json${pe.reset}`:e==="survey-theme.css"?`${pe.dim} Seeding wizard from survey-theme.css + defaults${pe.reset}`:`${pe.dim} Seeding wizard from SDK defaults${pe.reset}`)}function Je(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??He(G),{config:n}=ge({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),i=oe.join(o,"survey-ui-config.json");return Q.writeFileSync(i,JSON.stringify(n,null,2),"utf8"),i}var pe,wt,bt,$e=z(()=>{"use strict";q();Xe();De();Ce();xo();pe=a,wt=512e3,bt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function W(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 _t(){return{"--cfm-header-brand-gap":"16px","--cfm-header-padding-y":"12px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0","--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start"}}function vt(){return{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":"start","--cfm-footer-links-col":"3","--cfm-footer-links-justify":"end","--cfm-footer-logo-copyright-gap":"12px"}}function Be(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,i)=>{typeof n=="string"&&(e[`--cfm-number-color-${i}`]=n)})}function Do(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==="rating"&&(o.columnLabelColor&&(e["--cfm-rating-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-rating-column-label-bg"]=l(o.columnLabelBgColor,"transparent")))}function Dt(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,o.filledOptionBg&&(e["--cfm-mcq-filled-bg"]=l(o.filledOptionBg,"#F9FAFB"))}function Lt(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 Mt(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,"numbered"),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"),o.hintMinText&&(e["--cfm-hint-min-text"]=l(o.hintMinText,"")),o.hintMaxText&&(e["--cfm-hint-max-text"]=l(o.hintMaxText,"")),Do(e,o),Be(e,o)}function Bt(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 Ot(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`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-accent"]??"#00B5AD"),Ze(e,o,"csat"),Be(e,o)}function Ut(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`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-primary"]??"#1A1F36"),Ze(e,o,"rating"),Be(e,o)}function zt(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`,Do(e,o),Be(e,o)}function qt(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 Wt(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 Xt(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 Ht(e,o){let t=W(o.drag)??o,n=W(o.dropdown)??t,i=l(n.itemHoverBg??t.itemHoverBg,"#F3F4F6");e["--cfm-rank-item-bg"]=l(t.itemBg??n.itemBg,"#F9FAFB"),e["--cfm-rank-dropdown-hover-bg"]=i,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 Oe(e){let o=W(e.global)??{},t=W(o.colorScheme)??{},n=W(o.header)??{},i=W(o.footer)??{},r=W(o.theme)??{},s=W(o.layout)??{},c=W(o.typography)??{},d=W(o.motion)??{},h=e.questionTypes??{},m=l(s.fontStyle,"modern"),S=vo[m]??l(c.fontFamily,vo.modern),T=l(s.width,"standard"),F=l(s.borderStyle,"rounded"),k=l(r.cellSelectedColor,l(t.accent,"#00B5AD")),R=l(r.focusRingColor,l(t.accent,"#00B5AD")),p=l(r.selectedBackground,l(t.secondary,"#E8F5FD")),g={"--cfm-primary":l(t.primary,"#1A1F36"),"--cfm-secondary":l(t.secondary,"#E8F5FD"),"--cfm-accent":l(t.accent,"#00B5AD"),"--cfm-background":l(r.pageBackground??t.background,"#FFFFFF"),"--cfm-text":l(t.text,"#1A1F36"),"--cfm-button-text":l(t.buttonText,"#FFFFFF"),"--cfm-max-width":No[T]??No.standard,"--cfm-border-radius":_o[F]??_o.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)",..._t(),"--cfm-footer-bg":l(i.backgroundColor,"#262626"),"--cfm-footer-text":l(i.textColor,"#9CA3AF"),"--cfm-footer-link":l(i.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":l(i.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${b(i.logoWidth,120)}px`,"--cfm-footer-logo-height":`${b(i.logoHeight,32)}px`,"--cfm-footer-padding-y":`${b(i.paddingY,24)}px`,"--cfm-footer-padding-x":`${b(i.paddingX,40)}px`,...vt(),"--cfm-card-bg":l(r.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(r.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${b(r.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":r.cardShadowEnabled===!1?"none":`0 ${b(r.cardShadowOffsetY,1)}px ${b(r.cardShadowBlur,3)}px ${l(r.cardShadowColor,"rgba(0,0,0,0.1)")}`,"--cfm-selected-bg":p,"--cfm-mcq-selected-accent":R,"--cfm-mcq-selected-bg":p,"--cfm-matrix-selected":k,"--cfm-csat-ring-color":k,"--cfm-input-focus-ring":R,"--cfm-zebra-row":l(r.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":l(r.rowBandColor,"#F3F4F6"),"--cfm-validation-border":l(r.validationBorder,"#333333"),"--cfm-validation-bg":l(r.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":l(r.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${b(r.progressTrackHeight,12)}px`,"--cfm-progress-track":l(r.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(r.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${b(r.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${b(r.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":l(r.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":l(r.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":l(r.languageSelectorBorderColor,"#2563EB")},C=[["MCQ",Dt],["TEXTFIELD",Lt],["NPS_SCALE",Mt],["CFM_MATRIX",Bt],["CSAT_MATRIX",Ot],["RATING_MATRIX",Ut],["SLIDER_MATRIX",zt],["FILE_UPLOAD",qt],["TEXT_AND_MEDIA",Wt],["HEATMAP",Xt],["RANK_ORDER",Ht]];for(let[L,y]of C){let A=W(h[L]);A&&y(g,A)}return g}function eo(e){let o=e.questionTypes??{},t=W(o.MCQ),n=W(o.NPS_SCALE),i=W(o.FILE_UPLOAD),r={};return r["data-cfm-mcq-style"]=l(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(r["data-cfm-nps-button-style"]=l(n.buttonStyle,"numbered")),i?.dropzoneStyle&&(r["data-cfm-dropzone-style"]=l(i.dropzoneStyle,"dashed")),r}var No,_o,vo,oo=z(()=>{"use strict";No={narrow:"36rem",standard:"48rem",wide:"64rem"},_o={sharp:"0px",rounded:"12px",pill:"9999px"},vo={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'}});import*as te from"fs";import*as se from"path";function Vt(e){return`:root {
|
|
2
|
+
var rt=Object.defineProperty;var Pe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(o,t)=>(typeof require<"u"?require:o)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var z=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ne=(e,o)=>{for(var t in o)rt(e,t,{get:o[t],enumerable:!0})};var a,q=z(()=>{"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,Ce=z(()=>{"use strict";G=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]});function ut(e){let o={};for(let t of e)mo[t]&&(o[t]={...mo[t]});return o}function mt(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:21,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:ut(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=mt(t,e.instanceId),i=e.global??{},r=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:{...r,...i,header:ee(r.header,i.header),footer:ee(r.footer,i.footer),theme:ee(r.theme,i.theme),layout:ee(r.layout,i.layout),buttons:ee(r.buttons,i.buttons),logo:ee(r.logo,i.logo),colorScheme:ee(r.colorScheme,i.colorScheme),typography:ee(r.typography,i.typography),motion:ee(r.motion,i.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,mo,Xe=z(()=>{"use strict";Ce();M={primary:"#1A1F36",secondary:"#E8F5FD",accent:"#00B5AD",background:"#FFFFFF",text:"#1A1F36",buttonText:"#FFFFFF"},mo={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,statementRowGap:8},CSAT_MATRIX:{rowLabelWidth:180,cellSelectedColor:M.accent,headerStyle:"bold",bipolarColumnWidthPercent:25,carouselDotColor:M.primary,cellPadding:8,statementRowGap:8,accentColor:M.accent,emojiSize:24,unselectedOpacity:.5,numberedTextColor:"#FFFFFF",selectedRingColor:M.accent,cellSize:40,tooltipBg:"#1F2937",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.accent},RATING_MATRIX:{starColor:"#F59E0B",badgeColor:M.primary,rowLabelWidth:180,statementRowGap:8,unselectedStarOpacity:.5,numberedTextColor:"#FFFFFF",graphicsTrackColor:"#E5E7EB",graphicsThumbColor:M.primary},SLIDER_MATRIX:{trackColor:M.accent,thumbColor:M.primary,tickColor:"#9CA3AF",rowLabelWidth:180,statementRowGap:8,rowBandColor:"#F3F4F6",tickBadgeSize:28,hintMinText:"Label 1",hintMaxText:"Label 2",hintLabelColor:"#6B7280",hintLabelBgColor:"transparent"},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",itemHoverBg:"#F3F4F6",dragHandleColor:"#9CA3AF",rankBadgeColor:M.primary,itemPadding:12,itemGap:8},dropdown:{itemBg:"#F9FAFB",selectBorderColor:"#E5E7EB",rankBadgeColor:M.primary,itemPadding:12,itemGap:8,itemHoverBg:"#F3F4F6"}}}});import*as ve from"fs";import*as xe from"path";function bo(e){let o={},t=/--cfm-[\w-]+\s*:\s*([^;]+);/g,n;for(;(n=t.exec(e))!==null;){let i=n[0].split(":")[0].trim(),r=n[1].trim();o[i]=r}return o}function F(e){if(!e)return;let o=parseFloat(e.replace(/px$/,""));return Number.isFinite(o)?o:void 0}function wo(e){if(!e)return;let o=parseFloat(e.replace(/%$/,""));return Number.isFinite(o)?o:void 0}function Te(e){if(!e)return;let o=parseFloat(e);return Number.isFinite(o)?o:void 0}function So(e){let o={global:{},questionTypes:{}},t=o.global,n={},i={},r={},s={},c={},d={},h={},g=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"]&&go[e["--cfm-max-width"]]&&(c.width=go[e["--cfm-max-width"]]),e["--cfm-border-radius"]&&yo[e["--cfm-border-radius"]]&&(c.borderStyle=yo[e["--cfm-border-radius"]]),e["--cfm-font-family"]&&(d.fontFamily=e["--cfm-font-family"],ho[e["--cfm-font-family"]]&&(c.fontStyle=ho[e["--cfm-font-family"]])),e["--cfm-heading-weight"]&&(d.headingWeight=Te(e["--cfm-heading-weight"])),e["--cfm-motion-duration"]){let R=F(e["--cfm-motion-duration"]);R!==void 0&&(h.durationMs=R,h.enabled=R>0)}e["--cfm-header-height"]&&(i.height=F(e["--cfm-header-height"])),e["--cfm-header-logo-width"]&&(i.logoBoxWidth=F(e["--cfm-header-logo-width"])),e["--cfm-header-logo-height"]&&(i.logoBoxHeight=F(e["--cfm-header-logo-height"])),e["--cfm-header-logo-padding"]&&(i.logoPadding=F(e["--cfm-header-logo-padding"])),e["--cfm-header-bg"]&&(i.backgroundColor=e["--cfm-header-bg"]),e["--cfm-header-company-color"]&&(i.companyNameColor=e["--cfm-header-company-color"]),e["--cfm-header-company-size"]&&(i.companyNameFontSize=F(e["--cfm-header-company-size"])),e["--cfm-header-company-weight"]&&(i.companyNameFontWeight=Te(e["--cfm-header-company-weight"])),e["--cfm-header-border"]&&(i.borderBottomColor=e["--cfm-header-border"]),e["--cfm-header-padding-x"]&&(i.contentPaddingX=F(e["--cfm-header-padding-x"])),e["--cfm-footer-bg"]&&(r.backgroundColor=e["--cfm-footer-bg"]),e["--cfm-footer-text"]&&(r.textColor=e["--cfm-footer-text"]),e["--cfm-footer-link"]&&(r.linkColor=e["--cfm-footer-link"]),e["--cfm-footer-link-hover"]&&(r.linkHoverColor=e["--cfm-footer-link-hover"]),e["--cfm-footer-logo-width"]&&(r.logoWidth=F(e["--cfm-footer-logo-width"])),e["--cfm-footer-logo-height"]&&(r.logoHeight=F(e["--cfm-footer-logo-height"])),e["--cfm-footer-padding-y"]&&(r.paddingY=F(e["--cfm-footer-padding-y"])),e["--cfm-footer-padding-x"]&&(r.paddingX=F(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=F(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=F(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=F(e["--cfm-sticky-pt"])),e["--cfm-sticky-pb"]&&(s.stickyChromePaddingBottom=F(e["--cfm-sticky-pb"]));let b={};e["--cfm-mcq-selected-accent"]&&(b.selectedAccent=e["--cfm-mcq-selected-accent"]),e["--cfm-mcq-border-radius"]&&(b.borderRadius=F(e["--cfm-mcq-border-radius"])),e["--cfm-mcq-option-gap"]&&(b.optionGap=F(e["--cfm-mcq-option-gap"])),e["--cfm-mcq-card-padding"]&&(b.cardPadding=F(e["--cfm-mcq-card-padding"])),e["--cfm-mcq-selected-bg"]&&(b.selectedBackground=e["--cfm-mcq-selected-bg"]),e["--cfm-mcq-hover-border"]&&(b.hoverBorderColor=e["--cfm-mcq-hover-border"]),Object.keys(b).length&&(g.MCQ=b);let x={};e["--cfm-input-radius"]&&(x.inputRadius=F(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=F(e["--cfm-input-padding"])),e["--cfm-input-height"]&&(x.inputHeight=F(e["--cfm-input-height"])),e["--cfm-input-placeholder"]&&(x.placeholderColor=e["--cfm-input-placeholder"]),Object.keys(x).length&&(g.TEXTFIELD=x);let A={};e["--cfm-nps-selected-fill"]&&(A.selectedFill=e["--cfm-nps-selected-fill"]),e["--cfm-nps-label-color"]&&(A.labelColor=e["--cfm-nps-label-color"]),e["--cfm-nps-track-bar"]&&(A.trackBarColor=e["--cfm-nps-track-bar"]),e["--cfm-nps-track-highlight"]&&(A.trackHighlightColor=e["--cfm-nps-track-highlight"]),e["--cfm-nps-cell-size"]&&(A.cellSize=F(e["--cfm-nps-cell-size"])),e["--cfm-nps-cell-gap"]&&(A.cellGap=F(e["--cfm-nps-cell-gap"])),Object.keys(A).length&&(g.NPS_SCALE=A);let E=F(e["--cfm-matrix-row-width"]),$={};E!==void 0&&($.rowLabelWidth=E),e["--cfm-matrix-selected"]&&($.cellSelectedColor=e["--cfm-matrix-selected"]),e["--cfm-matrix-bipolar-width"]&&($.bipolarColumnWidthPercent=wo(e["--cfm-matrix-bipolar-width"])),e["--cfm-matrix-carousel-dot"]&&($.carouselDotColor=e["--cfm-matrix-carousel-dot"]),e["--cfm-matrix-cell-padding"]&&($.cellPadding=F(e["--cfm-matrix-cell-padding"])),Object.keys($).length&&(g.CFM_MATRIX=$);let S={...$};e["--cfm-csat-accent"]&&(S.accentColor=e["--cfm-csat-accent"]),e["--cfm-csat-emoji-size"]&&(S.emojiSize=F(e["--cfm-csat-emoji-size"])),e["--cfm-csat-unselected-opacity"]&&(S.unselectedOpacity=Te(e["--cfm-csat-unselected-opacity"])),e["--cfm-csat-ring-color"]&&(S.selectedRingColor=e["--cfm-csat-ring-color"]),e["--cfm-csat-cell-size"]&&(S.cellSize=F(e["--cfm-csat-cell-size"])),e["--cfm-csat-tooltip-bg"]&&(S.tooltipBg=e["--cfm-csat-tooltip-bg"]),(Object.keys(S).length>Object.keys($).length||e["--cfm-csat-accent"])&&(g.CSAT_MATRIX=S);let f={};e["--cfm-star-color"]&&(f.starColor=e["--cfm-star-color"]),e["--cfm-badge-color"]&&(f.badgeColor=e["--cfm-badge-color"]),E!==void 0&&(f.rowLabelWidth=E),e["--cfm-star-unselected-opacity"]&&(f.unselectedStarOpacity=Te(e["--cfm-star-unselected-opacity"])),Object.keys(f).length&&(g.RATING_MATRIX=f);let k={};e["--cfm-slider-track"]&&(k.trackColor=e["--cfm-slider-track"]),e["--cfm-slider-thumb"]&&(k.thumbColor=e["--cfm-slider-thumb"]),e["--cfm-slider-tick"]&&(k.tickColor=e["--cfm-slider-tick"]),E!==void 0&&(k.rowLabelWidth=E),e["--cfm-slider-row-band"]&&(k.rowBandColor=e["--cfm-slider-row-band"]),e["--cfm-slider-tick-size"]&&(k.tickBadgeSize=F(e["--cfm-slider-tick-size"])),Object.keys(k).length&&(g.SLIDER_MATRIX=k);let I={};e["--cfm-upload-accent"]&&(I.accentColor=e["--cfm-upload-accent"]),e["--cfm-upload-padding"]&&(I.dropzonePadding=F(e["--cfm-upload-padding"])),Object.keys(I).length&&(g.FILE_UPLOAD=I);let m={};e["--cfm-media-max-width"]&&(m.mediaMaxWidth=wo(e["--cfm-media-max-width"])),e["--cfm-media-radius"]&&(m.mediaRadius=F(e["--cfm-media-radius"])),e["--cfm-media-caption-color"]&&(m.captionColor=e["--cfm-media-caption-color"]),e["--cfm-media-caption-size"]&&(m.captionSize=F(e["--cfm-media-caption-size"])),Object.keys(m).length&&(g.TEXT_AND_MEDIA=m);let C={};e["--cfm-heatmap-pin"]&&(C.pinColor=e["--cfm-heatmap-pin"]),e["--cfm-heatmap-pin-size"]&&(C.pinSize=F(e["--cfm-heatmap-pin-size"])),e["--cfm-heatmap-pin-border"]&&(C.pinBorderColor=e["--cfm-heatmap-pin-border"]),e["--cfm-heatmap-overlay-opacity"]&&(C.overlayOpacity=Te(e["--cfm-heatmap-overlay-opacity"])),Object.keys(C).length&&(g.HEATMAP=C);let T={};return e["--cfm-rank-item-bg"]&&(T.itemBg=e["--cfm-rank-item-bg"]),e["--cfm-rank-badge"]&&(T.rankBadgeColor=e["--cfm-rank-badge"]),e["--cfm-rank-handle"]&&(T.dragHandleColor=e["--cfm-rank-handle"]),e["--cfm-rank-item-padding"]&&(T.itemPadding=F(e["--cfm-rank-item-padding"])),e["--cfm-rank-item-gap"]&&(T.itemGap=F(e["--cfm-rank-item-gap"])),Object.keys(T).length&&(g.RANK_ORDER=T),Object.keys(n).length&&(t.colorScheme=n),Object.keys(i).length&&(t.header=i),Object.keys(r).length&&(t.footer=r),Object.keys(s).length&&(t.theme=s),Object.keys(c).length&&(t.layout=c),Object.keys(d).length&&(t.typography=d),Object.keys(h).length&&(t.motion=h),o}function pe(e){let o=[xe.join(e,"src","styles","survey-theme.css"),xe.join(e,"src","app","survey-theme.css"),xe.join(e,"src","styles","globals.css"),xe.join(e,"src","app","globals.css")];for(let t of o)if(ve.existsSync(t)&&ve.readFileSync(t,"utf8").includes("--cfm-"))return t;return null}var go,yo,ho,De=z(()=>{"use strict";go={"36rem":"narrow","48rem":"standard","64rem":"wide"},yo={"0px":"sharp","12px":"rounded","9999px":"pill"},ho={"system-ui, sans-serif":"system","Inter, sans-serif":"modern","Georgia, serif":"serif"}});import*as Le from"fs";import*as Co from"path";function yt(e){for(let o of gt){let t=Co.join(e,o);if(Le.existsSync(t))return t}return null}function ht(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 To(e){let o=yt(e);if(!o)return null;let t=Le.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=ht(n[1]);if(s)return{mode:"image",publicPath:s,fileName:s}}let i=t.match(/data-cfm-logo-text[^>]*>([^<]+)</i);if(i)return{mode:"text",label:i[1].trim()};let r=t.match(/data-cfm-company[^>]*>([^<]+)</i);return r&&!n?{mode:"text",label:r[1].trim()}:null}var gt,xo=z(()=>{"use strict";gt=["src/components/Header.tsx","components/Header.tsx","app/components/Header.tsx"]});var Eo={};Ne(Eo,{logSeedSource:()=>Ve,resolveInitialConfig:()=>me,writeResolvedUiConfig:()=>Je});import*as Q from"fs";import*as oe from"path";function He(e){return e.filter(o=>G.includes(o))}function Ro(e){try{let o=JSON.parse(Q.readFileSync(e,"utf8"));return o.version!=="1.0"?null:(delete o.configuredAt,o)}catch{return null}}function St(e){let o={global:{}};if(!Q.existsSync(e))return o;let t=Q.readFileSync(e,"utf8"),n=new Set;for(let r of G)t.includes(r)&&n.add(r);n.size&&(o.surveyTypes=[...n]);let i=t.match(/\*\*Branding source:\*\*\s*(.+)/i);if(i){let r=i[1].trim(),s=r.match(/company[:\s]+([^,;]+)/i),c=r.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 Fo(e,o){let t=oe.join(e,o);if(!Q.existsSync(t))return null;let n=Q.readFileSync(t);if(n.length>wt)return{fileName:o,dataUrl:""};let i=oe.extname(o).toLowerCase(),r=bt[i]??"application/octet-stream";return{fileName:o,dataUrl:`data:${r};base64,${n.toString("base64")}`}}function $o(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=Fo(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 Ao(e,o){let t=e.global??{},n=o.global??{},i=e.questionTypes??{},r=o.questionTypes??{},s={...i};for(let[c,d]of Object.entries(r))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"),i=oe.join(o,"public"),r=He(e.surveyTypes),s={},c="defaults",d=pe(o);if(d){let T=Q.readFileSync(d,"utf8"),R=bo(T);Object.keys(R).length>0&&(s=So(R),c="survey-theme.css")}let h=St(n);s=Ao(s,h);let g=Ro(t);g&&(s=Ao(s,g),c="survey-ui-config.json");let b=oe.join(o,"survey-ui-config.final.json"),x=Ro(b),A=!!g?.configuredAt,E=!!x?.configuredAt;if(x&&E&&!A){let T=$o(i,x.global?.logo);T&&(s.global={...s.global??{},logo:{fileName:T.fileName,url:T.url}})}let $=$o(i,s.global?.logo),S=To(o),f=!!g?.configuredAt,k=$?.fileName!=null&&/^logo_\d+_/i.test($.fileName),I=S?.mode==="image"?S.fileName:null,m=!f&&k&&I!=null&&$?.fileName!==I;if($&&!m)s.global={...s.global??{},logo:{fileName:$.fileName,url:$.url}};else if(S?.mode==="image"){let T=Fo(i,S.fileName);s.global={...s.global??{},logo:{fileName:S.fileName,url:T?.dataUrl||null}}}else S?.mode==="text"&&(s.global={...s.global??{},logo:{fileName:null,url:null},companyName:s.global?.companyName??S.label});return s.surveyTypes=He(s.surveyTypes??r),s.surveyTypes?.length||(s.surveyTypes=r),e.instanceId&&(s.instanceId=e.instanceId),{config:_e(s),source:c}}function Ve(e){console.log(e==="survey-ui-config.json"?`${ue.dim} Seeding wizard from survey-ui-config.json${ue.reset}`:e==="survey-theme.css"?`${ue.dim} Seeding wizard from survey-theme.css + defaults${ue.reset}`:`${ue.dim} Seeding wizard from SDK defaults${ue.reset}`)}function Je(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=e.surveyTypes??He(G),{config:n}=me({projectRoot:o,surveyTypes:t,instanceId:e.instanceId}),i=oe.join(o,"survey-ui-config.json");return Q.writeFileSync(i,JSON.stringify(n,null,2),"utf8"),i}var ue,wt,bt,Re=z(()=>{"use strict";q();Xe();De();Ce();xo();ue=a,wt=512e3,bt={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml"}});function W(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function y(e,o){return typeof e=="number"&&Number.isFinite(e)?e:o}function l(e,o){return typeof e=="string"&&e.length?e:o}function _t(){return{"--cfm-header-brand-gap":"16px","--cfm-header-padding-y":"12px","--cfm-header-company-margin-top":"0","--cfm-header-company-margin-left":"0","--cfm-header-company-margin-right":"0","--cfm-header-logo-col":"1","--cfm-header-logo-justify":"start"}}function vt(){return{"--cfm-footer-inner-display":"grid","--cfm-footer-inner-direction":"row","--cfm-footer-logo-col":"1","--cfm-footer-logo-justify":"start","--cfm-footer-links-col":"3","--cfm-footer-links-justify":"end","--cfm-footer-logo-copyright-gap":"12px"}}function Be(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,i)=>{typeof n=="string"&&(e[`--cfm-number-color-${i}`]=n)})}function Do(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==="rating"&&(o.columnLabelColor&&(e["--cfm-rating-column-label-color"]=l(o.columnLabelColor,"#4B5563")),o.columnLabelBgColor&&(e["--cfm-rating-column-label-bg"]=l(o.columnLabelBgColor,"transparent")))}function Dt(e,o){let t=l(o.optionStyle??o.cardStyle,"outlined");e["--cfm-mcq-border-radius"]=`${y(o.borderRadius,8)}px`,e["--cfm-mcq-option-gap"]=`${y(o.optionGap,8)}px`,e["--cfm-mcq-card-padding"]=`${y(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 Lt(e,o){e["--cfm-input-radius"]=`${y(o.inputRadius,8)}px`,e["--cfm-input-border"]=l(o.borderColor,"#E5E7EB"),e["--cfm-input-padding"]=`${y(o.inputPadding,12)}px`,e["--cfm-input-height"]=`${y(o.inputHeight,44)}px`,e["--cfm-input-placeholder"]=l(o.placeholderColor,"#9CA3AF")}function Mt(e,o){e["--cfm-nps-cell-size"]=`${y(o.cellSize,40)}px`,e["--cfm-nps-cell-gap"]=`${y(o.cellGap,4)}px`,e["--cfm-nps-button-style"]=l(o.buttonStyle,"numbered"),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"),o.hintMinText&&(e["--cfm-hint-min-text"]=l(o.hintMinText,"")),o.hintMaxText&&(e["--cfm-hint-max-text"]=l(o.hintMaxText,"")),Do(e,o),Be(e,o)}function Bt(e,o){e["--cfm-matrix-row-width"]=`${y(o.rowLabelWidth,180)}px`,e["--cfm-matrix-bipolar-width"]=`${y(o.bipolarColumnWidthPercent,25)}%`,e["--cfm-matrix-cell-padding"]=`${y(o.cellPadding,8)}px`,e["--cfm-matrix-statement-row-gap"]=`${y(o.statementRowGap,8)}px`,o.carouselDotColor&&(e["--cfm-matrix-carousel-dot"]=l(o.carouselDotColor,"#2563EB")),Ze(e,o,"matrix")}function Ot(e,o){e["--cfm-csat-emoji-size"]=`${y(o.emojiSize,24)}px`,e["--cfm-csat-unselected-opacity"]=String(y(o.unselectedOpacity,.5)),e["--cfm-star-unselected-opacity"]=String(y(o.unselectedStarOpacity??o.unselectedOpacity,.5)),e["--cfm-csat-cell-size"]=`${y(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"]=`${y(o.rowLabelWidth,180)}px`,e["--cfm-matrix-statement-row-gap"]=`${y(o.statementRowGap,8)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-accent"]??"#00B5AD"),Ze(e,o,"csat"),Be(e,o),e["--cfm-matrix-number-text-color"]=l(o.numberedTextColor,"#FFFFFF")}function Ut(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"]=`${y(o.emojiSize,24)}px`,e["--cfm-star-unselected-opacity"]=String(y(o.unselectedStarOpacity,.5)),e["--cfm-csat-unselected-opacity"]=String(y(o.unselectedStarOpacity,.5)),e["--cfm-matrix-row-width"]=`${y(o.rowLabelWidth,180)}px`,e["--cfm-matrix-statement-row-gap"]=`${y(o.statementRowGap,8)}px`,e["--cfm-slider-track"]=l(o.graphicsTrackColor,"#E5E7EB"),e["--cfm-slider-thumb"]=l(o.graphicsThumbColor,e["--cfm-primary"]??"#1A1F36"),Ze(e,o,"rating"),Be(e,o),e["--cfm-matrix-number-text-color"]=l(o.numberedTextColor,"#FFFFFF")}function zt(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"]=`${y(o.rowLabelWidth,180)}px`,e["--cfm-matrix-statement-row-gap"]=`${y(o.statementRowGap,8)}px`,e["--cfm-slider-row-band"]=l(o.rowBandColor,e["--cfm-row-band"]??"#F3F4F6"),e["--cfm-slider-tick-size"]=`${y(o.tickBadgeSize,28)}px`,Do(e,o),Be(e,o)}function qt(e,o){e["--cfm-upload-border-color"]=l(o.borderColor??o.accentColor,"#D1D5DB"),e["--cfm-upload-padding"]=`${y(o.dropzonePadding,24)}px`,e["--cfm-upload-fill"]=l(o.dropzoneFillColor,"#F9FAFB"),e["--cfm-upload-border-style"]=l(o.dropzoneStyle,"dashed")}function Wt(e,o){e["--cfm-media-max-width"]=`${y(o.mediaMaxWidth,100)}%`,e["--cfm-media-radius"]=`${y(o.mediaRadius,8)}px`,e["--cfm-media-caption-color"]=l(o.captionColor,"#6B7280"),e["--cfm-media-caption-size"]=`${y(o.captionSize,14)}px`}function Xt(e,o){e["--cfm-heatmap-pin"]=l(o.pinColor,e["--cfm-accent"]??"#00B5AD"),e["--cfm-heatmap-pin-size"]=`${y(o.pinSize,12)}px`,e["--cfm-heatmap-pin-border"]=l(o.pinBorderColor,"#FFFFFF"),e["--cfm-heatmap-overlay-opacity"]=String(y(o.overlayOpacity,0))}function Ht(e,o){let t=W(o.drag)??o,n=W(o.dropdown)??t,i=l(n.itemHoverBg??t.itemHoverBg,"#F3F4F6");e["--cfm-rank-item-bg"]=l(t.itemBg??n.itemBg,"#F9FAFB"),e["--cfm-rank-dropdown-hover-bg"]=i,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"]=`${y(t.itemPadding,12)}px`,e["--cfm-rank-item-gap"]=`${y(t.itemGap,8)}px`,e["--cfm-rank-handle"]=l(t.dragHandleColor,"#9CA3AF"),e["--cfm-rank-select-border"]=l(n.selectBorderColor,"#E5E7EB")}function Oe(e){let o=W(e.global)??{},t=W(o.colorScheme)??{},n=W(o.header)??{},i=W(o.footer)??{},r=W(o.theme)??{},s=W(o.layout)??{},c=W(o.typography)??{},d=W(o.motion)??{},h=e.questionTypes??{},g=l(s.fontStyle,"modern"),b=vo[g]??l(c.fontFamily,vo.modern),x=l(s.width,"standard"),A=l(s.borderStyle,"rounded"),E=l(r.cellSelectedColor,l(t.accent,"#00B5AD")),$=l(r.focusRingColor,l(t.accent,"#00B5AD")),S=l(r.selectedBackground,l(t.secondary,"#E8F5FD")),f={"--cfm-primary":l(t.primary,"#1A1F36"),"--cfm-secondary":l(t.secondary,"#E8F5FD"),"--cfm-accent":l(t.accent,"#00B5AD"),"--cfm-background":l(r.pageBackground??t.background,"#FFFFFF"),"--cfm-text":l(t.text,"#1A1F36"),"--cfm-button-text":l(t.buttonText,"#FFFFFF"),"--cfm-max-width":jo[x]??jo.standard,"--cfm-border-radius":_o[A]??_o.rounded,"--cfm-font-family":b,"--cfm-heading-weight":String(y(c.headingWeight,700)),"--cfm-motion-duration":`${y(d.durationMs,200)}ms`,"--cfm-header-height":`${y(n.height,120)}px`,"--cfm-header-logo-width":`${y(n.logoBoxWidth,120)}px`,"--cfm-header-logo-height":`${y(n.logoBoxHeight,120)}px`,"--cfm-header-logo-padding":`${y(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":`${y(n.companyNameFontSize,18)}px`,"--cfm-header-company-weight":String(y(n.companyNameFontWeight,600)),"--cfm-header-border":l(n.borderBottomColor,"#E5E7EB"),"--cfm-header-padding-x":`${y(n.contentPaddingX,40)}px`,"--cfm-header-shadow":n.shadowEnabled===!1?"none":"0 2px 8px rgba(0,0,0,0.06)",..._t(),"--cfm-footer-bg":l(i.backgroundColor,"#262626"),"--cfm-footer-text":l(i.textColor,"#9CA3AF"),"--cfm-footer-link":l(i.linkColor,"#9CA3AF"),"--cfm-footer-link-hover":l(i.linkHoverColor,"#FFFFFF"),"--cfm-footer-logo-width":`${y(i.logoWidth,120)}px`,"--cfm-footer-logo-height":`${y(i.logoHeight,32)}px`,"--cfm-footer-padding-y":`${y(i.paddingY,24)}px`,"--cfm-footer-padding-x":`${y(i.paddingX,40)}px`,...vt(),"--cfm-card-bg":l(r.cardBackground,"#FFFFFF"),"--cfm-card-border-color":l(r.cardBorderColor,"#E5E7EB"),"--cfm-card-padding":`${y(r.cardPadding,24)}px`,"--cfm-card-gap":"32px","--cfm-card-shadow":r.cardShadowEnabled===!1?"none":`0 ${y(r.cardShadowOffsetY,1)}px ${y(r.cardShadowBlur,3)}px ${l(r.cardShadowColor,"rgba(0,0,0,0.1)")}`,"--cfm-selected-bg":S,"--cfm-mcq-selected-accent":$,"--cfm-mcq-selected-bg":S,"--cfm-matrix-selected":E,"--cfm-csat-ring-color":E,"--cfm-input-focus-ring":$,"--cfm-zebra-row":l(r.zebraRowColor,"rgba(249,250,251,0.8)"),"--cfm-row-band":l(r.rowBandColor,"#F3F4F6"),"--cfm-validation-border":l(r.validationBorder,"#333333"),"--cfm-validation-bg":l(r.validationBackground,"#D9D9D9"),"--cfm-tooltip-bg":l(r.tooltipBackground,"#1F2937"),"--cfm-progress-height":`${y(r.progressTrackHeight,12)}px`,"--cfm-progress-track":l(r.progressTrackColor,"#E5E7EB"),"--cfm-progress-fill":l(r.progressFillColor,l(t.primary,"#1A1F36")),"--cfm-sticky-pt":`${y(r.stickyChromePaddingTop,16)}px`,"--cfm-sticky-pb":`${y(r.stickyChromePaddingBottom,20)}px`,"--cfm-language-bg":l(r.languageSelectorBackground,"#FFFFFF"),"--cfm-language-text":l(r.languageSelectorTextColor,"#2563EB"),"--cfm-language-border":l(r.languageSelectorBorderColor,"#2563EB")},k=[["MCQ",Dt],["TEXTFIELD",Lt],["NPS_SCALE",Mt],["CFM_MATRIX",Bt],["CSAT_MATRIX",Ot],["RATING_MATRIX",Ut],["SLIDER_MATRIX",zt],["FILE_UPLOAD",qt],["TEXT_AND_MEDIA",Wt],["HEATMAP",Xt],["RANK_ORDER",Ht]];for(let[I,m]of k){let C=W(h[I]);C&&m(f,C)}return f}function eo(e){let o=e.questionTypes??{},t=W(o.MCQ),n=W(o.NPS_SCALE),i=W(o.FILE_UPLOAD),r={};return r["data-cfm-mcq-style"]=l(t?.optionStyle??t?.cardStyle,"outlined"),n?.buttonStyle&&(r["data-cfm-nps-button-style"]=l(n.buttonStyle,"numbered")),i?.dropzoneStyle&&(r["data-cfm-dropzone-style"]=l(i.dropzoneStyle,"dashed")),r}var jo,_o,vo,oo=z(()=>{"use strict";jo={narrow:"36rem",standard:"48rem",wide:"64rem"},_o={sharp:"0px",rounded:"12px",pill:"9999px"},vo={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'}});import*as te from"fs";import*as se from"path";function Vt(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 Jt(e,o){let t=Oe(e),n=Vt(t),i=o.match(/:root\s*\{[\s\S]*?\n\}/);return i?o.replace(i[0],n):`${n}
|
|
6
6
|
|
|
7
7
|
${o}`}function Gt(e){let o=se.join(e,"src","styles","survey-theme.css");if(te.existsSync(se.dirname(o)))return o;let t=se.join(e,"src","app","survey-theme.css");return te.existsSync(se.dirname(t))?t:(te.mkdirSync(se.dirname(o),{recursive:!0}),o)}function Lo(e,o,t){let n=te.readFileSync(t,"utf8"),i=Gt(e),r=Jt(o,n);return te.writeFileSync(i,r,"utf8"),i}var Mo=z(()=>{"use strict";oo()});import*as he from"fs";import*as we from"path";function Bo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(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 Uo(e,o,t,n){if(Oo(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)){Oo(e,o)?n.unchangedCount+=1:n.changed.push({path:t,before:ye(e),after:ye(o)});return}if(Bo(e)&&Bo(o)){let i=new Set([...Object.keys(e),...Object.keys(o)]);for(let r of i){if(Qt.has(r)&&t==="")continue;let s=t?`${t}.${r}`:r;Uo(e[r],o[r],s,n)}return}n.changed.push({path:t,before:ye(e),after:ye(o)})}function to(e,o){let t={changed:[],added:[],removed:[],unchangedCount:0};return Uo(e,o,"",t),t}function Ue(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,i)=>{if(i.length){o.push(`## ${n}`,"");for(let r of i)o.push(`### \`${r.path}\``),o.push(`- **Before:** \`${JSON.stringify(r.before)}\``),o.push(`- **After:** \`${JSON.stringify(r.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 ze(e,o,t){let n=ne(e),i=to(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(i,null,2),"utf8"),he.writeFileSync(n.diffMdPath,Ue(i),"utf8"),he.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),i}var Qt
|
|
9
|
-
${s}`,
|
|
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 ze(e,o,t){let n=ne(e),i=to(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(i,null,2),"utf8"),he.writeFileSync(n.diffMdPath,Ue(i),"utf8"),he.writeFileSync(n.activeConfigPath,JSON.stringify(o,null,2),"utf8"),i}var Qt,$e=z(()=>{"use strict";Qt=new Set(["configuredAt","instanceId"])});function qo(e){return zo[e]?zo[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 zo,Wo=z(()=>{"use strict";zo={"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.statementRowGap":"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.CSAT_MATRIX.graphicsTrackColor":"css","questionTypes.CSAT_MATRIX.graphicsThumbColor":"css","questionTypes.CSAT_MATRIX.columnLabelColor":"css","questionTypes.CSAT_MATRIX.columnLabelBgColor":"css","questionTypes.CSAT_MATRIX.numberedTextColor":"css","questionTypes.CSAT_MATRIX.statementRowGap":"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.RATING_MATRIX.graphicsTrackColor":"css","questionTypes.RATING_MATRIX.graphicsThumbColor":"css","questionTypes.RATING_MATRIX.columnLabelColor":"css","questionTypes.RATING_MATRIX.columnLabelBgColor":"css","questionTypes.RATING_MATRIX.numberedTextColor":"css","questionTypes.RATING_MATRIX.statementRowGap":"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.SLIDER_MATRIX.statementRowGap":"css","questionTypes.SLIDER_MATRIX.hintMinText":"runtime","questionTypes.SLIDER_MATRIX.hintMaxText":"runtime","questionTypes.SLIDER_MATRIX.hintLabelColor":"css","questionTypes.SLIDER_MATRIX.hintLabelBgColor":"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.itemHoverBg":"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.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 Ae={};Ne(Ae,{runApplyUiConfig:()=>rn});import*as D from"fs";import*as B from"path";function Yt(e,o){if(o&&D.existsSync(o))return o;let t=B.join(e,"survey-ui-config.json");if(D.existsSync(t))return t;let n=ne(e).finalPath;if(D.existsSync(n))return n;throw new Error("No survey-ui-config.json found. Complete the wizard or run confirm-ui-config first.")}function Zt(e,o){let t=B.relative(B.dirname(o),o),n=(o.includes(`${B.sep}styles${B.sep}`),"./survey-theme.css"),i=[B.join(e,"src","app","globals.css"),B.join(e,"src","styles","globals.css")];for(let r of i){if(!D.existsSync(r))continue;let s=D.readFileSync(r,"utf8"),c=`@import '${n}';`;if(s.includes("survey-theme.css"))return;s.includes(c)||(s=`${c}
|
|
9
|
+
${s}`,D.writeFileSync(r,s,"utf8"));return}}function en(e,o){let t=eo(o),n=B.join(e,"src","lib");D.mkdirSync(n,{recursive:!0});let i=B.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.
|
|
12
12
|
*/
|
|
@@ -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
|
|
19
|
+
`;return D.writeFileSync(i,s,"utf8"),i}function on(e){let o=B.join(e,"src","components");D.mkdirSync(o,{recursive:!0});let t=B.join(o,"SurveyUiConfigInit.tsx");return D.existsSync(t)||D.writeFileSync(t,Kt,"utf8"),t}function tn(e,o){let t=B.join(e,"src","lib","uiConfig.ts");if(D.existsSync(t))return;let n=B.join(o,"docs","templates","uiConfig.ts");D.existsSync(n)&&(D.mkdirSync(B.dirname(t),{recursive:!0}),D.copyFileSync(n,t))}function nn(e,o){let t=e.replace(/\.json$/,".diff.json");if(D.existsSync(t))try{let n=JSON.parse(D.readFileSync(t,"utf8")),i=[...(n.changed??[]).map(r=>r.path),...(n.added??[]).map(r=>r.path),...(n.removed??[]).map(r=>r.path)];for(let r of i)qo(r)==="unknown"&&o.push(`Unmapped config path (verify manually): ${r}`)}catch{}}function rn(e={}){let o=e.projectRoot??process.env.INIT_CWD??process.cwd(),t=Yt(o,e.configPath),n=B.join(__dirname,"..",".."),i=B.join(n,"templates","survey-theme.css"),r=B.join(n,"templates"),s=[],c=JSON.parse(D.readFileSync(t,"utf8")),d=[...new Set([...c.surveyTypes??[],...G])],h=_e({...c,surveyTypes:d}),g=Lo(o,h,i);Zt(o,g),tn(o,r),en(o,h);let b;e.skipInitComponent||(b=on(o));let x=Oe(h),A=eo(h);nn(t,s),console.log(`${K.green}\u2705 Applied UI config \u2192 ${g}${K.reset}`),console.log(`${K.dim} ${Object.keys(x).length} CSS variables regenerated${K.reset}`),console.log(`${K.dim} DOM attrs: ${Object.entries(A).map(([E,$])=>`${E}=${$}`).join(", ")}${K.reset}`),b&&console.log(`${K.dim} Runtime init: ${b} (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:g,cssVarCount:Object.keys(x).length,domAttributes:A,initComponentPath:b,warnings:s}}var K,Kt,Fe=z(()=>{"use strict";q();Xe();oo();Mo();$e();Wo();Ce();K=a,Kt=`'use client';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Applies wizard DOM attributes from survey-ui-config.json at runtime.
|
|
@@ -32,10 +32,10 @@ export function SurveyUiConfigInit() {
|
|
|
32
32
|
}, []);
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
|
-
`});import*as ce from"fs";import*as Go from"http";import*as Qo from"https";import*as ro from"path";function qe(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 Jo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?Qo:Go).get(n,r=>{if((r.statusCode??500)>=400){t(new Error(`Logo download failed HTTP ${r.statusCode}`));return}let s=[];r.on("data",c=>s.push(c)),r.on("end",()=>o(Buffer.concat(s)))}).on("error",t)})}async function ln(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Qo:Go).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 ae(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:i,apiBase:r,surveyId:s}=e,c=ro.join(o,"public");ce.existsSync(c)||ce.mkdirSync(c,{recursive:!0});let d=ro.join(c,t);if(n){let h=await Jo(n);return ce.writeFileSync(d,h),d}if(i&&r&&s){let h=await ln(`${r.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${i}`}}),
|
|
35
|
+
`});import*as ce from"fs";import*as Go from"http";import*as Qo from"https";import*as ro from"path";function qe(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 Jo(e){return new Promise((o,t)=>{let n=new URL(e);(n.protocol==="https:"?Qo:Go).get(n,r=>{if((r.statusCode??500)>=400){t(new Error(`Logo download failed HTTP ${r.statusCode}`));return}let s=[];r.on("data",c=>s.push(c)),r.on("end",()=>o(Buffer.concat(s)))}).on("error",t)})}async function ln(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Qo:Go).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 ae(e){let{projectRoot:o,fileName:t,logoUrl:n,jwt:i,apiBase:r,surveyId:s}=e,c=ro.join(o,"public");ce.existsSync(c)||ce.mkdirSync(c,{recursive:!0});let d=ro.join(c,t);if(n){let h=await Jo(n);return ce.writeFileSync(d,h),d}if(i&&r&&s){let h=await ln(`${r.replace(/\/$/,"")}/wizard/logo/${encodeURIComponent(s)}/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${i}`}}),g=await Jo(h.downloadUrl);return ce.writeFileSync(d,g),d}throw new Error("Logo download requires logoUrl from wizard poll or CFM_INSTANCE_ID + CFM_DEPLOY_API_BASE")}var We=z(()=>{"use strict"});var ot={};Ne(ot,{runConfirmUiConfig:()=>gn});import*as Y from"fs";function mn(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function gn(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")),i=JSON.parse(Y.readFileSync(t.finalPath,"utf8")),r=to(n,i);if(console.log(`
|
|
36
36
|
${H.bold}${H.cyan}\u{1F4CB} UI config review${H.reset}
|
|
37
|
-
`),console.log(Ue(r)),e.diffOnly){Y.writeFileSync(t.diffJsonPath,JSON.stringify(r,null,2),"utf8"),Y.writeFileSync(t.diffMdPath,Ue(r),"utf8"),console.log(`${H.dim} Updated ${t.diffMdPath}${H.reset}`);return}Y.writeFileSync(t.activeConfigPath,JSON.stringify(i,null,2),"utf8"),console.log(`${H.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${H.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(
|
|
38
|
-
${X.green}\u2705 Fetched final config (review mode)${X.reset}`),console.log(`${X.green} Final: ${s.finalPath}${X.reset}`),console.log(`${X.green} Diff: ${s.diffMdPath}${X.reset}`),console.log(`${X.yellow} ${
|
|
37
|
+
`),console.log(Ue(r)),e.diffOnly){Y.writeFileSync(t.diffJsonPath,JSON.stringify(r,null,2),"utf8"),Y.writeFileSync(t.diffMdPath,Ue(r),"utf8"),console.log(`${H.dim} Updated ${t.diffMdPath}${H.reset}`);return}Y.writeFileSync(t.activeConfigPath,JSON.stringify(i,null,2),"utf8"),console.log(`${H.green}\u2705 Applied final config \u2192 ${t.activeConfigPath}${H.reset}`);let{runApplyUiConfig:s}=await Promise.resolve().then(()=>(Fe(),Ae));s({projectRoot:o,configPath:t.activeConfigPath});let c=i.global?.logo;if(!c?.fileName)return;let d=process.env.CFM_INSTANCE_ID,h=(process.env.CFM_DEPLOY_API_BASE??"").replace(/\/$/,""),g=d?mn(d):null;try{await ae({projectRoot:o,fileName:c.fileName,logoUrl:c.url,jwt:d??void 0,apiBase:h||void 0,surveyId:g??void 0}),console.log(`${H.green} Logo saved to public/${c.fileName}${H.reset}`),c.url&&console.log(`${H.dim} Public logo URL: ${c.url}${H.reset}`)}catch(b){console.log(`${H.yellow} Logo not downloaded \u2014 ${b instanceof Error?b.message:String(b)}${H.reset}`)}}var H,tt=z(()=>{"use strict";q();$e();We();H=a});var nt={};Ne(nt,{runFetchUiConfig:()=>Sn});import*as Ie from"fs";import*as yn from"http";import*as hn from"https";async function wn(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?hn:yn).request(i,{method:"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 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.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 i=bn(o);if(!i)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let r=process.env.INIT_CWD??process.cwd(),s=ne(r),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 wn(`${t}/wizard/config/${encodeURIComponent(i)}?sessionId=${encodeURIComponent(n)}`,{headers:{Authorization:`Bearer ${o}`}});if(d.status!=="ready"||!d.config)throw new Error(`Wizard not complete yet (status: ${d.status})`);let h=qe(d)??d.config,g=JSON.parse(Ie.readFileSync(c,"utf8")),b=ze(r,g,h),x=h.global?.logo;if(x?.fileName)try{await ae({projectRoot:r,fileName:x.fileName,logoUrl:d.logoUrl,jwt:o,apiBase:t,surveyId:i}),console.log(`${X.green} Logo saved to public/${x.fileName}${X.reset}`)}catch(A){console.warn(`${X.yellow} Logo download failed: ${A}${X.reset}`)}console.log(`
|
|
38
|
+
${X.green}\u2705 Fetched final config (review mode)${X.reset}`),console.log(`${X.green} Final: ${s.finalPath}${X.reset}`),console.log(`${X.green} Diff: ${s.diffMdPath}${X.reset}`),console.log(`${X.yellow} ${b.changed.length} changed, ${b.added.length} added, ${b.removed.length} removed${X.reset}`),console.log(`${X.dim} Apply when ready: npx cfm-sdk confirm-ui-config${X.reset}`)}var X,it=z(()=>{"use strict";q();$e();We();X=a});q();q();import{execSync as co,spawn as st}from"child_process";function de(e){try{let o=process.platform==="win32"?`where ${e}`:`command -v ${e}`;return co(o,{stdio:"ignore"}),!0}catch{return!1}}var ct={stdio:"inherit",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};function Se(e,o){try{let t=`${e} ${o.join(" ")}`;return co(t,ct),!0}catch{return!1}}function je(e,o){return new Promise(t=>{st(e,o,{stdio:"inherit",shell:!0}).on("close",i=>{t(i)})})}import at from"readline/promises";import{stdin as lt,stdout as dt}from"process";async function fe(e){let o=at.createInterface({input:lt,output:dt});try{return(await o.question(e)).trim()}finally{o.close()}}async function ao(){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}
|
|
41
41
|
`),process.exit(1));let n=process.platform==="win32",i=process.platform==="darwin";n?de("winget")?(console.log(`
|
|
@@ -57,15 +57,15 @@ ${X.green}\u2705 Fetched final config (review mode)${X.reset}`),console.log(`${X
|
|
|
57
57
|
`),process.exit(1))}else console.log(`\u2714 ${a.green}Node.js version (v${e}) is sufficient.${a.reset}`)}q();async function lo(){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}`),Se("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}}q();import{execSync as ft}from"child_process";var
|
|
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{ft(e?"npx --yes vercel whoami":"vercel whoami",
|
|
62
|
-
\u2714 ${a.green}Logged in successfully!${a.reset}`)}return o}q();async function
|
|
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}}q();import{execSync as ft}from"child_process";var pt={stdio:"ignore",shell:process.platform==="win32"?"cmd.exe":"/bin/sh"};async function fo(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{ft(e?"npx --yes vercel whoami":"vercel whoami",pt),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"],i=e?"npx":"vercel",r=e?["--yes","vercel",...n]:n;if(await je(i,r)!==0)throw new Error("Vercel login failed or was aborted.");console.log(`
|
|
62
|
+
\u2714 ${a.green}Logged in successfully!${a.reset}`)}return o}q();async function po(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",i=e?["--yes","vercel",...t]:t;if(console.log(`${a.cyan}\u26A1 Running deployment in: ${process.cwd()}${a.reset}
|
|
64
|
-
`),await
|
|
64
|
+
`),await je(n,i)!==0)throw new Error("Vercel deployment failed.");console.log(`
|
|
65
65
|
${a.bold}${a.green}\u{1F389} Deployment completed successfully!${a.reset}
|
|
66
|
-
`)}async function
|
|
66
|
+
`)}async function uo(){console.log(`
|
|
67
67
|
${a.bold}${a.cyan}\u{1F680} Starting CFM Vercel Deployment...${a.reset}
|
|
68
|
-
`),await ao();let{vercelCmd:e,useNpx:o}=await lo(),t=await fo(o);await
|
|
68
|
+
`),await ao();let{vercelCmd:e,useNpx:o}=await lo(),t=await fo(o);await po(o,t)}q();import*as ke from"http";import*as P from"fs";import*as v from"path";function U(e){return e instanceof Error?e.message:String(e)}Re();q();import*as j from"fs";import*as N from"path";De();De();import*as u from"fs";import*as p from"path";import{execSync as Ct}from"child_process";function re(e,o){if(u.existsSync(e)){u.mkdirSync(o,{recursive:!0});for(let t of u.readdirSync(e,{withFileTypes:!0})){let n=p.join(e,t.name),i=p.join(o,t.name);t.isDirectory()?re(n,i):u.copyFileSync(n,i)}}}function Ge(e){let o=[],t=e;for(let n=0;n<6;n++){let i=p.join(t,"node_modules");u.existsSync(i)&&o.push(i);let r=p.dirname(t);if(r===t)break;t=r}return o}function Tt(e,o){let t=Ge(e);for(let n of t)for(let i of["@explorer02/cfm-survey-sdk","@repo/sdk"])for(let r of["mjs","js"]){let s=p.join(n,i,"dist",`index.${r}`);if(u.existsSync(s))return s}for(let n of["mjs","js"]){let i=p.join(o,"dist",`index.${n}`);if(u.existsSync(i))return i}throw new Error("Could not resolve @explorer02/cfm-survey-sdk for preview build")}function xt(e,o){let t=[...Ge(o).map(n=>p.join(n,"vite","bin","vite.js")),p.join(e,"node_modules","vite","bin","vite.js")];for(let n of t)if(u.existsSync(n))return n;throw new Error("Vite is required for agent preview builds. Install vite in the project or SDK package.")}function Rt(e){let o=p.join(e,"src","components");if(!u.existsSync(p.join(o,"Question.tsx")))throw new Error(`Missing src/components/Question.tsx in ${e}. Build the survey UI before export-previews.`);let t=p.join(e,"src","lib"),n=p.join(e,"public");return{componentsDir:o,libDir:u.existsSync(t)?t:void 0,publicDir:u.existsSync(n)?n:void 0}}function $t(e,o,t){let n=p.join(e,"templates","docs","templates"),i=p.join(o,"agent","src","lib");u.mkdirSync(i,{recursive:!0});let r=p.join(n,"uiConfig.ts");if(!u.existsSync(r))throw new Error(`Missing template uiConfig.ts at ${r}`);u.copyFileSync(r,p.join(i,"uiConfig.ts"));let s=p.join(o,"agent","survey-ui-config.json"),c=p.join(t,"survey-ui-config.json");u.existsSync(c)?u.copyFileSync(c,s):u.existsSync(s)||u.writeFileSync(s,JSON.stringify({version:"1.0",global:{},questionTypes:{},placeholders:{}},null,2))}function At(e,o,t){let n=p.join(e,"templates","docs","templates"),i=p.join(o,"agent","src","components"),r=p.join(o,"agent","src","lib","surveyUi");u.mkdirSync(r,{recursive:!0});let s=["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 h of s){let g=p.join(n,h);u.existsSync(g)&&u.copyFileSync(g,p.join(i,h))}let c=["selectionStyles.ts","labelStyles.ts","heatmapCoords.ts","surveyUiScaleUtils.ts"];for(let h of c){let g=p.join(n,h);u.existsSync(g)&&u.copyFileSync(g,p.join(r,h))}let d=p.join(n,"heatmapCoords.ts");u.existsSync(d)&&u.copyFileSync(d,p.join(i,"heatmapCoords.ts")),$t(e,o,t)}function Ft(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
|
|
89
|
+
mountPreview(<QuestionPreview question={question} />);`}}function Et(e,o,t,n){let i=Tt(o,t),r=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,38 +121,42 @@ ${r}
|
|
|
121
121
|
},
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
|
-
`;u.writeFileSync(
|
|
125
|
-
</
|
|
126
|
-
|
|
124
|
+
`;u.writeFileSync(p.join(e,"vite.config.mjs"),s)}function kt(e,o,t){let n=u.readFileSync(e,"utf8"),i=!1;if(!n.includes("cfm-preview-fonts")&&t&&n.includes("</head>")&&(n=n.replace("</head>",`${t}
|
|
125
|
+
</head>`),i=!0),!n.includes("CFM_UI_CONFIG_SNAPSHOT")){let r=`<script>${o}</script>`;n=n.includes("</body>")?n.replace("</body>",`${r}
|
|
126
|
+
</body>`):`${n}
|
|
127
|
+
${r}`,i=!0}i&&u.writeFileSync(e,n)}function It(e){return e.replace(/_/g," ")}async function ko(e){let{projectRoot:o,outputDir:t,keys:n}=e,i=p.join(__dirname,"..",".."),r=p.join(i,"templates","preview-harness","vite-app");if(!u.existsSync(r))throw new Error(`Missing Vite preview harness template at ${r}`);let s=Rt(o),c=p.join(t,".preview-vite-work");u.existsSync(c)&&u.rmSync(c,{recursive:!0,force:!0}),re(r,c),u.mkdirSync(p.join(c,"agent","src"),{recursive:!0}),re(s.componentsDir,p.join(c,"agent","src","components")),s.libDir&&re(s.libDir,p.join(c,"agent","src","lib")),s.publicDir&&re(s.publicDir,p.join(c,"agent","public")),At(i,c,o);let d=p.join(o,"survey-ui-config.json");u.existsSync(d)&&u.copyFileSync(d,p.join(c,"agent","survey-ui-config.json"));let h=pe(o),g=p.join(c,"src","survey-theme.css");u.writeFileSync(g,h?u.readFileSync(h,"utf8"):u.readFileSync(p.join(i,"templates","survey-theme.css"),"utf8")),u.mkdirSync(p.join(c,"src","entries"),{recursive:!0});for(let I of n)u.mkdirSync(p.join(c,I),{recursive:!0}),u.writeFileSync(p.join(c,I,"index.html"),`<!DOCTYPE html>
|
|
127
128
|
<html lang="en">
|
|
128
129
|
<head>
|
|
129
130
|
<meta charset="UTF-8" />
|
|
130
131
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
131
|
-
<title>${
|
|
132
|
+
<title>${It(I)} \u2014 CFM Preview</title>
|
|
133
|
+
<link id="cfm-preview-fonts" rel="preconnect" href="https://fonts.googleapis.com" />
|
|
134
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
135
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Roboto:wght@400;500;600;700&family=Open+Sans:wght@400;500;600;700&family=Lato:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Montserrat:wght@400;500;600;700&family=Nunito:wght@400;500;600;700&family=Raleway:wght@400;500;600;700&family=Source+Sans+3:wght@400;500;600;700&family=Merriweather:wght@400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap" />
|
|
132
136
|
</head>
|
|
133
137
|
<body>
|
|
134
138
|
<div id="root"></div>
|
|
135
|
-
<script type="module" src="../src/entries/${
|
|
139
|
+
<script type="module" src="../src/entries/${I}.tsx"></script>
|
|
136
140
|
</body>
|
|
137
|
-
</html>`),u.writeFileSync(
|
|
138
|
-
${
|
|
139
|
-
${
|
|
140
|
-
`),sn(
|
|
141
|
+
</html>`),u.writeFileSync(p.join(c,"src","entries",`${I}.tsx`),Ft(I));u.writeFileSync(p.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)),Et(c,o,i,n);let b=xt(i,o),x=Ge(o).join(p.delimiter);Ct(`node "${b}" build --config "${p.join(c,"vite.config.mjs")}"`,{cwd:c,stdio:"inherit",env:{...process.env,NODE_PATH:x}});let A=p.join(t,"previews");u.mkdirSync(A,{recursive:!0});let E=p.join(c,"dist"),$=u.readFileSync(p.join(i,"templates","preview-harness","preview-bridge.inline.js"),"utf8"),S=u.readFileSync(p.join(i,"templates","preview-harness","preview-google-fonts.html"),"utf8").trim();for(let I of n){let m=p.join(E,I),C=p.join(A,I);if(!u.existsSync(p.join(m,"index.html")))throw new Error(`Vite build did not produce ${I}/index.html`);u.existsSync(C)&&u.rmSync(C,{recursive:!0,force:!0}),re(m,C),kt(p.join(C,"index.html"),$,S)}let f=p.join(E,"assets");u.existsSync(f)&&re(f,p.join(A,"assets"));let k=p.join(c,"agent","public");if(u.existsSync(k))for(let I of u.readdirSync(k)){let m=p.join(k,I);u.statSync(m).isFile()&&u.copyFileSync(m,p.join(A,I))}u.rmSync(c,{recursive:!0,force:!0})}import*as Qe from"fs";import*as Ke from"path";function Me(e){if(e)return e;let o=process.cwd();if(Qe.existsSync(Ke.join(o,"src","components","Question.tsx")))return o;let t=process.env.INIT_CWD;return t&&Qe.existsSync(Ke.join(t,"src","components","Question.tsx"))?t:o}var Io=["header","footer","survey_page"],Po={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"]},pi=[...Io,...Object.values(Po).flat()];function No(e){let o=new Set(Io);for(let t of e)for(let n of Po[t]??[])o.add(n);return[...o]}var O=a;function Pt(){return N.join(__dirname,"..","..","templates")}function Nt(e){let o=j.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 i of n)o.includes(i)&&t.add(i);return t.size?[...t]:n}function jt(e,o){let t=new Set(No(o));return e.filter(n=>t.has(n))}function Ye(e,o,t){if(j.existsSync(e))for(let n of j.readdirSync(e)){let i=N.join(e,n),r=N.posix.join(o,n);if(j.statSync(i).isDirectory())Ye(i,r,t);else{let s=N.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:r,contentType:c,sizeBytes:j.statSync(i).size})}}}async function ge(e={}){let o=Me(e.projectRoot),t=e.outputDir??N.join(o,"out"),n=Pt(),i=N.join(n,"preview-harness");e.useTemplatesOnly&&console.log(`${O.dim} Using SDK template preview harness only (--use-templates-only)${O.reset}`);let r=N.join(i,"previewPages.js"),{PREVIEW_PAGE_DEFS:s,buildPreviewHtml:c,PREVIEW_KEYS:d}=Pe(r),h=(()=>{let f=pe(o);return f?(console.log(`${O.dim} Using project theme: ${N.relative(o,f)}${O.reset}`),j.readFileSync(f,"utf8")):j.readFileSync(N.join(n,"survey-theme.css"),"utf8")})(),g=j.readFileSync(N.join(i,"preview-bridge.inline.js"),"utf8"),b=j.readFileSync(N.join(i,"preview-google-fonts.html"),"utf8").trim(),x=e.surveyTypes;if(!x){let f=N.join(o,"implementation_plan.md");x=j.existsSync(f)?Nt(f):["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"]}let A=jt(d,x),E=N.join(t,"previews");if(j.existsSync(E)&&(j.rmSync(E,{recursive:!0,force:!0}),console.log(`${O.dim} Cleared previous preview output${O.reset}`)),j.mkdirSync(E,{recursive:!0}),!e.useTemplatesOnly)try{console.log(`${O.dim} Building previews from agent components (Vite)\u2026${O.reset}`),await ko({projectRoot:o,outputDir:t,keys:A});let f={};for(let I of A)f[I]=`previews/${I}/index.html`;j.writeFileSync(N.join(t,"previews","manifest.json"),JSON.stringify(f,null,2));let k=[];return Ye(N.join(t,"previews"),"previews",k),console.log(`${O.green}\u2705 Exported ${A.length} agent component previews \u2192 ${t}${O.reset}`),{outputDir:t,manifestPath:N.join(t,"previews","manifest.json"),files:k,surveyTypes:x}}catch(f){console.warn(`${O.yellow}\u26A0 Agent Vite preview build failed; falling back to template harness.${O.reset}`),console.warn(`${O.dim} ${U(f)}${O.reset}`)}for(let f of s){if(!A.includes(f.key))continue;let k=N.join(t,"previews",f.key);j.mkdirSync(k,{recursive:!0}),j.writeFileSync(N.join(k,"index.html"),c(f,h,g,b))}let $={};for(let f of A)$[f]=`previews/${f}/index.html`;j.writeFileSync(N.join(t,"previews","manifest.json"),JSON.stringify($,null,2));let S=[];return Ye(N.join(t,"previews"),"previews",S),console.log(`${O.green}\u2705 Exported ${A.length} preview pages \u2192 ${t}${O.reset}`),{outputDir:t,manifestPath:N.join(t,"previews","manifest.json"),files:S,surveyTypes:x}}var _=a,Ee=["MCQ","TEXTFIELD","NPS_SCALE","CFM_MATRIX","CSAT_MATRIX","RATING_MATRIX","SLIDER_MATRIX","FILE_UPLOAD","TEXT_AND_MEDIA","HEATMAP","RANK_ORDER"];function Ho(e){return new Promise(o=>{let t=ke.createServer();t.listen(e,()=>{t.close(()=>o(e))}),t.on("error",()=>o(Ho(e+1)))})}function Xo(e){return new Promise((o,t)=>{let n="";e.on("data",i=>n+=i),e.on("end",()=>o(n)),e.on("error",t)})}function sn(e){let{exec:o}=Pe("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function no(e){let o=v.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 cn(e){let o=new Set,t,n=e.match(/\*\*instanceId:\*\*\s*(.+)/i);if(n){let r=n[1].replace(/[()[\]]/g,"").trim();r&&!r.startsWith("(")&&r!=="JWT"&&(t=r)}for(let r of Ee)e.includes(r)&&o.add(r);let i=e.matchAll(/\|\s*`([A-Z_]+)`\s*\|/g);for(let r of i)Ee.includes(r[1])&&o.add(r[1]);return{surveyTypes:o.size>0?[...o]:[...Ee],instanceId:t}}async function an(e){return new Promise(o=>{try{let t=ke.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 io(e){let o=v.join(e,"out","previews");P.existsSync(o)&&(P.rmSync(o,{recursive:!0,force:!0}),console.log(`${_.dim} Removed local preview files: out/previews/${_.reset}`))}async function Vo(){let e=process.env.INIT_CWD||process.cwd(),o=v.join(e,"public"),t=v.join(e,"survey-ui-config.json"),n=v.join(e,"implementation_plan.md"),i=v.join(__dirname,"..","..","templates"),r=v.join(i,"wizard-dist"),s=process.env.CFM_PREVIEW_URL??"http://localhost:3000",c={},d=v.join(e,"out","previews"),h=v.join(d,"manifest.json");console.log(`${_.dim} Exporting component previews for local wizard\u2026${_.reset}`),await ge({projectRoot:e,surveyTypes:[...Ee]}),P.existsSync(h)&&(c=JSON.parse(P.readFileSync(h,"utf8")));let g=await Ho(4200),b=`http://localhost:${g}`;return new Promise((x,A)=>{let E=ke.createServer(async(S,f)=>{try{let k=S.url??"/",I=k.split("?")[0];if(S.method==="GET"&&I.startsWith("/api/project-logo/")){let m=v.basename(decodeURIComponent(I.slice(18))),C=v.join(o,m),T=v.normalize(C);if(T.startsWith(o)&&P.existsSync(T)&&P.statSync(T).isFile()){let R=P.readFileSync(T);f.writeHead(200,{"Content-Type":no(T)}),f.end(R);return}f.writeHead(404),f.end("Logo not found");return}if(S.method==="GET"&&I==="/api/inventory"){let m;if(P.existsSync(n)){let R=P.readFileSync(n,"utf8");m=cn(R).instanceId}if(P.existsSync(t))try{let R=JSON.parse(P.readFileSync(t,"utf8"));R.instanceId&&(m=R.instanceId)}catch{}let C=[...Ee],{config:T}=me({projectRoot:e,surveyTypes:C,instanceId:m});f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({surveyTypes:C,instanceId:m,previewUrl:s,initialConfig:T,previewManifest:Object.fromEntries(Object.keys(c).map(R=>[R,`${b}/previews/${R}/index.html`]))}));return}if(S.method==="GET"&&k==="/api/preview-url"){let m=await an(s);f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({url:s,connected:m}));return}if(S.method==="POST"&&k.split("?")[0]==="/api/wizard-quit"){io(e),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({ok:!0,deleted:"out/previews"})),setTimeout(()=>{E.close(()=>{A(new Error("Client quit the wizard without saving. Local preview garbage collection complete (out/previews removed)."))})},300);return}if(S.method==="POST"&&k==="/api/upload-logo"){let m=await Xo(S),C=JSON.parse(m);P.existsSync(o)||P.mkdirSync(o,{recursive:!0});let T=C.base64.replace(/^data:image\/\w+;base64,/,""),R=Buffer.from(T,"base64"),V=v.extname(C.filename),J=v.basename(C.filename,V).toLowerCase().replace(/[^a-z0-9_-]/g,""),le=`logo_${Date.now()}_${J}${V||".png"}`;P.writeFileSync(v.join(o,le),R),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({fileName:le}));return}if(S.method==="POST"&&k==="/api/save-config"){let m=await Xo(S),C=JSON.parse(m);C.configuredAt=new Date().toISOString();let T=C.global?.logo;T?.url?.startsWith("data:")&&(T.url=null),P.writeFileSync(t,JSON.stringify(C,null,2),"utf8"),console.log(`
|
|
142
|
+
${_.green}\u2705 UI configuration saved to ${t}${_.reset}`);try{let{runApplyUiConfig:R}=await Promise.resolve().then(()=>(Fe(),Ae));R({projectRoot:e,configPath:t})}catch(R){console.log(`${_.yellow} CSS apply skipped: ${R instanceof Error?R.message:String(R)}${_.reset}`)}io(e),console.log(`${_.dim} Local preview garbage collection complete (out/previews removed)${_.reset}`),f.writeHead(200,{"Content-Type":"application/json"}),f.end(JSON.stringify({ok:!0})),setTimeout(()=>{E.close(()=>x())},500);return}if(S.method==="GET"){let m=k.split("?")[0];if(m==="/"&&(m="/index.html"),m.startsWith("/previews/")&&P.existsSync(d)){let R=m.replace(/^\/previews\//,""),V=v.join(d,R),J=v.normalize(V);if(J.startsWith(d)&&P.existsSync(J)&&P.statSync(J).isFile()){let le=P.readFileSync(J);f.writeHead(200,{"Content-Type":no(J)}),f.end(le);return}}let C=P.existsSync(r),T=C?v.join(r,m):v.join(i,"wizard.html");if(C&&P.existsSync(T)&&P.statSync(T).isFile()){let R=P.readFileSync(T);f.writeHead(200,{"Content-Type":no(T)}),f.end(R);return}if(!C&&m==="/index.html"){let R=P.readFileSync(v.join(i,"wizard.html"),"utf8");f.writeHead(200,{"Content-Type":"text/html"}),f.end(R);return}}f.writeHead(404,{"Content-Type":"text/plain"}),f.end("Not found")}catch(k){f.writeHead(500,{"Content-Type":"text/plain"}),f.end(`Server error: ${U(k)}`)}});E.listen(g,()=>{let S=b;console.log(`
|
|
143
|
+
${_.bold}${_.cyan}\u{1F3A8} Survey UI Customization Wizard${_.reset}`),console.log(`${_.bold}\u{1F517} Client wizard link \u2014 share this URL only:${_.reset}`),console.log(` ${_.green}${S}${_.reset}`),console.log(`${_.dim} Port ${g} (auto-selected if 4200 was in use)${_.reset}`),console.log(`${_.dim} Live previews: ${_.reset}${Object.keys(c).length} components`),console.log(`${_.dim} Preview target: ${_.reset}${s}`),console.log(`${_.dim} Default wizard \u2014 saves directly to survey-ui-config.json when client clicks Review & Build${_.reset}
|
|
144
|
+
`),sn(S)}),E.on("error",A);let $=()=>{io(e),E.close(()=>process.exit(130))};process.once("SIGINT",$),process.once("SIGTERM",$)})}q();import*as be from"fs";import*as Ko from"path";import*as Yo from"http";import*as Zo from"https";Ce();Re();$e();We();var w=a;function dn(e){let{exec:o}=Pe("child_process"),t=process.platform==="darwin"?`open "${e}"`:process.platform==="win32"?`start "" "${e}"`:`xdg-open "${e}"`;o(t)}function fn(e){return new Promise(o=>setTimeout(o,e))}async function so(e,o={}){return new Promise((t,n)=>{let i=new URL(e),s=(i.protocol==="https:"?Zo:Yo).request(i,{method:o.method??"GET",headers:o.headers??{}},c=>{let d="";c.on("data",h=>d+=h),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 pn(e,o,t,n){return new Promise((i,r)=>{let s=new URL(e),c=s.protocol==="https:"?Zo:Yo,d={"Content-Type":t,"Content-Length":o.length};n&&(d["X-Wizard-Session"]=n.sessionSecret,d["X-Wizard-Session-Id"]=n.sessionId);let h=c.request(s,{method:"PUT",headers:d},g=>{if((g.statusCode??500)>=400){let b="";g.on("data",x=>b+=x),g.on("end",()=>r(new Error(`PUT failed ${g.statusCode}: ${b}`)));return}g.resume(),i()});h.on("error",r),h.write(o),h.end()})}function un(e){try{let o=e.split(".")[1];return JSON.parse(Buffer.from(o,"base64url").toString("utf8")).surveyId??null}catch{return null}}async function et(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),i=process.env.CFM_INSTANCE_ID,r=(process.env.CFM_DEPLOY_API_BASE??"http://localhost:3000").replace(/\/$/,"");if(!i)throw new Error("CFM_INSTANCE_ID (JWT) is required");let s=un(i);if(!s)throw new Error("Could not parse surveyId from CFM_INSTANCE_ID JWT");let c=Me(),d=ne(c),h=d.activeConfigPath,g=e.apply?!1:e.review!==!1;console.log(`
|
|
141
145
|
${w.bold}${w.cyan}\u{1F3A8} CFM UI Customization (AWS)${w.reset}
|
|
142
|
-
`),
|
|
143
|
-
`));let
|
|
144
|
-
${w.bold}${w.cyan}\u{1F517} Client wizard link \u2014 share with the client:${w.reset}`),console.log(`${w.green} ${
|
|
145
|
-
`),dn(
|
|
146
|
-
${w.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${w.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(
|
|
147
|
-
${w.green}\u2705 Configuration ready${w.reset}`),
|
|
146
|
+
`),g&&(console.log(`${w.dim} Review mode: seed kept in survey-ui-config.json; final + diff written on complete.${w.reset}`),console.log(`${w.dim} Apply later with: npx cfm-sdk confirm-ui-config${w.reset}
|
|
147
|
+
`));let b=[...G],{outputDir:x,files:A}=await ge({projectRoot:c,useTemplatesOnly:e.useTemplatesOnly,surveyTypes:b}),E=A.map(m=>({path:m.path,contentType:m.contentType,sizeBytes:m.sizeBytes})),{config:$,source:S}=me({projectRoot:c,surveyTypes:b,instanceId:s});$.surveyTypes=b,Ve(S),g&&(be.writeFileSync(d.seedPath,JSON.stringify($,null,2),"utf8"),be.writeFileSync(h,JSON.stringify($,null,2),"utf8"),console.log(`${w.dim} Seed snapshot \u2192 survey-ui-config.json (+ .seed.json)${w.reset}`));let f=await so(`${r}/wizard/session/start`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({files:E,surveyTypes:b,initialConfig:$})});console.log(`${w.dim} Uploading ${E.length} preview files\u2026${w.reset}`);for(let m of f.uploads){let C=Ko.join(x,m.path),T=be.readFileSync(C),R=E.find(V=>V.path===m.path)?.contentType??"application/octet-stream";await pn(m.uploadUrl,T,R,{sessionId:f.sessionId,sessionSecret:f.sessionSecret})}if(await so(`${r}/wizard/previews/upload/complete`,{method:"POST",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},body:JSON.stringify({sessionId:f.sessionId})}),console.log(`${w.green}\u2705 Previews uploaded${w.reset}`),console.log(`${w.dim} ${E.length} component preview page(s) \u2192 EC2 local server (disk)${w.reset}`),console.log(`
|
|
148
|
+
${w.bold}${w.cyan}\u{1F517} Client wizard link \u2014 share with the client:${w.reset}`),console.log(`${w.green} ${f.wizardUrl}${w.reset}`),console.log(`${w.dim} (Deployed on EC2 \u2014 client customizes here; agent keeps CLI open until submit)${w.reset}
|
|
149
|
+
`),dn(f.wizardUrl),!o){console.log(`${w.yellow}--no-wait: wizard URL (not polling):${w.reset}`),console.log(f.wizardUrl),g&&console.log(`${w.dim} When wizard completes, poll manually or re-run without --no-wait to capture final + diff.${w.reset}`);return}let k=Date.now()+n,I=0;for(;Date.now()<k;){I+=1,process.stdout.write(`\r${w.dim}Waiting for client to finish wizard\u2026 (poll ${I})${w.reset}`);let m=await so(`${r}/wizard/config/${encodeURIComponent(s)}?sessionId=${f.sessionId}`,{headers:{Authorization:`Bearer ${i}`}});if(m.status==="abandoned")throw console.log(`
|
|
150
|
+
${w.yellow}\u26A0 Client quit the wizard \u2014 session cleaned up on S3${w.reset}`),new Error("Client quit the wizard without saving. S3 preview garbage was removed. Re-run customize-ui to start a new session.");if(m.status==="ready"&&m.config){let C=qe(m)??m.config;if(console.log(`
|
|
151
|
+
${w.green}\u2705 Configuration ready${w.reset}`),m.logoUrl&&console.log(`${w.dim} Logo URL: ${m.logoUrl}${w.reset}`),g){let V=ze(c,$,C);console.log(`${w.green} Seed (unchanged active): ${h}${w.reset}`),console.log(`${w.green} Final: ${d.finalPath}${w.reset}`),console.log(`${w.green} Diff: ${d.diffMdPath}${w.reset}`),console.log(`${w.yellow} ${V.changed.length} changed, ${V.added.length} added, ${V.removed.length} removed${w.reset}`);let J=C.global?.logo;if(J?.fileName)try{await ae({projectRoot:c,fileName:J.fileName,logoUrl:m.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${w.green} Logo saved to public/${J.fileName}${w.reset}`)}catch(le){console.warn(`${w.yellow} Logo download deferred: ${U(le)}${w.reset}`)}console.log(`${w.dim} Apply when ready: npx cfm-sdk confirm-ui-config (promotes JSON + regenerates survey-theme.css)${w.reset}`);return}be.writeFileSync(h,JSON.stringify(C,null,2),"utf8"),console.log(`${w.green} Written ${h}${w.reset}`);let{runApplyUiConfig:T}=await Promise.resolve().then(()=>(Fe(),Ae));T({projectRoot:c,configPath:h});let R=C.global?.logo;R?.fileName&&(await ae({projectRoot:c,fileName:R.fileName,logoUrl:m.logoUrl,jwt:i,apiBase:r,surveyId:s}),console.log(`${w.green} Logo saved to public/${R.fileName}${w.reset}`));return}await fn(t)}throw new Error("Timed out waiting for wizard completion")}Re();q();var L=a,ie=process.argv.slice(2),Z=ie[0];async function Cn(){if(Z==="customize"||Z==="init"){Z==="init"&&console.log(`${L.yellow}\u26A0 cfm-sdk init is deprecated. Use \`cfm-sdk customize\` instead.${L.reset}
|
|
148
152
|
`);try{await Vo()}catch(e){console.error(`
|
|
149
|
-
${
|
|
150
|
-
${
|
|
151
|
-
${
|
|
152
|
-
${
|
|
153
|
-
${
|
|
154
|
-
${
|
|
155
|
-
${
|
|
156
|
-
${
|
|
157
|
-
${
|
|
153
|
+
${L.red}\u274C Error: ${U(e)}${L.reset}`),process.exit(1)}}else if(Z==="customize-ui"){let e=ie.includes("--use-templates-only"),o=ie.includes("--no-wait"),t=ie.includes("--apply"),n=ie.includes("--no-review")?!1:!t;try{await et({useTemplatesOnly:e,wait:!o,review:n,apply:t})}catch(i){console.error(`
|
|
154
|
+
${L.red}\u274C Error: ${U(i)}${L.reset}`),process.exit(1)}}else if(Z==="confirm-ui-config"){let e=ie.includes("--diff-only");try{let{runConfirmUiConfig:o}=await Promise.resolve().then(()=>(tt(),ot));await o({diffOnly:e})}catch(o){console.error(`
|
|
155
|
+
${L.red}\u274C Error: ${U(o)}${L.reset}`),process.exit(1)}}else if(Z==="apply-ui-config")try{let{runApplyUiConfig:e}=await Promise.resolve().then(()=>(Fe(),Ae));e({})}catch(e){console.error(`
|
|
156
|
+
${L.red}\u274C Error: ${U(e)}${L.reset}`),process.exit(1)}else if(Z==="fetch-ui-config"){let o=ie.find(t=>t.startsWith("--session="))?.split("=")[1];try{let{runFetchUiConfig:t}=await Promise.resolve().then(()=>(it(),nt));await t({sessionId:o})}catch(t){console.error(`
|
|
157
|
+
${L.red}\u274C Error: ${U(t)}${L.reset}`),process.exit(1)}}else if(Z==="export-previews"){let e=ie.includes("--use-templates-only");try{await ge({useTemplatesOnly:e})}catch(o){console.error(`
|
|
158
|
+
${L.red}\u274C Error: ${U(o)}${L.reset}`),process.exit(1)}}else if(Z==="resolve-ui-config"){let e=ie.includes("--write");try{if(e){let o=Je();console.log(`${L.green}\u2705 Wrote ${o}${L.reset}`)}else{let{resolveInitialConfig:o}=await Promise.resolve().then(()=>(Re(),Eo)),{config:t,source:n}=o({surveyTypes:[]});console.log(JSON.stringify({source:n,config:t},null,2))}}catch(o){console.error(`
|
|
159
|
+
${L.red}\u274C Error: ${U(o)}${L.reset}`),process.exit(1)}}else if(Z==="deploy")try{await uo()}catch(e){console.error(`
|
|
160
|
+
${L.red}\u274C Error: ${U(e)}${L.reset}`),process.exit(1)}else console.log(`
|
|
161
|
+
${L.bold}${L.cyan}CFM SDK CLI Tool${L.reset}`),console.log(`
|
|
158
162
|
Usage:`),console.log(" npx cfm-sdk customize \u2013 Local UI customization wizard"),console.log(" npx cfm-sdk customize-ui \u2013 AWS wizard (review mode: seed + diff, no auto-apply)"),console.log(" npx cfm-sdk customize-ui --apply \u2013 AWS wizard (legacy: write final config immediately)"),console.log(" npx cfm-sdk confirm-ui-config \u2013 Promote final config + apply CSS to project"),console.log(" npx cfm-sdk apply-ui-config \u2013 Regenerate survey-theme.css from survey-ui-config.json"),console.log(" npx cfm-sdk fetch-ui-config \u2013 Pull final + diff after client completes (--no-wait)"),console.log(" npx cfm-sdk export-previews \u2013 Build component preview pages only"),console.log(" npx cfm-sdk resolve-ui-config --write \u2013 Write draft survey-ui-config.json from project"),console.log(" npx cfm-sdk deploy \u2013 Deploy to Vercel"),process.exit(0)}Cn();
|