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